Commit a90e5204 authored by Ari Trachtenberg's avatar Ari Trachtenberg
Browse files

Merge branch 'autograder' into 'master'

hw4 autograder

See merge request !1
parents f9b32386 26da89fa
Loading
Loading
Loading
Loading

ci_cd/.gitlab-ci.yml

0 → 100644
+11 −0
Original line number Diff line number Diff line
stages:
  - prebuild
  - compile
  - test

include:
  - local: 'ci_cd/problem2.yml'
  - local: 'ci_cd/problem3.yml'

default:
  timeout: 5m

ci_cd/problem2.yml

0 → 100644
+52 −0
Original line number Diff line number Diff line
prebuild_problem_2:
  stage: prebuild
  script:
    - |
      # Check if source files exist
      if [ ! -f "impl/MyBloom.h" ]; then
        echo "MyBloom.h does not exist under include directory";
        exit 1;
      fi
      if [ ! -f "impl/MyBloom.cpp" ]; then
        echo "MyBloom.cpp does not exist under impl directory";
        exit 1;
      fi
    - git clone https://agile.bu.edu/gitlab/configs/ec330/homeworks/homeworkFour.git hw4
  artifacts:
    paths:
      - hw4/
  rules:
    - if: '$CI_COMMIT_REF_NAME == "problem2"'
  tags: [c++-17]

compile_problem_2:
  stage: compile
  needs:
    - job: prebuild_problem_2
      artifacts: true
  script:
    - cp include/MyBloom.h hw4/tests/include/
    - cp impl/MyBloom.cpp hw4/tests/impl/
    - cd hw4/tests
    - make problem2
  artifacts:
    paths:
      - hw4/
  rules:
    - if: '$CI_COMMIT_REF_NAME == "problem2"'
  tags: [c++-17]

exec_problem_2:
  stage: test
  needs:
    - job: compile_problem_2
      artifacts: true
  script:
    - cd hw4/tests
    - ./problem2
  artifacts:
    paths:
      - hw4/
  rules:
    - if: '$CI_COMMIT_REF_NAME == "problem2"'
  tags: [c++-17]
 No newline at end of file

ci_cd/problem3.yml

0 → 100644
+47 −0
Original line number Diff line number Diff line
prebuild_problem_3:
  stage: prebuild
  script:
    - |
      # Check if source files exist
      if [ ! -f "impl/MiningHash.cpp" ]; then
        echo "MiningHash.cpp does not exist under impl directory";
        exit 1;
      fi
    - git clone https://agile.bu.edu/gitlab/configs/ec330/homeworks/homeworkFour.git hw4
  artifacts:
    paths:
      - hw4/
  rules:
    - if: '$CI_COMMIT_REF_NAME == "problem3"'
  tags: [c++-17]

compile_problem_3:
  stage: compile
  needs:
    - job: prebuild_problem_3
      artifacts: true
  script:
    - cp impl/MiningHash.cpp hw4/tests/impl/
    - cd hw4/tests
    - make problem3
  artifacts:
    paths:
      - hw4/
  rules:
    - if: '$CI_COMMIT_REF_NAME == "problem3"'
  tags: [c++-17]

exec_problem_3:
  stage: test
  needs:
    - job: compile_problem_3
      artifacts: true
  script:
    - cd hw4/tests
    - ./problem3
  artifacts:
    paths:
      - hw4/
  rules:
    - if: '$CI_COMMIT_REF_NAME == "problem3"'
  tags: [c++-17]
 No newline at end of file

tests/Makefile

0 → 100644
+39 −0
Original line number Diff line number Diff line
# Makefile, generated with support of ChatGPT

# Compiler and flags
CXX = g++ -O2
CXXFLAGS = -Wall -std=c++17

# Source files
PROBLEM2_SRCS = testBloom.cpp
PROBLEM3_SRCS = testHash.cpp
SRCS = $(PROBLEM2_SRCS) $(PROBLEM3_SRCS)

# Object files
PROBLEM2_OBJS = testBloom.o
PROBLEM3_OBJS = testHash.o
OBJS = $(PROBLEM2_OBJS)  $(PROBLEM3_OBJS)

# Executable names
PROBLEM2_EXEC = problem2
PROBLEM3_EXEC = problem3
EXECS = $(PROBLEM2_EXEC) $(PROBLEM3_EXEC)

# Default target to build the executable
all: $(PROBLEM2_EXEC) $(PROBLEM3_EXEC)

# Rule to build the executable from object files
$(PROBLEM2_EXEC): $(PROBLEM2_OBJS) Makefile
	$(CXX) $(CXXFLAGS) -o $(PROBLEM2_EXEC) $(PROBLEM2_OBJS)

$(PROBLEM3_EXEC): $(PROBLEM3_OBJS) Makefile
	$(CXX) $(CXXFLAGS) -o $(PROBLEM3_EXEC) $(PROBLEM3_OBJS)

# Rules to build object files from source files, with dependency on the Common.h header
%.o: %.cpp Makefile
	$(CXX) $(CXXFLAGS) -c $< -o $@

# Clean target to remove compiled files
clean:
	rm -f $(OBJS) $(EXEC)

tests/include/Bloom.h

0 → 100644
+71 −0
Original line number Diff line number Diff line
//
// Created by Ari Trachtenberg on 3/15/17.
//

#ifndef BLOOM_OBJECT_H
#define BLOOM_OBJECT_H

#include <string>
#include <array>
#include <memory>

using namespace std;

/**
 * Represents a Bloom object corresponding to a character-based Bloom filter.
 * \tparam length The length (in characters) of the Bloom filter.
 */
template<size_t length>
class Bloom {
public:
    /**
     * Instantiate an empty Bloom filter object
     */
    Bloom () = default;

    /**
     * @return A pointer to an empty Bloom filter.
     */
    virtual unique_ptr< Bloom > makeBloom() = 0;

    /**
     * Instantiates a Bloom filter object from a given \param theFilter string
     * \param theFilter The object is created to represent this \param theFilter
     * \pre \param theFilter must have been produced by the \ref getFilter()
     *     method of some BloomFilter object of the same length, or else the
     *     behavior is unspecified.
     * \return A pointer to a Bloom filter corresponding to \param theFilter
     */
     virtual unique_ptr< Bloom > makeBloom(const array<char,length>& theFilter) = 0;

    /**
     * inserts \param item into the Bloom object.
     */
     virtual void insert(string item)=0;

    /**
     * Checks whether \param item is in the Bloom filter object.
     * @return  true if \param item may be in the Bloom filter object
     *          false if \param item  is definitely not in the Bloom filter object
     */
    virtual bool exists(string item)=0;

    /**
     * \return A filter string representing the Bloom object
     */
    const array<char,length> getFilter() const { return filter; }

    /**
     * Destructor for the Bloom object
     */
    virtual ~Bloom() = default;

protected:
    /**
     * The filter itself.
     */
    array<char,length> filter;
};


#endif //BLOOM_OBJECT_H
Loading