Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Features] Integrating ART #29

Closed
wants to merge 12 commits into from
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -201,3 +201,5 @@ cmake-build-debug/
src/bliss/.idea/

db_working_home

.DS_Store
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ add_library(bliss OBJECT
${CMAKE_SOURCE_DIR}/src/bliss/bench_lipp.h
${CMAKE_SOURCE_DIR}/src/bliss/bench_alex.h
${CMAKE_SOURCE_DIR}/src/bliss/bench_btree.h
${CMAKE_SOURCE_DIR}/src/bliss/bench_art.h
)

target_compile_features(bliss PUBLIC
Expand All @@ -57,6 +58,7 @@ target_link_libraries(bliss PUBLIC
alex
lipp
tlx
art
)

target_include_directories(bliss PUBLIC
Expand Down
2 changes: 1 addition & 1 deletion data/example.data
Original file line number Diff line number Diff line change
Expand Up @@ -997,4 +997,4 @@
2991
2994
2997
3000
3000
23 changes: 20 additions & 3 deletions external/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,21 @@ FetchContent_MakeAvailable(cxxopts)



FetchContent_Declare(
art
GIT_REPOSITORY https://github.com/BU-DiSC/ART
GIT_TAG main
)
FetchContent_GetProperties(art)
if (NOT art_POPULATED)
FetchContent_Populate(art)
endif()

add_library(art INTERFACE)
target_include_directories(art INTERFACE ${art_SOURCE_DIR})



FetchContent_Declare(
alex
GIT_REPOSITORY https://github.com/microsoft/ALEX.git
Expand Down Expand Up @@ -59,10 +74,12 @@ endif()
add_library(lipp INTERFACE)
target_include_directories(lipp INTERFACE ${lipp_SOURCE_DIR}/src/core)


JslYoon marked this conversation as resolved.
Show resolved Hide resolved

FetchContent_Declare(
tlx
GIT_REPOSITORY https://github.com/tlx/tlx.git
GIT_TAG master
tlx
GIT_REPOSITORY https://github.com/tlx/tlx.git
GIT_TAG master
)
FetchContent_GetProperties(tlx)
if (NOT tlx_POPULATED)
Expand Down
3 changes: 1 addition & 2 deletions script/bench.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from infra.pybliss import BlissArgs, PyBliss
from infra.util import get_file_params

INDEXES = ["btree"]
INDEXES = ["btree", "art"]
PRELOAD_FACTOR = 0.4
WRITE_FACTOR = 0.4
READ_FACTOR = 0.2
Expand Down Expand Up @@ -77,7 +77,6 @@ def main(args):
)

args = parser.parse_args()

log_level = logging.WARNING
if args.verbose == 1:
log_level = logging.INFO
Expand Down
53 changes: 53 additions & 0 deletions src/bliss/bench_ART.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#ifndef BLISS_BENCH_ART
#define BLISS_BENCH_ART

#include "ART.h"

#include <vector>

#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:
static constexpr size_t KEY_SIZE = sizeof(KEY_TYPE);
ART::Node* _index;
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);

uint8_t depth = 0;
ART::Node* leaf = ART::lookup(_index, ARTkey, KEY_SIZE, depth, KEY_SIZE);
return ART::isLeaf(leaf) && ART::getLeafValue(leaf) == key;
}

void put(KEY_TYPE key, VALUE_TYPE value) override {
uint8_t ARTkey[KEY_SIZE];
ART::loadKey(key, ARTkey);

uint8_t depth = 0;
ART::insert(_index, &_index, ARTkey, depth, key, KEY_SIZE);
JslYoon marked this conversation as resolved.
Show resolved Hide resolved
}

void end_routine() override {}
};

} // namespace bliss

#endif // !BLISS_BENCH_ART
8 changes: 7 additions & 1 deletion src/bliss_bench.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <alex.h>
#include <lipp.h>
#include "ART.h"
#include <spdlog/common.h>

#include <cxxopts.hpp>
Expand All @@ -9,6 +10,7 @@
#include "bliss/bench_alex.h"
#include "bliss/bench_btree.h"
#include "bliss/bench_lipp.h"
#include "bliss/bench_art.h"
#include "bliss/bliss_index.h"
#include "bliss/util/reader.h"
#include "bliss/util/timer.h"
Expand Down Expand Up @@ -49,7 +51,7 @@ BlissConfig parse_args(int argc, char *argv[]) {
cxxopts::value<int>()->default_value("0"))(
"v,verbosity", "Verbosity [0: Info| 1: Debug | 2: Trace]",
cxxopts::value<int>()->default_value("0")->implicit_value("1"))(
"i,index", "Index type [alex | lipp | btree | bepstree | lsm]",
"i,index", "Index type [alex | lipp | btree | bepstree | lsm | art]",
cxxopts::value<std::string>()->default_value("btree"))(
"file_type", "Input file type [binary | txt]",
cxxopts::value<std::string>()->default_value("txt"))(
Expand Down Expand Up @@ -252,18 +254,22 @@ int main(int argc, char *argv[]) {
} else {
data = bliss::read_file<key_type>(config.data_file.c_str());
}

spdlog::debug("data.at(0) = {}", data.at(0));
spdlog::debug("data.at({}) = {}", data.size() - 1,
data.at(data.size() - 1));

std::unique_ptr<bliss::BlissIndex<key_type, value_type>> index;

// Call the respective function based on the index value
if (config.index == "alex") {
index.reset(new bliss::BlissAlexIndex<key_type, value_type>());
} else if (config.index == "lipp") {
index.reset(new bliss::BlissLippIndex<key_type, value_type>());
} else if (config.index == "btree") {
index.reset(new bliss::BlissBTreeIndex<key_type, value_type>());
} else if (config.index == "art") {
index.reset(new bliss::BlissARTIndex<key_type, value_type>());
} else {
spdlog::error("{} not implemented yet", config.index);
}
Expand Down