-
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.
[Integration] Adding ART to the benchmark (#38)
* ART integration - work in progress * art fixes * fixing execute * fixed art * clean up code * merge from master * fixed minor bug --------- Co-authored-by: Lucas <[email protected]>
- Loading branch information
1 parent
b87c2bf
commit 2b9cf5c
Showing
10 changed files
with
143 additions
and
16 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,46 @@ | ||
#ifndef BLISS_BENCH_ART | ||
#define BLISS_BENCH_ART | ||
|
||
#include <vector> | ||
|
||
#include "ART.h" | ||
#include "bliss/bliss_index.h" | ||
#include "spdlog/spdlog.h" | ||
|
||
namespace bliss { | ||
|
||
template <typename KEY_TYPE, typename VALUE_TYPE> | ||
class BlissARTIndex : public BlissIndex<KEY_TYPE, VALUE_TYPE> { | ||
public: | ||
ART::ArtNode* _index; | ||
static constexpr size_t KEY_SIZE = sizeof(KEY_TYPE); | ||
BlissARTIndex() { _index = nullptr; }; | ||
|
||
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) { | ||
put(pair.first, pair.second); | ||
} | ||
} | ||
|
||
bool get(KEY_TYPE key) override { | ||
uint8_t ARTkey[KEY_SIZE]; | ||
ART::loadKey(key, ARTkey); | ||
ART::ArtNode* leaf = | ||
ART::lookup(_index, ARTkey, KEY_SIZE, 0, KEY_SIZE); | ||
return leaf != nullptr && ART::isLeaf(leaf); | ||
} | ||
|
||
void put(KEY_TYPE key, VALUE_TYPE value) override { | ||
uint8_t ARTkey[KEY_SIZE]; | ||
ART::loadKey(key, ARTkey); | ||
ART::insert(_index, &_index, ARTkey, 0, key, KEY_SIZE); | ||
} | ||
|
||
void end_routine() override {} | ||
}; | ||
|
||
} // namespace bliss | ||
|
||
#endif |
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,42 @@ | ||
#include "bliss_index_tests.h" | ||
|
||
class ArtTest : public BlissIndexTest {}; | ||
|
||
|
||
TEST_F(ArtTest, TestArt_Sanity) { | ||
index.reset(new bliss::BlissARTIndex<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(ArtTest, TestArt_Sorted) { | ||
index.reset(new bliss::BlissARTIndex<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(ArtTest, TestArt_Random) { | ||
index.reset(new bliss::BlissARTIndex<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)); | ||
} | ||
} |