Skip to content

Commit a60328c

Browse files
authored
Integrate ByteSlice into bliss (#48)
ByteSlice is now integrated into Bliss, with two parameters to pass: number of rows and number of bits per row.
1 parent 0336039 commit a60328c

File tree

5 files changed

+89
-2
lines changed

5 files changed

+89
-2
lines changed

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ add_library(bliss OBJECT
6161
${CMAKE_SOURCE_DIR}/src/bliss/bench_imprints.h
6262
${CMAKE_SOURCE_DIR}/src/bliss/bench_columnsketches.h
6363
${CMAKE_SOURCE_DIR}/src/bliss/bench_skiplist.h
64+
${CMAKE_SOURCE_DIR}/src/bliss/bench_byteslice.h
6465
${CMAKE_SOURCE_DIR}/src/bliss/bench_pgm.h
6566
${CMAKE_SOURCE_DIR}/src/bliss/bench_art.h
6667
${CMAKE_SOURCE_DIR}/src/bliss/bench_leveldb.h
@@ -76,6 +77,7 @@ target_link_libraries(bliss PUBLIC
7677
alex
7778
lipp
7879
tlx
80+
byteslice
7981
imprints
8082
skiplist
8183
pgm

external/CMakeLists.txt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,32 @@ if(COMPILE_COLUMNSKETCHES)
112112
)
113113
endif()
114114

115+
FetchContent_Declare(
116+
byteslice
117+
GIT_REPOSITORY https://github.com/altramarine/ByteSlice.git
118+
GIT_TAG master
119+
)
120+
FetchContent_GetProperties(byteslice)
121+
122+
if (NOT byteslice_POPULATED)
123+
FetchContent_Populate(byteslice)
124+
endif()
125+
file(GLOB_RECURSE byteslice_SOURCES
126+
${byteslice_SOURCE_DIR}/src/*.cpp
127+
)
128+
add_library(byteslice STATIC ${byteslice_SOURCES})
129+
target_include_directories(byteslice PUBLIC ${byteslice_SOURCE_DIR}/)
130+
# OpenMP is required for byteslice
131+
find_package(OpenMP REQUIRED)
132+
if(OpenMP_CXX_FOUND)
133+
target_link_libraries(byteslice PRIVATE OpenMP::OpenMP_CXX)
134+
endif()
135+
target_compile_options(byteslice PUBLIC
136+
"-mavx2"
137+
"-m64"
138+
"-fopenmp"
139+
)
140+
115141
FetchContent_Declare(
116142
skiplist
117143
GIT_REPOSITORY https://github.com/petegoodliffe/skip_list

src/bliss/bench_byteslice.h

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#ifndef BLISS_BENCH_BYTESLICE
2+
#define BLISS_BENCH_BYTESLICE
3+
4+
#include <vector>
5+
6+
#include "bliss/bliss_index.h"
7+
#include "src/byteslice.h"
8+
#include <string>
9+
10+
namespace bliss {
11+
12+
template <typename KEY_TYPE, typename VALUE_TYPE>
13+
class BlissByteSliceIndex : public BlissIndex<KEY_TYPE, VALUE_TYPE> {
14+
public:
15+
BlissByteSliceIndex(int numrows = 1000000, int numbits = 32) {
16+
byteslice_ = new byteslice::ByteSlice(numrows, numbits);
17+
};
18+
19+
~BlissByteSliceIndex() {
20+
delete byteslice_;
21+
}
22+
23+
void bulkload(
24+
std::vector<std::pair<KEY_TYPE, VALUE_TYPE>> values) override {
25+
int i = 0;
26+
for(auto x: values) {
27+
byteslice_->setTuple(i, static_cast<unsigned long long>(x.second));
28+
}
29+
}
30+
31+
32+
bool get(VALUE_TYPE start, VALUE_TYPE end) {
33+
uint32_t * result = byteslice_->query(static_cast<unsigned long long>(start), static_cast<unsigned long long>(end));
34+
bool check_ = result != nullptr;
35+
if(check_) delete result;
36+
return check_;
37+
}
38+
39+
bool get(KEY_TYPE key) override {
40+
std::runtime_error("ByteSlice does not support get(key, value).");
41+
return false;
42+
}
43+
44+
void put(KEY_TYPE key, VALUE_TYPE value) {
45+
std::runtime_error("ByteSlice does not support put(key, value).");
46+
return;
47+
}
48+
49+
void end_routine() override {}
50+
private:
51+
byteslice::ByteSlice *byteslice_;
52+
};
53+
54+
} // namespace bliss
55+
56+
#endif // !BLISS_BENCH_BTREE

src/bliss/bench_imprints.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ template <typename KEY_TYPE, typename VALUE_TYPE>
1313
class BlissImprintsIndex : public BlissIndex<KEY_TYPE, VALUE_TYPE> {
1414
public:
1515
BlissImprintsIndex(int blocksize = 64, int maxbins = 64, std::string type_name = std::string("unsigned long")) : blocksize_(blocksize), maxbins_(maxbins) {
16-
imprints_ = new Imprints<VALUE_TYPE>(blocksize, maxbins, type_name);
16+
imprints_ = new ColumnImprints::Imprints<VALUE_TYPE>(blocksize, maxbins, type_name);
1717
};
1818

1919
~BlissImprintsIndex() {
@@ -55,7 +55,7 @@ class BlissImprintsIndex : public BlissIndex<KEY_TYPE, VALUE_TYPE> {
5555

5656
void end_routine() override {}
5757
private:
58-
Imprints<VALUE_TYPE> *imprints_;
58+
ColumnImprints::Imprints<VALUE_TYPE> *imprints_;
5959
int blocksize_, maxbins_;
6060
std::string type_name;
6161
};

src/bliss_bench.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "bliss/bench_btree.h"
1212
#include "bliss/bench_leveldb.h"
1313
#include "bliss/bench_lipp.h"
14+
#include "bliss/bench_byteslice.h"
1415
#include "bliss/bench_columnsketches.h"
1516
#include "bliss/bench_pgm.h"
1617
#include "bliss/bench_skiplist.h"
@@ -176,6 +177,8 @@ int main(int argc, char *argv[]) {
176177
index.reset(new bliss::BlissLippIndex<key_type, value_type>());
177178
} else if (config.index == "btree") {
178179
index.reset(new bliss::BlissBTreeIndex<key_type, value_type>());
180+
} else if (config.index == "byteslice") {
181+
index.reset(new bliss::BlissByteSliceIndex<key_type, value_type>());
179182
} else if (config.index == "imprints") {
180183
index.reset(new bliss::BlissImprintsIndex<key_type, value_type>(/* block_size */64, /* max_bins */64));
181184
} else if (config.index == "columnskteches") {

0 commit comments

Comments
 (0)