MCPcopy Create free account
hub / github.com/baidu/tera / InitTable

Function InitTable

src/sample/global_txn_async_sample.cc:21–38  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19};
20
21tera::Table* InitTable(tera::Client* client, const std::string& tablename) {
22 tera::ErrorCode error_code;
23 if (!client->IsTableExist(tablename, &error_code)) {
24 tera::TableDescriptor schema(tablename);
25 schema.EnableTxn(); // 参与全局事务的表schema 都需要设置 txn=true
26 schema.AddLocalityGroup("lg0");
27 tera::ColumnFamilyDescriptor* cfd1 = schema.AddColumnFamily("cf1");
28 cfd1->EnableGlobalTransaction();
29 tera::ColumnFamilyDescriptor* cfd2 = schema.AddColumnFamily("cf2");
30 cfd2->DisableGlobalTransaction();
31 client->CreateTable(schema, &error_code);
32 assert(error_code.GetType() == tera::ErrorCode::kOK);
33 }
34
35 tera::Table* table = client->OpenTable(tablename, &error_code);
36 assert(table && error_code.GetType() == tera::ErrorCode::kOK);
37 return table;
38}
39
40void TxnCallBack(tera::Transaction* txn) {
41 if (txn->GetError().GetType() != tera::ErrorCode::kOK) {

Callers 1

mainFunction · 0.85

Calls 9

IsTableExistMethod · 0.45
EnableTxnMethod · 0.45
AddLocalityGroupMethod · 0.45
AddColumnFamilyMethod · 0.45
CreateTableMethod · 0.45
GetTypeMethod · 0.45
OpenTableMethod · 0.45

Tested by

no test coverage detected