-
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.
[Features] integrating skiplist (#37)
* skiplist implementation * adding skiplist & skiplist unit tests * fixing minor bugs: (use bench_lipp in bench_lipp unit test, fix gitimport error for alex)
- Loading branch information
Showing
9 changed files
with
105 additions
and
6 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,33 @@ | ||
#ifndef BLISS_BENCH_SKIPLIST | ||
#define BLISS_BENCH_SKIPLIST | ||
|
||
#include <vector> | ||
|
||
#include "bliss/bliss_index.h" | ||
#include "skiplist_map.hpp" | ||
|
||
namespace bliss { | ||
|
||
template <typename KEY_TYPE, typename VALUE_TYPE> | ||
class BlissSkipListIndex : public BlissIndex<KEY_TYPE, VALUE_TYPE> { | ||
public: | ||
skiplist<KEY_TYPE, VALUE_TYPE> _index; | ||
BlissSkipListIndex() : _index(){}; | ||
|
||
void bulkload( | ||
std::vector<std::pair<KEY_TYPE, VALUE_TYPE>> values) override { | ||
for (const auto& pair : values) { | ||
_index.insert(pair.first, pair.second); | ||
} | ||
} | ||
|
||
bool get(KEY_TYPE key) override { return _index.find(key) != _index.end(); } | ||
|
||
void put(KEY_TYPE key, VALUE_TYPE value) override { _index.insert(key, value); } | ||
|
||
void end_routine() override {} | ||
}; | ||
|
||
} // namespace bliss | ||
|
||
#endif // !BLISS_BENCH_SKIPLIST |
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,31 @@ | ||
#include "bliss_index_tests.h" | ||
|
||
class SkipListTest : public BlissIndexTest {}; | ||
|
||
TEST_F(SkipListTest, TestSkipList_Sorted) { | ||
index.reset(new bliss::BlissSkipListIndex<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(SkipListTest, TestSkipList_Random) { | ||
index.reset(new bliss::BlissSkipListIndex<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)); | ||
} | ||
} |