mirror of
https://github.com/scylladb/scylladb.git
synced 2026-04-26 11:30:36 +00:00
Instead of lengthy blurbs, switch to single-line, machine-readable standardized (https://spdx.dev) license identifiers. The Linux kernel switched long ago, so there is strong precedent. Three cases are handled: AGPL-only, Apache-only, and dual licensed. For the latter case, I chose (AGPL-3.0-or-later and Apache-2.0), reasoning that our changes are extensive enough to apply our license. The changes we applied mechanically with a script, except to licenses/README.md. Closes #9937
84 lines
2.8 KiB
C++
84 lines
2.8 KiB
C++
/*
|
|
* Copyright (C) 2021-present ScyllaDB
|
|
*/
|
|
|
|
/*
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
*/
|
|
|
|
#include <seastar/core/app-template.hh>
|
|
#include <seastar/core/thread.hh>
|
|
#include <map>
|
|
#include <iostream>
|
|
#include <fmt/core.h>
|
|
#include "utils/logalloc.hh"
|
|
|
|
constexpr int TEST_NODE_SIZE = 7;
|
|
constexpr int TEST_LINEAR_THRESHOLD = 19;
|
|
|
|
#include "tree_test_key.hh"
|
|
#include "utils/intrusive_btree.hh"
|
|
#include "btree_validation.hh"
|
|
#include "collection_stress.hh"
|
|
|
|
using namespace intrusive_b;
|
|
using namespace seastar;
|
|
|
|
class test_key : public tree_test_key_base {
|
|
public:
|
|
member_hook _hook;
|
|
test_key(int nr) noexcept : tree_test_key_base(nr) {}
|
|
test_key(const test_key&) = delete;
|
|
test_key(test_key&& o) noexcept : tree_test_key_base(std::move(o)), _hook(std::move(o._hook)) {}
|
|
};
|
|
|
|
using test_tree = tree<test_key, &test_key::_hook, test_key_tri_compare, TEST_NODE_SIZE, TEST_LINEAR_THRESHOLD, key_search::both, with_debug::yes>;
|
|
using test_validator = validator<test_key, &test_key::_hook, test_key_tri_compare, TEST_NODE_SIZE, TEST_LINEAR_THRESHOLD>;
|
|
|
|
int main(int argc, char **argv) {
|
|
namespace bpo = boost::program_options;
|
|
app_template app;
|
|
app.add_options()
|
|
("count", bpo::value<int>()->default_value(10000), "number of keys to fill the tree with")
|
|
("iters", bpo::value<int>()->default_value(13), "number of iterations")
|
|
("verb", bpo::value<bool>()->default_value(false), "be verbose");
|
|
|
|
return app.run(argc, argv, [&app] {
|
|
auto count = app.configuration()["count"].as<int>();
|
|
auto rep = app.configuration()["iters"].as<int>();
|
|
auto verb = app.configuration()["verb"].as<bool>();
|
|
|
|
return seastar::async([count, rep, verb] {
|
|
stress_config cfg;
|
|
cfg.count = count;
|
|
cfg.iters = rep;
|
|
cfg.verb = verb;
|
|
|
|
tree_pointer<test_tree> t;
|
|
test_validator tv;
|
|
|
|
stress_compact_collection(cfg,
|
|
/* insert */ [&] (int key) {
|
|
auto k = alloc_strategy_unique_ptr<test_key>(current_allocator().construct<test_key>(key));
|
|
auto ti = t->insert(std::move(k), test_key_tri_compare{});
|
|
assert(ti.second);
|
|
},
|
|
/* erase */ [&] (int key) {
|
|
auto deleter = current_deleter<test_key>();
|
|
t->erase_and_dispose(test_key(key), test_key_tri_compare{}, deleter);
|
|
},
|
|
/* validate */ [&] {
|
|
if (verb) {
|
|
fmt::print("Validating:\n");
|
|
tv.print_tree(*t, '|');
|
|
}
|
|
tv.validate(*t);
|
|
},
|
|
/* clear */ [&] {
|
|
t->clear_and_dispose(current_deleter<test_key>());
|
|
}
|
|
);
|
|
});
|
|
});
|
|
}
|