 |
SWC-DB
v0.5.12 C++ documentations
SWC-DB© (Super Wide Column Database) - High Performance Scalable Database (https://github.com/kashirin-alex/swc-db)
|
Go to the documentation of this file.
39 namespace LoadGenerator {
51 switch(typ.length()) {
101 switch(typ.length()) {
103 switch(*typ.data()) {
170 Property::Value::get_pointer<Property::Value_enum_g>(
175 "SWC-DB(load_generator) Usage: swcdb_load_generator [options]\n\nOptions:")
180 "Query applicable requests with Broker")
182 (
"gen-handlers",
i32(8),
"Number of client Handlers")
184 (
"gen-insert",
boo(
true),
"Generate new data")
185 (
"gen-select",
boo(
false),
"Select generated data")
186 (
"gen-delete",
boo(
false),
"Delete generated data")
188 (
"gen-select-empty",
boo(
false),
"Expect empty select results")
189 (
"gen-delete-column",
boo(
false),
"Delete Column after")
191 (
"gen-progress",
i32(100000),
192 "display progress every N cells or 0 for quiet")
193 (
"gen-cell-a-time",
boo(
false),
"Write one cell at a time")
195 (
"gen-cells",
i64(1000),
196 "number of cells, total=cells*versions*(is SINGLE?1:fractions*onLevel)")
197 (
"gen-cells-on-level",
i64(1),
198 "number of cells, on fraction level")
200 (
"gen-fractions",
i32(10),
201 "Number of Fractions per cell key")
202 (
"gen-fraction-size",
i32(10),
203 "fraction size in bytes at least")
205 (
"gen-distrib-seed",
i64(1),
206 "Use this seed/step for Distribution injection")
207 (
"gen-distrib-course",
213 "Fractions distrib Course STEP|R_STEP|SINGLE|R_SINGLE|LEVELS|R_LEVELS")
220 "Distribution SEQUENTIAL|STEPPING|UNIFORM")
222 (
"gen-value-size",
i32(256),
223 "cell value in bytes or counts for a col-counter")
225 (
"gen-col-name",
str(
"load_generator-"),
226 "Gen. load column name, joins with colm-number")
227 (
"gen-col-number",
i32(1),
228 "Number of columns to generate")
232 int(DB::Types::KeySeq::LEXIC),
237 "Schema col-seq FC_+|LEXIC|VOLUME")
241 int(DB::Types::Column::PLAIN),
246 "Schema col-type PLAIN|COUNTER_I{64,32,16,8}|SERIAL")
248 (
"gen-versions",
i32(1),
"number of cell versions to generate")
249 (
"gen-cell-versions",
i32(1),
"cell key schema-versions")
250 (
"gen-cell-encoding",
252 int(DB::Types::Encoder::PLAIN),
257 "Cell's Value encoding ZSTD|SNAPPY|ZLIB")
259 (
"gen-cs-count",
i8(0),
"Schema cs-count")
260 (
"gen-cs-size",
i32(0),
"Schema cs-size")
261 (
"gen-cs-replication",
i8(0),
"Schema cs-replication")
263 (
"gen-blk-size",
i32(0),
"Schema blk-size")
264 (
"gen-blk-cells",
i32(0),
"Schema blk-cells")
272 "Schema blk-encoding NONE|ZSTD|SNAPPY|ZLIB")
274 (
"gen-log-rollout",
i8(0),
275 "CommitLog rollout block ratio")
276 (
"gen-log-compact-cointervaling",
i8(0),
277 "CommitLog minimal cointervaling Fragments for compaction")
278 (
"gen-log-preload",
i8(0),
279 "Number of CommitLog Fragments to preload")
281 (
"gen-compaction-percent",
i8(0),
282 "Compaction threshold in % applied over size of either by cellstore or block")
292 namespace Utils {
namespace LoadGenerator {
386 std::uniform_int_distribution<size_t>
distrib;
415 "Not supported SINGLE|LEVELS Distribution Course with onlevel > 1");
425 "Not supported SEQUENTIAL Distribution with seed > 1");
436 "Not supported STEPPING Distribution with LEVELS");
442 "Not supported STEP Distribution Course with"
443 " onlevel > 1 and step > 1");
543 a_ncells, a_ncells_onlevel,
544 a_fraction_size, a_nfractions,
545 a_distribution, a_course, seed
582 a_ncells, a_ncells_onlevel,
583 a_fraction_size, a_nfractions,
584 a_distribution, a_course, seed) {
596 for(
auto& fraction : key) {
615 ? settings->get_i32(
"gen-versions")
618 uint32_t nfractions = settings->get_i32(
"gen-fractions");
619 uint32_t fraction_size = settings->get_i32(
"gen-fraction-size");
621 uint64_t ncells = settings->get_i64(
"gen-cells");
622 uint64_t ncells_onlevel = settings->get_i64(
"gen-cells-on-level");
624 Distrib distribution =
Distrib(settings->get_enum(
"gen-distrib"));
628 ? settings->get_i32(
"gen-value-size")
631 uint32_t progress = settings->get_i32(
"gen-progress");
632 bool cellatime = settings->get_bool(
"gen-cell-a-time");
635 "gen-cell-encoding"));
643 settings->get_bool(
"with-broker")
648 for(
auto& schema : schemas)
649 colms.
push_back(hdlr->create(schema).get());
651 size_t added_count = 0;
652 size_t resend_cells = 0;
653 size_t added_bytes = 0;
661 std::string value_data;
664 for(uint32_t n=0; n<value;++n)
665 value_data +=
char(c == 122 ? c = 97 : ++c);
671 for(uint32_t v=0; v<versions; ++v) {
672 for(uint32_t count=
is_counter ? value : 1; count > 0; --count) {
675 ncells, ncells_onlevel,
676 fraction_size, nfractions,
677 distribution, course, seed
679 while(key_gen.
next(cell.
key)) {
684 }
else if(is_serial) {
687 wfields.
ensure(value_data.size() * 10);
689 for(
auto it= value_data.cbegin(); it != value_data.cend(); ++it) {
691 wfields.
add(int64_t(*it));
694 long double v_d(*it);
698 const uint8_t c = *it;
704 if(cell_encoder == DB::Types::Encoder::PLAIN) {
710 }
else if(cell_encoder == DB::Types::Encoder::PLAIN) {
713 cell.
set_value(cell_encoder, value_data);
717 for(
auto& col : colms) {
726 hdlr->commit_or_wait();
730 if(progress && !(added_count % progress)) {
733 <<
" cells=" << added_count
734 <<
" bytes=" << added_bytes
735 <<
" avg=" << t_progress.
elapsed()/progress <<
"ns/cell) ";
736 hdlr->profile.finished();
742 resend_cells += hdlr->get_resend_count();
746 hdlr->commit_if_need();
749 resend_cells += hdlr->get_resend_count();
763 bool expect_empty = settings->get_bool(
"gen-select-empty");
765 uint32_t versions = settings->get_i32(
"gen-cell-versions");
766 uint32_t nfractions = settings->get_i32(
"gen-fractions");
767 uint32_t fraction_size = settings->get_i32(
"gen-fraction-size");
769 uint64_t ncells = settings->get_i64(
"gen-cells");
770 uint64_t ncells_onlevel = settings->get_i64(
"gen-cells-on-level");
772 Distrib distribution =
Distrib(settings->get_enum(
"gen-distrib"));
775 uint32_t progress = settings->get_i32(
"gen-progress");
776 bool cellatime = settings->get_bool(
"gen-cell-a-time");
777 bool with_broker = settings->get_bool(
"with-broker");
779 size_t select_count = 0;
780 size_t select_bytes = 0;
791 ncells, ncells_onlevel,
792 fraction_size, nfractions,
793 distribution, course, seed
797 while(key_gen.
next(key_spec)) {
806 nullptr,
false,
nullptr,
811 for(
auto& schema : schemas)
812 hdlr->scan(schema, std::move(intval));
818 for(
auto& schema : schemas)
819 SWC_ASSERT(hdlr->get_size(schema->cid) == versions);
822 select_bytes += hdlr->get_size_bytes();
825 profiling += hdlr->profile;
826 if(progress && !(select_count % progress)) {
829 <<
" cells=" << select_count
830 <<
" avg=" << t_progress.
elapsed()/progress <<
"ns/cell) ";
848 for(
auto& schema : schemas) {
853 [&select_bytes, &select_count, &schemas]
855 for(
auto& schema : schemas) {
857 _hdlr->get_cells(schema->cid, cells);
858 select_count += cells.size();
869 hdlr->scan(err, std::move(specs));
876 : select_count == versions * ncells * ncells_onlevel * schemas.size() * (
893 size_t seed = settings->get_i64(
"gen-distrib-seed");
895 if(settings->get_bool(
"gen-insert"))
898 if(settings->get_bool(
"gen-select"))
901 if(settings->get_bool(
"gen-delete"))
904 if(settings->get_bool(
"gen-delete-column")) {
907 auto func = Comm::Protocol::Mngr::Params::ColumnMng::Function::REMOVE;
908 for(
auto& schema : schemas) {
924 std::string col_name(settings->get_str(
"gen-col-name"));
926 uint32_t ncolumns(settings->get_i32(
"gen-col-number"));
934 if(schemas.
size() == ncolumns) {
941 for(uint32_t ncol=1; ncol<=ncolumns; ++ncol) {
945 settings->get_genum(
"gen-col-seq"));
947 settings->get_genum(
"gen-col-type"));
948 schema->cell_versions = settings->get_i32(
"gen-cell-versions");
949 schema->cell_ttl = 0;
951 settings->get_genum(
"gen-blk-encoding"));
952 schema->blk_size = settings->get_i32(
"gen-blk-size");
953 schema->blk_cells = settings->get_i32(
"gen-blk-cells");
954 schema->cs_replication = settings->get_i8(
"gen-cs-replication");
955 schema->cs_size = settings->get_i32(
"gen-cs-size");
956 schema->cs_max = settings->get_i8(
"gen-cs-count");
957 schema->log_rollout_ratio = settings->get_i8(
"gen-log-rollout");
958 schema->log_compact_cointervaling = settings->get_i8(
959 "gen-log-compact-cointervaling");
960 schema->log_fragment_preload = settings->get_i8(
"gen-log-preload");
962 schema->compact_percent = settings->get_i8(
"gen-compaction-percent");
965 auto func = Comm::Protocol::Mngr::Params::ColumnMng::Function::CREATE;
976 if(schemas.
size() != ncolumns)
987 int run(
int argc,
char** argv) {
994 settings->get_i32(
"gen-handlers")
998 (settings->get_bool(
"with-broker")
1013 auto period = settings->get<
1016 io->set_periodic_timer(
1028 std::this_thread::sleep_for(std::chrono::seconds(2));
1031 std::this_thread::sleep_for(std::chrono::seconds(1));
1037 return run(argc, argv);
void set_counter(uint8_t op, int64_t v, Types::Column typ=Types::Column::COUNTER_I64, int64_t rev=TIMESTAMP_NULL)
Property::Value_int32::Ptr i32(const int32_t &v)
constexpr SWC_CAN_INLINE reference front() noexcept
static SWC_CAN_INLINE Ptr make(const Clients::Ptr &clients, Cb_t &&cb=nullptr, bool rsp_partials=false, const Comm::IoContextPtr &io=nullptr, Clients::Flag executor=Clients::DEFAULT)
SWC_CAN_INLINE void set_value(uint8_t *v, uint32_t len, bool owner)
std::string repr_distrib(int typ)
std::shared_ptr< Common > Ptr
KeyIntervals key_intervals
static void reset() noexcept
Property::Value_enum_g::Ptr g_enum(const int32_t &v, Property::Value_enum_g::OnChg_t &&cb, Property::Value_enum_g::FromString_t &&from_string, Property::Value_enum_g::Repr_t &&repr)
SWC_CAN_INLINE void resize(size_type sz, ArgsT &&... args)
static SWC_CAN_INLINE void request(const Mngr::Params::ColumnMng ¶ms, const uint32_t timeout, DataArgsT &&... args)
static SWC_CAN_INLINE client::Clients::Ptr & get() noexcept
SWC_CAN_INLINE void clear() noexcept(_NoExceptDestructor)
SWC_CAN_INLINE int64_t now_ns() noexcept
Property::Value_uint8::Ptr i8(const uint8_t &v)
const char * get_text(const int err) noexcept
SWC_CAN_INLINE std::string repr_col_type(int typ)
Core::Vector< std::unique_ptr< FractionState > > _fractions_state
static SWC::Config::Settings::Ptr & settings()
void init_app_options(Settings *settings)
SWC_CAN_INLINE int from_string_range_seq(const std::string &typ) noexcept
#define SWC_THROW(_code_, _msg_)
virtual void set_value() override
SWC_CAN_INLINE void ensure(size_t len)
KeyGeneratorUpdate(size_t a_ncells, size_t a_ncells_onlevel, uint24_t a_fraction_size, uint24_t a_nfractions, Distrib a_distribution, DistribCourse a_course, size_t seed)
static SWC_SHOULD_NOT_INLINE void init(int argc, char **argv, SWC::Config::Settings::init_option_t init_app_options, SWC::Config::Settings::init_option_t init_post_cmd_args)
void update_data(const DB::SchemasVec &schemas, uint8_t flag, size_t seed)
SWC_CAN_INLINE int from_string_encoding(const std::string &typ) noexcept
ParserConfig cmdline_desc
Property::Value_bool::Ptr boo(const bool &v)
void display(std::ostream &out) const
virtual ~FractionStateDistStepping() noexcept
SWC_CAN_INLINE void add(Field *field)
void init_client_options(Settings *settings)
static void init(const client::Clients::Ptr &clients)
KeyGenerator(size_t a_ncells, size_t a_ncells_onlevel, uint24_t a_fraction_size, uint24_t a_nfractions, Distrib a_distribution, DistribCourse a_course, size_t seed)
SWC_CAN_INLINE uint64_t elapsed() const noexcept
SWC_CAN_INLINE void add(const std::string_view &fraction)
bool next(DB::Specs::Key &key)
FractionState(size_t a_value)
static SWC_CAN_INLINE Ptr make(const Clients::Ptr &clients, Cb_t &&cb=nullptr, const Comm::IoContextPtr &io=nullptr, Clients::Flag executor=Clients::DEFAULT)
void init_comm_options(Settings *settings)
int main(int argc, char **argv)
int run(int argc, char **argv)
std::string repr_distrib_course(int typ)
int from_string_distrib(const std::string &typ)
const Distrib distribution
const uint24_t nfractions
const size_t ncells_onlevel
std::string usage_str(const char *usage=nullptr)
The SWC-DB C++ namespace 'SWC'.
void print_cells_statistics(std::ostream &out, size_t cells_count, size_t resend_cells) const
const DistribCourse course
~KeyGeneratorUpdate() noexcept
void make_work_load(const DB::SchemasVec &schemas)
static SWC_CAN_INLINE Ptr make()
bool SWC_CONST_FUNC is_counter(const Column typ) noexcept
SWC_CAN_INLINE std::string repr_range_seq(int typ)
#define SWC_CAN_QUICK_EXIT(_CODE_)
FractionStateDistStepping(size_t a_ncells, size_t a_step, bool a_reverse)
ParserConfig &SWC_CONST_FUNC add_options()
Property::Value_string::Ptr str(std::string &&v)
SWC_CAN_INLINE void restart() noexcept
const uint24_t fraction_size
SWC_CAN_INLINE void finished() noexcept
constexpr SWC_CAN_INLINE void set_time_order_desc(bool desc) noexcept
virtual void reset() override
SWC_CAN_INLINE void free() noexcept
#define SWC_QUICK_EXIT(_CODE_)
Core::Encoder::Type Encoder
constexpr SWC_CAN_INLINE size_t fill() const noexcept
Ptr zero_token() noexcept
constexpr SWC_CAN_INLINE size_t encoded_length(bool no_value=false) const noexcept
KeyGeneratorSelect(size_t a_ncells, size_t a_ncells_onlevel, uint24_t a_fraction_size, uint24_t a_nfractions, Distrib a_distribution, DistribCourse a_course, size_t seed)
Property::Value_int64::Ptr i64(const int64_t &v)
static SWC_CAN_INLINE void request(const Params::ColumnMng ¶ms, const uint32_t timeout, DataArgsT &&... args)
virtual void set_value() override
static void reset() noexcept
static Ptr make(const Config::Settings &settings, const Comm::IoContextPtr &io_ctx, const ContextManager::Ptr &mngr_ctx, const ContextRanger::Ptr &rgr_ctx, const ContextBroker::Ptr &bkr_ctx)
int from_string_distrib_course(const std::string &typ)
SWC_CAN_INLINE std::string repr_encoding(int typ)
bool next(DB::Cell::Key &key)
constexpr SWC_CAN_INLINE void set_opt__key_equal() noexcept
void select_data(const DB::SchemasVec &schemas, size_t seed)
constexpr SWC_CAN_INLINE size_t size_bytes() const noexcept
SWC_CAN_INLINE void push_back(ArgsT &&... args)
FractionStateDistSeq(size_t a_ncells, bool a_reverse)
SWC_CAN_INLINE std::string to_string(const BitFieldInt< T, SZ > &v)
static IoContextPtr make(std::string &&_name, int32_t size)
Property::Value::Ptr get_default(const std::string &name)
constexpr SWC_CAN_INLINE size_type size() const noexcept
bool str_case_eq(const char *s1, const char *s2, size_t count) noexcept SWC_ATTRIBS((SWC_ATTRIB_O3))
SWC_CAN_INLINE reference emplace_back(ArgsT &&... args)
SWC_CAN_INLINE void move(Key &other) noexcept
Core::Vector< std::string > _fractions
virtual void set_value()=0
SWC_CAN_INLINE void reserve(size_type cap)
virtual ~FractionStateDistSeq() noexcept
SWC_CAN_INLINE int from_string_col_type(const std::string &typ) noexcept
~KeyGeneratorSelect() noexcept
ParserConfig & definition(const char *u)