-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
integrate ByteSlice into Bliss, resolve conflicts
- Loading branch information
Showing
11 changed files
with
227 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#ifndef BLISS_BENCH_COLUMNSKETCHES | ||
#define BLISS_BENCH_COLUMNSKETCHES | ||
#ifdef COMPILE_COLUMNSKETCHES | ||
#include <vector> | ||
|
||
#include "bliss/bliss_index.h" | ||
#include "column_sketches.h" | ||
|
||
namespace bliss { | ||
|
||
template <typename KEY_TYPE, typename VALUE_TYPE> | ||
class BlissColumnSketchesIndex : public BlissIndex<KEY_TYPE, VALUE_TYPE> { | ||
public: | ||
BlissColumnSketchesIndex() { | ||
columnsketches_ = new ColumnSketchesInteger(); | ||
}; | ||
|
||
~BlissColumnSketchesIndex() { | ||
delete columnsketches_; | ||
} | ||
|
||
void bulkload( | ||
std::vector<std::pair<KEY_TYPE, VALUE_TYPE>> values) override { | ||
std::vector<int32_t> vals; | ||
for(auto x: values) { | ||
vals.push_back(x.second); | ||
} | ||
columnsketches_->create(&vals[0], vals.size(), vals.size()); | ||
} | ||
|
||
bool get(VALUE_TYPE start, VALUE_TYPE end) { | ||
uint32_t *res = columnsketches_->query_ge_lt(start, end); | ||
bool succeed = res != nullptr; | ||
if(succeed) delete res; | ||
return succeed; | ||
} | ||
|
||
bool get(KEY_TYPE key) override { | ||
std::runtime_error("Column Imprints does not support get(key, value)."); | ||
return false; | ||
} | ||
|
||
void put(KEY_TYPE key, VALUE_TYPE value) { | ||
std::runtime_error("Column Imprints does not support put(key, value)."); | ||
return; | ||
} | ||
|
||
void end_routine() override {} | ||
private: | ||
|
||
ColumnSketchesInteger *columnsketches_; | ||
}; | ||
|
||
} // namespace bliss | ||
#endif | ||
#endif // !BLISS_BENCH_BTREE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#ifndef BLISS_BENCH_IMPRINTS | ||
#define BLISS_BENCH_IMPRINTS | ||
|
||
#include <vector> | ||
|
||
#include "bliss/bliss_index.h" | ||
#include "column_imprints.h" | ||
#include <string> | ||
|
||
namespace bliss { | ||
|
||
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 ColumnImprints::Imprints<VALUE_TYPE>(blocksize, maxbins, type_name); | ||
}; | ||
|
||
~BlissImprintsIndex() { | ||
delete imprints_; | ||
} | ||
|
||
void bulkload( | ||
std::vector<std::pair<KEY_TYPE, VALUE_TYPE>> values) override { | ||
std::vector<VALUE_TYPE> vals; | ||
for(auto x: values) { | ||
vals.push_back(x.second); | ||
} | ||
imprints_->bulkload(vals); | ||
} | ||
|
||
|
||
bool get(VALUE_TYPE start, VALUE_TYPE end) { | ||
unsigned int * res = imprints_->range_scan(start, end); | ||
if(res != nullptr) { | ||
delete res; | ||
return true; | ||
} else | ||
return false; | ||
} | ||
|
||
uint32_t * get_bitmask(VALUE_TYPE start, VALUE_TYPE end) { | ||
return imprints_->range_scan(start, end); | ||
} | ||
|
||
bool get(KEY_TYPE key) override { | ||
std::runtime_error("Column Imprints does not support get(key, value)."); | ||
return false; | ||
} | ||
|
||
void put(KEY_TYPE key, VALUE_TYPE value) { | ||
std::runtime_error("Column Imprints does not support put(key, value)."); | ||
return; | ||
} | ||
|
||
void end_routine() override {} | ||
private: | ||
ColumnImprints::Imprints<VALUE_TYPE> *imprints_; | ||
int blocksize_, maxbins_; | ||
std::string type_name; | ||
}; | ||
|
||
} // namespace bliss | ||
|
||
#endif // !BLISS_BENCH_BTREE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
get_filename_component(EXEC ${CMAKE_CURRENT_SOURCE_DIR} NAME) | ||
file(GLOB_RECURSE CPP_TESTS "*_tests.cpp") | ||
add_executable(${EXEC} ${CPP_TESTS}) | ||
target_link_libraries(${EXEC} PRIVATE | ||
bliss | ||
bliss_test_infra | ||
GTest::gtest_main) | ||
include(GoogleTest) | ||
gtest_discover_tests(${EXEC}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#include "bliss_index_tests.h" | ||
|
||
class ImprintsTest : public BlissIndexTest {}; | ||
|
||
TEST_F(ImprintsTest, TestImprint_Random) { | ||
index.reset(new bliss::BlissImprintsIndex<size_t, key_type>(64, 64, std::string("unsigned long"))); | ||
std::vector<key_type> data; | ||
GenerateData(data, num_keys, false); | ||
std::vector < std::pair<size_t, key_type> > bulkload_data; | ||
for (size_t i = 0; i < data.size(); i ++) { | ||
bulkload_data.push_back(std::make_pair(i, data[i])); | ||
} | ||
index->bulkload(bulkload_data); | ||
auto minimum = 0; | ||
for (size_t key = 0; key < num_keys; key += std::max(1,num_keys / 20)) { | ||
uint32_t *result = nullptr; | ||
bliss::BlissImprintsIndex<size_t, key_type> * index_copy = (bliss::BlissImprintsIndex<size_t, key_type> *)index.get(); | ||
result = (index_copy)->get_bitmask(minimum, data[key]); | ||
for(size_t i = 0; i < num_keys; i ++) { | ||
if((result[i / 32] >> (i & 31)) & 1u) { | ||
EXPECT_TRUE(data[i] <= data[key] && data[i] > minimum); | ||
} else { | ||
EXPECT_FALSE(data[i] <= data[key] && data[i] > minimum); | ||
} | ||
} | ||
free(result); | ||
} | ||
} |