Skip to content

Commit

Permalink
Integrate ByteSlice into bliss (#48)
Browse files Browse the repository at this point in the history
ByteSlice is now integrated into Bliss, with two parameters to pass: number of rows and number of bits per row.
  • Loading branch information
altramarine authored Feb 21, 2025
1 parent 0336039 commit a60328c
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ add_library(bliss OBJECT
${CMAKE_SOURCE_DIR}/src/bliss/bench_imprints.h
${CMAKE_SOURCE_DIR}/src/bliss/bench_columnsketches.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 @@ -76,6 +77,7 @@ target_link_libraries(bliss PUBLIC
alex
lipp
tlx
byteslice
imprints
skiplist
pgm
Expand Down
26 changes: 26 additions & 0 deletions external/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,32 @@ if(COMPILE_COLUMNSKETCHES)
)
endif()

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
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::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 start, VALUE_TYPE end) {
uint32_t * result = byteslice_->query(static_cast<unsigned long long>(start), static_cast<unsigned long long>(end));
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 *byteslice_;
};

} // namespace bliss

#endif // !BLISS_BENCH_BTREE
4 changes: 2 additions & 2 deletions src/bliss/bench_imprints.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ template <typename KEY_TYPE, typename VALUE_TYPE>
class BlissImprintsIndex : public BlissIndex<KEY_TYPE, VALUE_TYPE> {
public:
BlissImprintsIndex(int blocksize = 64, int maxbins = 64, std::string type_name = std::string("unsigned long")) : blocksize_(blocksize), maxbins_(maxbins) {
imprints_ = new Imprints<VALUE_TYPE>(blocksize, maxbins, type_name);
imprints_ = new ColumnImprints::Imprints<VALUE_TYPE>(blocksize, maxbins, type_name);
};

~BlissImprintsIndex() {
Expand Down Expand Up @@ -55,7 +55,7 @@ class BlissImprintsIndex : public BlissIndex<KEY_TYPE, VALUE_TYPE> {

void end_routine() override {}
private:
Imprints<VALUE_TYPE> *imprints_;
ColumnImprints::Imprints<VALUE_TYPE> *imprints_;
int blocksize_, maxbins_;
std::string type_name;
};
Expand Down
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_columnsketches.h"
#include "bliss/bench_pgm.h"
#include "bliss/bench_skiplist.h"
Expand Down Expand Up @@ -176,6 +177,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 == "imprints") {
index.reset(new bliss::BlissImprintsIndex<key_type, value_type>(/* block_size */64, /* max_bins */64));
} else if (config.index == "columnskteches") {
Expand Down

0 comments on commit a60328c

Please sign in to comment.