diff --git a/src/bliss/util/execute.h b/src/bliss/util/execute.h index 96fe823..dd50f70 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