Skip to content

Commit

Permalink
bug fix on execute
Browse files Browse the repository at this point in the history
  • Loading branch information
JslYoon committed Oct 31, 2024
1 parent 6b1cf48 commit 854395d
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions src/bliss/util/execute.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#ifndef BLISS_EXECUTE_H
#define BLISS_EXECUTE_H

#include <iostream>
#include <random>
#include <vector>
#include <cmath>
#include <spdlog/spdlog.h>

#include "bliss/bliss_index.h"

Expand All @@ -12,33 +15,35 @@ typedef unsigned long value_type;
namespace bliss {
namespace utils {
namespace executor {

void execute_inserts(bliss::BlissIndex<key_type, value_type> &tree,
std::vector<key_type>::iterator &start,
std::vector<key_type>::iterator &end, int seed = 0) {
std::vector<key_type>::iterator start,
std::vector<key_type>::iterator end, int seed = 0) {
spdlog::trace("Executing Inserts");
std::mt19937 gen(seed);
std::uniform_int_distribution<value_type> dist(0, 1);
auto num_keys = std::distance(start, end);
std::uniform_int_distribution<value_type> 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<key_type, value_type> &tree,
std::vector<key_type> &data, int num_reads,
const std::vector<key_type> &data, int num_reads,
int seed = 0) {
spdlog::trace("Executing Non-Empty Reads");
std::mt19937 gen(seed);
std::uniform_int_distribution<int> dist(0, 1);
std::uniform_int_distribution<size_t> 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));
}
}

} // namespace executor
} // namespace utils
} // namespace bliss
#endif

#endif

0 comments on commit 854395d

Please sign in to comment.