Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug fix on execute #46

Merged
merged 2 commits into from
Nov 13, 2024
Merged
Changes from all commits
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
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<size_t> 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