-
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.
* adding pgm index * make pgm sanity tests * clean up code * fix pgm test bug
- Loading branch information
Showing
8 changed files
with
125 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#ifndef BLISS_BENCH_PGM | ||
#define BLISS_BENCH_PGM | ||
|
||
#include <vector> | ||
|
||
#include "bliss/bliss_index.h" | ||
#include "include/pgm/pgm_index_dynamic.hpp" | ||
|
||
|
||
namespace bliss { | ||
|
||
template <typename KEY_TYPE, typename VALUE_TYPE> | ||
class BlissPGMIndex : public BlissIndex<KEY_TYPE, VALUE_TYPE> { | ||
public: | ||
pgm::DynamicPGMIndex<KEY_TYPE, VALUE_TYPE> _index; | ||
BlissPGMIndex() : _index(){}; | ||
|
||
void bulkload( | ||
std::vector<std::pair<KEY_TYPE, VALUE_TYPE>> values) override { | ||
// expects the pairs to be pre-sorted before performing bulk load | ||
for (const auto& pair : values) { | ||
this->put(pair.first, pair.second); | ||
} | ||
} | ||
|
||
bool get(KEY_TYPE key) override { | ||
auto it = _index.find(key); | ||
return it != _index.end(); | ||
} | ||
|
||
void put(KEY_TYPE key, VALUE_TYPE value) override { _index.insert_or_assign(key, value); } | ||
|
||
void end_routine() override {} | ||
}; | ||
|
||
} // namespace bliss | ||
|
||
#endif // !BLISS_BENCH_PGM |
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,43 @@ | ||
#include "bliss_index_tests.h" | ||
|
||
class PGMTest : public BlissIndexTest {}; | ||
|
||
|
||
TEST_F(PGMTest, TestPGM_Sanity) { | ||
index.reset(new bliss::PGMIndex<key_type, key_type>()); | ||
std::vector<key_type> data; | ||
int key = 100'000; | ||
int value = 123'456; | ||
index->put(key, value); | ||
EXPECT_TRUE(index->get(key)); | ||
} | ||
|
||
|
||
TEST_F(PGMTest, TestPGM_Sorted) { | ||
index.reset(new bliss::PGMIndex<key_type, key_type>()); | ||
std::vector<key_type> data; | ||
GenerateData(data, num_keys); | ||
|
||
auto insert_start = data.begin(); | ||
auto insert_end = data.end(); | ||
executor::execute_inserts(*index, insert_start, insert_end); | ||
|
||
for (auto key : data) { | ||
EXPECT_TRUE(index->get(key)); | ||
} | ||
} | ||
|
||
|
||
TEST_F(PGMTest, TestPGM_Random) { | ||
index.reset(new bliss::PGMIndex<key_type, key_type>()); | ||
std::vector<key_type> data; | ||
GenerateData(data, num_keys, false); | ||
|
||
auto insert_start = data.begin(); | ||
auto insert_end = data.end(); | ||
executor::execute_inserts(*index, insert_start, insert_end); | ||
|
||
for (auto key : data) { | ||
EXPECT_TRUE(index->get(key)); | ||
} | ||
} |