Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate ByteSlice into bliss #48

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ add_library(bliss OBJECT
${CMAKE_SOURCE_DIR}/src/bliss/bench_alex.h
${CMAKE_SOURCE_DIR}/src/bliss/bench_btree.h
${CMAKE_SOURCE_DIR}/src/bliss/bench_skiplist.h
${CMAKE_SOURCE_DIR}/src/bliss/bench_byteslice.h
${CMAKE_SOURCE_DIR}/src/bliss/bench_pgm.h
${CMAKE_SOURCE_DIR}/src/bliss/bench_art.h
${CMAKE_SOURCE_DIR}/src/bliss/bench_leveldb.h
Expand All @@ -71,6 +72,7 @@ target_link_libraries(bliss PUBLIC
alex
lipp
tlx
byteslice
skiplist
pgm
art
Expand Down
28 changes: 27 additions & 1 deletion external/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,32 @@ add_library(tlx INTERFACE)
target_include_directories(tlx INTERFACE ${tlx_SOURCE_DIR}/)


FetchContent_Declare(
byteslice
GIT_REPOSITORY https://github.com/altramarine/ByteSlice.git
GIT_TAG master
)
FetchContent_GetProperties(byteslice)

if (NOT byteslice_POPULATED)
FetchContent_Populate(byteslice)
endif()
file(GLOB_RECURSE byteslice_SOURCES
${byteslice_SOURCE_DIR}/src/*.cpp
)
add_library(byteslice STATIC ${byteslice_SOURCES})
target_include_directories(byteslice PUBLIC ${byteslice_SOURCE_DIR}/)
# OpenMP is required for byteslice
find_package(OpenMP REQUIRED)
if(OpenMP_CXX_FOUND)
target_link_libraries(byteslice PRIVATE OpenMP::OpenMP_CXX)
endif()
target_compile_options(byteslice PUBLIC
"-mavx2"
"-m64"
"-fopenmp"
)

FetchContent_Declare(
skiplist
GIT_REPOSITORY https://github.com/petegoodliffe/skip_list
Expand Down Expand Up @@ -114,4 +140,4 @@ if (NOT pgm_POPULATED)
endif()

add_library(pgm INTERFACE)
target_include_directories(pgm INTERFACE ${pgm_SOURCE_DIR})
target_include_directories(pgm INTERFACE ${pgm_SOURCE_DIR})
56 changes: 56 additions & 0 deletions src/bliss/bench_byteslice.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#ifndef BLISS_BENCH_BYTESLICE
#define BLISS_BENCH_BYTESLICE

#include <vector>

#include "bliss/bliss_index.h"
#include "src/byteslice.h"
#include <string>

namespace bliss {

template <typename KEY_TYPE, typename VALUE_TYPE>
class BlissByteSliceIndex : public BlissIndex<KEY_TYPE, VALUE_TYPE> {
public:
BlissByteSliceIndex(int numrows = 1000000, int numbits = 32) {
byteslice_ = new ByteSlice(numrows, numbits);
};

~BlissByteSliceIndex() {
delete byteslice_;
}

void bulkload(
std::vector<std::pair<KEY_TYPE, VALUE_TYPE>> values) override {
int i = 0;
for(auto x: values) {
byteslice_->setTuple(i, static_cast<unsigned long long>(x.second));
}
}


bool get(VALUE_TYPE low, VALUE_TYPE high) {
uint32_t * result = byteslice_->query(static_cast<unsigned long long>(low), static_cast<unsigned long long>(high));
bool check_ = result != nullptr;
if(check_) delete result;
return check_;
}

bool get(KEY_TYPE key) override {
std::runtime_error("ByteSlice does not support get(key, value).");
return false;
}

void put(KEY_TYPE key, VALUE_TYPE value) {
std::runtime_error("ByteSlice does not support put(key, value).");
return;
}

void end_routine() override {}
private:
ByteSlice *byteslice_;
};

} // namespace bliss

#endif // !BLISS_BENCH_BTREE
2 changes: 1 addition & 1 deletion src/bliss/bliss_index.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ class BlissIndex {

} // namespace bliss

#endif // !BLISS_INDEX
#endif // !BLISS_INDEX
3 changes: 3 additions & 0 deletions src/bliss_bench.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "bliss/bench_btree.h"
#include "bliss/bench_leveldb.h"
#include "bliss/bench_lipp.h"
#include "bliss/bench_byteslice.h"
#include "bliss/bench_pgm.h"
#include "bliss/bench_skiplist.h"
#include "bliss/bliss_index.h"
Expand Down Expand Up @@ -174,6 +175,8 @@ int main(int argc, char *argv[]) {
index.reset(new bliss::BlissLippIndex<key_type, value_type>());
} else if (config.index == "btree") {
index.reset(new bliss::BlissBTreeIndex<key_type, value_type>());
} else if (config.index == "byteslice") {
index.reset(new bliss::BlissByteSliceIndex<key_type, value_type>());
} else if (config.index == "skiplist") {
index.reset(new bliss::BlissSkipListIndex<key_type, value_type>());
} else if (config.index == "art") {
Expand Down