Skip to content

Commit

Permalink
adding ART
Browse files Browse the repository at this point in the history
  • Loading branch information
JslYoon committed Sep 23, 2024
1 parent 54e3b27 commit 1eb0c97
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 66 deletions.
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
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ add_library(bliss OBJECT
${CMAKE_SOURCE_DIR}/src/bliss/bliss_index.h
${CMAKE_SOURCE_DIR}/src/bliss/bench_lipp.h
${CMAKE_SOURCE_DIR}/src/bliss/bench_alex.h
${CMAKE_SOURCE_DIR}/src/bliss/bench_rax.h
${CMAKE_SOURCE_DIR}/src/bliss/bench_btree.h
${CMAKE_SOURCE_DIR}/src/bliss/bench_ART.h
)

target_compile_features(bliss PUBLIC
Expand All @@ -58,7 +58,7 @@ target_link_libraries(bliss PUBLIC
alex
lipp
tlx
rax
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
16 changes: 8 additions & 8 deletions external/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,17 @@ FetchContent_MakeAvailable(cxxopts)


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

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



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", "radix_tree"]
INDEXES = ["btree", "radix_tree", "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
1 change: 1 addition & 0 deletions script/infra/pybliss.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ def run_single_bliss_bench(self, args: BlissArgs) -> BlissStats:
f"--file_type {'binary' if args.file_type else 'txt'}",
"--use_preload" if args.use_preload else "",
]
print("this is cmd: " , " ".join(cmd))
process = subprocess.Popen(
" ".join(cmd),
stdout=subprocess.PIPE,
Expand Down
49 changes: 49 additions & 0 deletions src/bliss/bench_ART.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#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:
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[8];
ART::loadKey(key, ARTkey);

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

void put(KEY_TYPE key, VALUE_TYPE value) override {
uint8_t ARTkey[8];
ART::loadKey(key, ARTkey);
ART::insert(_index, &_index, ARTkey, 0, key, 8);
}

void end_routine() override {}
};

} // namespace bliss

#endif // !BLISS_BENCH_ART
47 changes: 0 additions & 47 deletions src/bliss/bench_rax.h

This file was deleted.

14 changes: 8 additions & 6 deletions src/bliss_bench.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include <alex.h>
#include <lipp.h>

#include "rax.h"
#include <ART.h>
#include <spdlog/common.h>

#include <cxxopts.hpp>
Expand All @@ -11,7 +10,8 @@
#include "bliss/bench_alex.h"
#include "bliss/bench_btree.h"
#include "bliss/bench_lipp.h"
#include "bliss/bench_rax.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 @@ -52,7 +52,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 | radix_tree]",
"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 @@ -255,20 +255,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 == "radix_tree") {
index.reset(new bliss::BlissRaxIndex<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

0 comments on commit 1eb0c97

Please sign in to comment.