-
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.
- Loading branch information
Showing
9 changed files
with
151 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,6 @@ | |
path = external/rocksdb | ||
url = [email protected]:BU-DiSC/rocksdb.git | ||
branch = sortedness | ||
[submodule "external/leveldb_bliss"] | ||
path = external/leveldb_bliss | ||
url = [email protected]:JslYoon/leveldb_bliss.git |
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
Submodule leveldb_bliss
added at
434e20
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,80 @@ | ||
#ifndef BLISS_BENCH_LEVELDB | ||
#define BLISS_BENCH_LEVELDB | ||
|
||
#include <vector> | ||
#include <string> | ||
#include <sstream> | ||
#include <cstdlib> | ||
#include <iostream> | ||
|
||
#include "bliss/bliss_index.h" | ||
#include "leveldb/db.h" | ||
|
||
namespace bliss { | ||
|
||
template <typename KEY_TYPE, typename VALUE_TYPE> | ||
class BlissLevelDBIndex : public BlissIndex<KEY_TYPE, VALUE_TYPE> { | ||
public: | ||
leveldb::DB* db_; | ||
|
||
|
||
BlissLevelDBIndex() { | ||
leveldb::Options options; | ||
options.create_if_missing = true; | ||
|
||
std::string db_path = "/tmp/bliss_leveldb_index"; | ||
leveldb::Status status = leveldb::DB::Open(options, db_path, &db_); | ||
if (!status.ok()) { | ||
std::cerr << "Failed to open LevelDB at " << db_path << ": " | ||
<< status.ToString() << std::endl; | ||
std::exit(1); | ||
} | ||
} | ||
|
||
|
||
void bulkload(std::vector<std::pair<KEY_TYPE, VALUE_TYPE>> values) override { | ||
for (const auto& kv : values) { | ||
put(kv.first, kv.second); | ||
} | ||
} | ||
|
||
|
||
bool get(KEY_TYPE key) override { | ||
std::string key_str = to_string(key); | ||
std::string value; | ||
leveldb::Status status = db_->Get(leveldb::ReadOptions(), key_str, &value); | ||
return status.ok(); | ||
} | ||
|
||
|
||
void put(KEY_TYPE key, VALUE_TYPE value) override { | ||
std::string key_str = to_string(key); | ||
std::string value_str = to_string(value); | ||
leveldb::Status status = db_->Put(leveldb::WriteOptions(), key_str, value_str); | ||
if (!status.ok()) { | ||
std::cerr << "LevelDB put error: " << status.ToString() << std::endl; | ||
} | ||
} | ||
|
||
|
||
void end_routine() override { | ||
delete db_; | ||
} | ||
|
||
private: | ||
template <typename T> | ||
std::string to_string(const T& t) { | ||
std::ostringstream oss; | ||
oss << t; | ||
return oss.str(); | ||
} | ||
|
||
|
||
std::string to_string(const std::string& s) { | ||
return s; | ||
} | ||
}; | ||
|
||
} // namespace bliss | ||
|
||
#endif // BLISS_BENCH_LEVELDB |
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,40 @@ | ||
#include "bliss_index_tests.h" | ||
|
||
class LevelDBTest : public BlissIndexTest {}; | ||
|
||
TEST_F(LevelDBTest, TestLevelDB_Sanity) { | ||
index.reset(new bliss::BlissLevelDBIndex<key_type, key_type>()); | ||
std::vector<key_type> data; | ||
int key = 100; | ||
int value = 123; | ||
index->put(key, value); | ||
EXPECT_TRUE(index->get(key)); | ||
} | ||
|
||
TEST_F(LevelDBTest, TestLevelDB_Sorted) { | ||
index.reset(new bliss::BlissLevelDBIndex<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(LevelDBTest, TestLevelDB_Random) { | ||
index.reset(new bliss::BlissLevelDBIndex<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)); | ||
} | ||
} |