MCPcopy Create free account
hub / github.com/4paradigm/OpenMLDB / BM_SimpleQueryFunction

Function BM_SimpleQueryFunction

src/sdk/mini_cluster_microbenchmark.cc:40–117  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

38::fedb::sdk::MiniCluster* mc;
39
40static void BM_SimpleQueryFunction(benchmark::State& state) { // NOLINT
41 ::fedb::nameserver::TableInfo table_info;
42 table_info.set_format_version(1);
43 std::string name = "test" + GenRand();
44 std::string db = "db" + GenRand();
45 auto ns_client = mc->GetNsClient();
46 std::string error;
47 bool ok = ns_client->CreateDatabase(db, error);
48 table_info.set_name(name);
49 table_info.set_db(db);
50 table_info.set_partition_num(1);
51 RtiDBSchema* schema = table_info.mutable_column_desc();
52 auto col1 = schema->Add();
53 col1->set_name("col1");
54 col1->set_data_type(::fedb::type::kVarchar);
55 auto col2 = schema->Add();
56 col2->set_name("col2");
57 col2->set_data_type(::fedb::type::kBigInt);
58 auto col3 = schema->Add();
59 col3->set_name("col3");
60 col3->set_data_type(::fedb::type::kBigInt);
61 auto col4 = schema->Add();
62 col4->set_name("col4");
63 col4->set_data_type(::fedb::type::kBigInt);
64 auto col5 = schema->Add();
65 col5->set_name("col5");
66 col5->set_data_type(::fedb::type::kBigInt);
67
68 RtiDBIndex* index = table_info.mutable_column_key();
69 auto key1 = index->Add();
70 key1->set_index_name("index0");
71 key1->add_col_name("col1");
72 key1->set_ts_name("col2");
73 ok = ns_client->CreateTable(table_info, error);
74
75 ::hybridse::vm::Schema fe_schema;
76 ::fedb::catalog::SchemaAdapter::ConvertSchema(table_info.column_desc(), &fe_schema);
77 ::hybridse::codec::RowBuilder rb(fe_schema);
78 std::string pk = "pk1";
79 uint64_t ts = 1589780888000l;
80 uint32_t size = rb.CalTotalLength(pk.size());
81 std::string value;
82 value.resize(size);
83 rb.SetBuffer(reinterpret_cast<int8_t*>(&(value[0])), size);
84 rb.AppendString(pk.c_str(), pk.size());
85 rb.AppendInt64(ts);
86 rb.AppendInt64(ts);
87 rb.AppendInt64(ts);
88 rb.AppendInt64(ts);
89 ::fedb::sdk::ClusterOptions option;
90 option.zk_cluster = mc->GetZkCluster();
91 option.zk_path = mc->GetZkPath();
92 ::fedb::sdk::ClusterSDK sdk(option);
93 sdk.Init();
94 std::vector<std::shared_ptr<::fedb::catalog::TabletAccessor>> tablet;
95 ok = sdk.GetTablet(db, name, &tablet);
96 if (!ok || tablet.size() <= 0) return;
97 uint32_t tid = sdk.GetTableId(db, name);

Callers

nothing calls this directly

Calls 15

NewClusterSQLRouterFunction · 0.85
CalTotalLengthMethod · 0.80
SetBufferMethod · 0.80
GetZkClusterMethod · 0.80
GetZkPathMethod · 0.80
GetTableIdMethod · 0.80
GetClientMethod · 0.80
GenRandFunction · 0.70
GetNsClientMethod · 0.45
CreateDatabaseMethod · 0.45
CreateTableMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected