From 854395d8c65d5bdce711efb391913f94d04c1886 Mon Sep 17 00:00:00 2001 From: Lucas Date: Thu, 31 Oct 2024 15:34:30 -0400 Subject: [PATCH 1/2] bug fix on execute --- src/bliss/util/execute.h | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/src/bliss/util/execute.h b/src/bliss/util/execute.h index 96fe823..08bad0e 100644 --- a/src/bliss/util/execute.h +++ b/src/bliss/util/execute.h @@ -1,8 +1,11 @@ #ifndef BLISS_EXECUTE_H #define BLISS_EXECUTE_H + #include #include #include +#include +#include #include "bliss/bliss_index.h" @@ -12,28 +15,29 @@ typedef unsigned long value_type; namespace bliss { namespace utils { namespace executor { + void execute_inserts(bliss::BlissIndex &tree, - std::vector::iterator &start, - std::vector::iterator &end, int seed = 0) { + std::vector::iterator start, + std::vector::iterator end, int seed = 0) { spdlog::trace("Executing Inserts"); std::mt19937 gen(seed); - std::uniform_int_distribution dist(0, 1); + auto num_keys = std::distance(start, end); + std::uniform_int_distribution dist(0, num_keys - 1); - auto num_keys = end - start; - for (auto &curr = start; curr != end; ++curr) { - tree.put(*curr, std::round(dist(gen) * num_keys)); + for (auto curr = start; curr != end; ++curr) { + tree.put(*curr, dist(gen)); } } void execute_non_empty_reads(bliss::BlissIndex &tree, - std::vector &data, int num_reads, + const std::vector &data, int num_reads, int seed = 0) { + spdlog::trace("Executing Non-Empty Reads"); std::mt19937 gen(seed); - std::uniform_int_distribution dist(0, 1); + std::uniform_int_distribution dist(0, data.size() - 1); - size_t key_idx; - for (auto blank = 0; blank < num_reads; blank++) { - key_idx = std::round(dist(gen) * (data.size() - 1)); + for (int i = 0; i < num_reads; ++i) { + size_t key_idx = dist(gen); tree.get(data.at(key_idx)); } } @@ -41,4 +45,5 @@ void execute_non_empty_reads(bliss::BlissIndex &tree, } // namespace executor } // namespace utils } // namespace bliss -#endif \ No newline at end of file + +#endif From 76f0b0e7d3c50b99ee9c52ed32af71a00f6f15cc Mon Sep 17 00:00:00 2001 From: Lucas Date: Thu, 31 Oct 2024 19:22:03 -0400 Subject: [PATCH 2/2] made value type to size_t --- src/bliss/util/execute.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bliss/util/execute.h b/src/bliss/util/execute.h index 08bad0e..dd50f70 100644 --- a/src/bliss/util/execute.h +++ b/src/bliss/util/execute.h @@ -22,7 +22,7 @@ void execute_inserts(bliss::BlissIndex &tree, spdlog::trace("Executing Inserts"); std::mt19937 gen(seed); auto num_keys = std::distance(start, end); - std::uniform_int_distribution dist(0, num_keys - 1); + std::uniform_int_distribution dist(0, num_keys - 1); for (auto curr = start; curr != end; ++curr) { tree.put(*curr, dist(gen));