-
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.
We integrated Column Imprints into Bliss. Column Imprints requires 2 tuning knobs (block_size and #bins) and supports different data types. You have to manually pass a string to tell the exact type of the data.
- Loading branch information
1 parent
4281f2c
commit 0336039
Showing
9 changed files
with
122 additions
and
1 deletion.
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
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 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: | ||
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); | ||
} | ||
} |