mirror of
https://github.com/codership/wsrep-lib.git
synced 2025-07-28 20:02:00 +03:00
Configurable data payload size for dbsim.
This commit is contained in:
@ -34,10 +34,13 @@ db::client::client(db::server& server,
|
||||
, client_state_(mutex_, cond_, server_state_, client_service_, client_id, mode)
|
||||
, client_service_(*this)
|
||||
, se_trx_(server.storage_engine())
|
||||
, data_()
|
||||
, random_device_()
|
||||
, random_engine_(random_device_())
|
||||
, stats_()
|
||||
{ }
|
||||
{
|
||||
data_.resize(params.max_data_size);
|
||||
}
|
||||
|
||||
void db::client::start()
|
||||
{
|
||||
@ -119,18 +122,23 @@ void db::client::run_one_transaction()
|
||||
assert(transaction.active());
|
||||
assert(err == 0);
|
||||
std::uniform_int_distribution<size_t> uniform_dist(0, params_.n_rows);
|
||||
const size_t data(uniform_dist(random_engine_));
|
||||
std::ostringstream os;
|
||||
os << data;
|
||||
const size_t randkey(uniform_dist(random_engine_));
|
||||
::memcpy(data_.data(), &randkey,
|
||||
std::min(sizeof(randkey), data_.size()));
|
||||
wsrep::key key(wsrep::key::exclusive);
|
||||
key.append_key_part("dbms", 4);
|
||||
unsigned long long client_key(client_state_.id().get());
|
||||
key.append_key_part(&client_key, sizeof(client_key));
|
||||
key.append_key_part(&data, sizeof(data));
|
||||
key.append_key_part(&randkey, sizeof(randkey));
|
||||
err = client_state_.append_key(key);
|
||||
size_t bytes_to_append(data_.size());
|
||||
if (params_.random_data_size)
|
||||
{
|
||||
bytes_to_append = std::uniform_int_distribution<size_t>(
|
||||
1, data_.size())(random_engine_);
|
||||
}
|
||||
err = err || client_state_.append_data(
|
||||
wsrep::const_buffer(os.str().c_str(),
|
||||
os.str().size()));
|
||||
wsrep::const_buffer(data_.data(), bytes_to_append));
|
||||
return err;
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user