Files
scylladb/tests/test_services.cc
Benny Halevy 223e1af521 sstables: provide large_data_handler to constructor
And use it for writing the sstable and/or when deleting it.

Refs #4198

Signed-off-by: Benny Halevy <bhalevy@scylladb.com>
2019-03-26 16:24:19 +02:00

72 lines
2.6 KiB
C++

/*
* Copyright (C) 2019 ScyllaDB
*/
/*
* This file is part of Scylla.
*
* Scylla is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Scylla is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Scylla. If not, see <http://www.gnu.org/licenses/>.
*/
#include "tests/test_services.hh"
#include "dht/i_partitioner.hh"
#include "dht/murmur3_partitioner.hh"
dht::token create_token_from_key(sstring key) {
sstables::key_view key_view = sstables::key_view(bytes_view(reinterpret_cast<const signed char*>(key.c_str()), key.size()));
dht::token token = dht::global_partitioner().get_token(key_view);
assert(token == dht::global_partitioner().get_token(key_view));
return token;
}
range<dht::token> create_token_range_from_keys(sstring start_key, sstring end_key) {
dht::token start = create_token_from_key(start_key);
assert(engine().cpu_id() == dht::global_partitioner().shard_of(start));
dht::token end = create_token_from_key(end_key);
assert(engine().cpu_id() == dht::global_partitioner().shard_of(end));
assert(end >= start);
return range<dht::token>::make(start, end);
}
static const sstring some_keyspace("ks");
static const sstring some_column_family("cf");
db::nop_large_data_handler nop_lp_handler;
thread_local sstables::sstables_manager test_sstables_manager(nop_lp_handler);
column_family::config column_family_test_config() {
column_family::config cfg;
cfg.sstables_manager = &test_sstables_manager;
return cfg;
}
column_family_for_tests::column_family_for_tests()
: column_family_for_tests(
schema_builder(some_keyspace, some_column_family)
.with_column(utf8_type->decompose("p1"), utf8_type, column_kind::partition_key)
.build()
)
{ }
column_family_for_tests::column_family_for_tests(schema_ptr s)
: _data(make_lw_shared<data>())
{
_data->s = s;
_data->cfg = column_family_test_config();
_data->cfg.enable_disk_writes = false;
_data->cfg.enable_commitlog = false;
_data->cf = make_lw_shared<column_family>(_data->s, _data->cfg, column_family::no_commitlog(), _data->cm, _data->cl_stats, _data->tracker);
_data->cf->mark_ready_for_writes();
}