Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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: 1 addition & 1 deletion src/bliss/bench_alex.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ template <typename KEY_TYPE, typename VALUE_TYPE>
class BlissAlexIndex : public BlissIndex<KEY_TYPE, VALUE_TYPE> {
public:
alex::Alex<KEY_TYPE, VALUE_TYPE> _index;
BlissAlexIndex() : _index(){};
BlissAlexIndex() : _index() {};

void bulkload(
std::vector<std::pair<KEY_TYPE, VALUE_TYPE>> values) override {
Expand Down
8 changes: 7 additions & 1 deletion src/bliss/util/args.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ BlissConfig parse_args(int argc, char *argv[]) {
"file_type", "Input file type [binary | txt]",
cxxopts::value<std::string>()->default_value("txt"))(
"use_preload", "Use index defined preload",
cxxopts::value<bool>()->default_value("false"));
cxxopts::value<bool>()->default_value("false"))(
"range-query", "Range query factor",
cxxopts::value<double>()->default_value("0.0"))(
"selectivity", "Selectivity factor (percentage of domain)",
cxxopts::value<double>()->default_value("0.01"));

auto result = options.parse(argc, argv);
config = {
Expand All @@ -51,6 +55,8 @@ BlissConfig parse_args(int argc, char *argv[]) {
.index = result["index"].as<std::string>(),
.file_type = result["file_type"].as<std::string>(),
.use_preload = result["use_preload"].as<bool>(),
.range_query_factor = result["range-query"].as<double>(),
.selectivity_factor = result["selectivity"].as<double>(),
};
} catch (const std::exception &e) {
std::cerr << "Error: " << e.what() << std::endl;
Expand Down
5 changes: 5 additions & 0 deletions src/bliss/util/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ struct BlissConfig {
std::string index;
std::string file_type;
bool use_preload;
double range_query_factor = 0.0;
double selectivity_factor = 0.01;
};

void display_config(BlissConfig config) {
Expand All @@ -30,6 +32,9 @@ void display_config(BlissConfig config) {
spdlog::trace("Verbosity {}", config.verbosity);
spdlog::trace("Index: {}", config.index);
spdlog::trace("File type: {}", config.file_type);
spdlog::trace("Use Preload: {}", config.use_preload);
spdlog::trace("Range Query Factor: {}", config.range_query_factor);
spdlog::trace("Selectivity Factor: {}", config.selectivity_factor);
}
} // namespace config
} // namespace utils
Expand Down
21 changes: 21 additions & 0 deletions src/bliss/util/execute.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <iostream>
#include <random>
#include <vector>
#include <algorithm>

#include "bliss/bliss_index.h"

Expand Down Expand Up @@ -43,6 +44,26 @@ void execute_non_empty_reads(bliss::BlissIndex<key_type, value_type> &tree,
}
}

void execute_range_queries(bliss::BlissIndex<key_type, value_type> &tree,
const std::vector<key_type> &data, int num_queries,
double selectivity = 0.01, int seed = 0) {
spdlog::trace("Executing Range Queries");
std::mt19937 gen(seed);
std::uniform_int_distribution<size_t> key_dist(0, data.size() - 1);

key_type data_range = *std::max_element(data.begin(), data.end()) -
*std::min_element(data.begin(), data.end());
key_type avg_range_size = static_cast<key_type>(data_range * selectivity);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's use better variable names - call this selected_data_range or qualifying_data_range.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just updated!


for (int i = 0; i < num_queries; ++i) {
size_t start_idx = key_dist(gen);
key_type start_key = data.at(start_idx);
key_type end_key = start_key + avg_range_size;

tree.get(start_key, end_key);
}
}

} // namespace executor
} // namespace utils
} // namespace bliss
Expand Down
22 changes: 21 additions & 1 deletion src/bliss_bench.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,15 @@ std::vector<std::pair<key_type, value_type>> create_preload_vec(
return vec;
}

void display_bliss_config(const config::BlissConfig &config) {
spdlog::info("Preload Factor: {}", config.preload_factor);
spdlog::info("Write Factor: {}", config.write_factor);
spdlog::info("Read Factor: {}", config.read_factor);
spdlog::info("Mixed Read/Write Ratio: {}", config.mixed_read_write_ratio);
spdlog::info("Range Query Factor: {}", config.range_query_factor);
spdlog::info("Selectivity Factor: {}", config.selectivity_factor);
}

void workload_executor(bliss::BlissIndex<key_type, value_type> &tree,
std::vector<key_type> &data,
const config::BlissConfig &config, const int seed) {
Expand All @@ -90,6 +99,7 @@ void workload_executor(bliss::BlissIndex<key_type, value_type> &tree,
size_t num_writes = std::round(config.write_factor * data.size());
size_t num_mixed = num_inserts - (num_preload + num_writes);
size_t num_reads = std::round(config.read_factor * data.size());
size_t num_ranges = std::round(config.range_query_factor * data.size());

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if range_query_factor is intended to be used to determine the number of range queries we perform, we should use something like range_query_perc. Also, is it required for the number of range queries to be a factor of the data size?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought that factor would be the best to reflect the performance of a range query as the number of entry data in an index is not always the same.
Putting the num_ranges calculate as a factor would measure the relative performance. Please correct me if I'm wrong.

I also changed the variable name to range_query_perc!


// Timing for preloading index
spdlog::debug("Preloading {} items", num_preload);
Expand Down Expand Up @@ -143,6 +153,16 @@ void workload_executor(bliss::BlissIndex<key_type, value_type> &tree,
executor::execute_non_empty_reads(tree, data, num_reads, seed);
});
spdlog::info("Read Time (ns): {}", read_time);

// Timing for range queries with configured amount
if (num_ranges > 0) {
spdlog::debug("Executing {} range queries", num_ranges);
auto range_time = time_function([&]() {
executor::execute_range_queries(tree, data, num_ranges,
config.selectivity_factor);
});
spdlog::info("Range Query Time (ns): {}", range_time);
}
}

int main(int argc, char *argv[]) {
Expand All @@ -157,7 +177,7 @@ int main(int argc, char *argv[]) {
default:
spdlog::set_level(spdlog::level::info);
}
display_config(config);
display_bliss_config(config);

std::vector<key_type> data;
if (config.file_type == "binary") {
Expand Down
21 changes: 21 additions & 0 deletions tests/test_alex/alex_tests.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,27 @@
#include "bliss_index_tests.h"

class AlexTest : public BlissIndexTest {};

TEST_F(AlexTest, TestAlex_RangeQuery) {
index.reset(new bliss::BlissAlexIndex<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);

key_type start_key = data.front();
key_type end_key = start_key + (data.back() - data.front()) / 4;

try {
index->get(start_key, end_key);
SUCCEED();
} catch (const std::runtime_error& e) {
EXPECT_STREQ("Not implemented", e.what());
}
}

TEST_F(AlexTest, TestAlex_Sorted) {
index.reset(new bliss::BlissAlexIndex<key_type, key_type>());
std::vector<key_type> data;
Expand Down
20 changes: 20 additions & 0 deletions tests/test_art/art_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,26 @@ TEST_F(ArtTest, TestArt_Sanity) {
EXPECT_TRUE(index->get(key));
}

TEST_F(ArtTest, TestArt_RangeQuery) {
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);

key_type start_key = data.front();
key_type end_key = start_key + (data.back() - data.front()) / 4;

try {
index->get(start_key, end_key);
SUCCEED();
} catch (const std::runtime_error& e) {
EXPECT_STREQ("Not implemented", e.what());
}
}

TEST_F(ArtTest, TestArt_Sorted) {
index.reset(new bliss::BlissARTIndex<key_type, key_type>());
std::vector<key_type> data;
Expand Down
20 changes: 20 additions & 0 deletions tests/test_btree/btree_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,26 @@ TEST_F(BTreeTest, TestBtree_Sanity) {
EXPECT_TRUE(index->get(key));
}

TEST_F(BTreeTest, TestBtree_RangeQuery) {
index.reset(new bliss::BlissBTreeIndex<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);

key_type start_key = data.front();
key_type end_key = start_key + (data.back() - data.front()) / 4;

try {
index->get(start_key, end_key);
SUCCEED();
} catch (const std::runtime_error& e) {
EXPECT_STREQ("Not implemented", e.what());
}
}

TEST_F(BTreeTest, TestBtree_Sorted) {
index.reset(new bliss::BlissBTreeIndex<key_type, key_type>());
std::vector<key_type> data;
Expand Down
20 changes: 20 additions & 0 deletions tests/test_imprints/imprint_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,26 @@

class ImprintsTest : public BlissIndexTest {};

TEST_F(ImprintsTest, TestImprint_RangeQuery) {
index.reset(new bliss::BlissImprintsIndex<size_t, key_type>(64, 64, std::string("unsigned long")));
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);

key_type start_key = data.front();
key_type end_key = start_key + (data.back() - data.front()) / 4;

try {
index->get(start_key, end_key);
SUCCEED();
} catch (const std::runtime_error& e) {
EXPECT_STREQ("Not implemented", e.what());
}
}

TEST_F(ImprintsTest, TestImprint_Random) {
index.reset(new bliss::BlissImprintsIndex<size_t, key_type>(64, 64, std::string("unsigned long")));
std::vector<key_type> data;
Expand Down
20 changes: 20 additions & 0 deletions tests/test_leveldb/leveldb_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,26 @@ TEST_F(LevelDBTest, TestLevelDB_Sanity) {
EXPECT_TRUE(index->get(key));
}

TEST_F(LevelDBTest, TestLevelDB_RangeQuery) {
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);

key_type start_key = data.front();
key_type end_key = start_key + (data.back() - data.front()) / 4;

try {
index->get(start_key, end_key);
SUCCEED();
} catch (const std::runtime_error& e) {
EXPECT_STREQ("Not implemented", e.what());
}
}

TEST_F(LevelDBTest, TestLevelDB_Sorted) {
index.reset(new bliss::BlissLevelDBIndex<key_type, key_type>());
std::vector<key_type> data;
Expand Down
20 changes: 20 additions & 0 deletions tests/test_lipp/lipp_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,26 @@

class LippTest : public BlissIndexTest {};

TEST_F(LippTest, TestLipp_RangeQuery) {
index.reset(new bliss::BlissLippIndex<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);

key_type start_key = data.front();
key_type end_key = start_key + (data.back() - data.front()) / 4;

try {
index->get(start_key, end_key);
SUCCEED();
} catch (const std::runtime_error& e) {
EXPECT_STREQ("Not implemented", e.what());
}
}

TEST_F(LippTest, TestLipp_Sorted) {
index.reset(new bliss::BlissLippIndex<key_type, key_type>());
std::vector<key_type> data;
Expand Down
20 changes: 20 additions & 0 deletions tests/test_pgm/pgm_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,26 @@ TEST_F(PGMTest, TestPGM_Sanity) {
EXPECT_TRUE(index->get(key));
}

TEST_F(PGMTest, TestPGM_RangeQuery) {
index.reset(new bliss::PGMIndex<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);

key_type start_key = data.front();
key_type end_key = start_key + (data.back() - data.front()) / 4;

try {
index->get(start_key, end_key);
SUCCEED();
} catch (const std::runtime_error& e) {
EXPECT_STREQ("Not implemented", e.what());
}
}

TEST_F(PGMTest, TestPGM_Sorted) {
index.reset(new bliss::PGMIndex<key_type, key_type>());
std::vector<key_type> data;
Expand Down
20 changes: 20 additions & 0 deletions tests/test_skiplist/skiplist_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,26 @@ TEST_F(SkipListTest, TestSkipList_Sanity) {
EXPECT_TRUE(index->get(key));
}

TEST_F(SkipListTest, TestSkipList_RangeQuery) {
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);

key_type start_key = data.front();
key_type end_key = start_key + (data.back() - data.front()) / 4;

try {
index->get(start_key, end_key);
SUCCEED();
} catch (const std::runtime_error& e) {
EXPECT_STREQ("Not implemented", e.what());
}
}

TEST_F(SkipListTest, TestSkipList_Sorted) {
index.reset(new bliss::BlissSkipListIndex<key_type, key_type>());
std::vector<key_type> data;
Expand Down