本文整理汇总了C++中ndbdictionary::Table::getName方法的典型用法代码示例。如果您正苦于以下问题:C++ Table::getName方法的具体用法?C++ Table::getName怎么用?C++ Table::getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ndbdictionary::Table
的用法示例。
在下文中一共展示了Table::getName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: hugoTrans
int
runDDL(NDBT_Context* ctx, NDBT_Step* step){
Ndb* pNdb= GETNDB(step);
NdbDictionary::Dictionary* pDict = pNdb->getDictionary();
const int tables = NDBT_Tables::getNumTables();
while(!ctx->isTestStopped())
{
const int tab_no = rand() % (tables);
NdbDictionary::Table tab = *NDBT_Tables::getTable(tab_no);
BaseString name= tab.getName();
name.appfmt("-%d", step->getStepNo());
tab.setName(name.c_str());
if(pDict->createTable(tab) == 0)
{
HugoTransactions hugoTrans(* pDict->getTable(name.c_str()));
if (hugoTrans.loadTable(pNdb, 10000) != 0){
return NDBT_FAILED;
}
while(pDict->dropTable(tab.getName()) != 0 &&
pDict->getNdbError().code != 4009)
g_err << pDict->getNdbError() << endl;
sleep(1);
}
}
return NDBT_OK;
}
示例2: doAsyncCallback
/* doAsyncCallback() runs in the main thread. We don't want it to block.
TODO: verify whether any IO is done
by checking WaitMetaRequestCount at the start and end.
*/
void GetTableCall::doAsyncCallback(Local<Object> ctx) {
HandleScope scope;
DEBUG_PRINT("GetTableCall::doAsyncCallback: return_val %d", return_val);
/* User callback arguments */
Handle<Value> cb_args[2];
cb_args[0] = Null();
cb_args[1] = Null();
/* TableMetadata = {
database : "" , // Database name
name : "" , // Table Name
columns : [] , // ordered array of DBColumn objects
indexes : [] , // array of DBIndex objects
partitionKey : [] , // ordered array of column numbers in the partition key
};
*/
if(ndb_table && ! return_val) {
Local<Object> table = NdbDictTableEnv.newWrapper();
wrapPointerInObject(ndb_table, NdbDictTableEnv, table);
// database
table->Set(String::NewSymbol("database"), String::New(arg1));
// name
table->Set(String::NewSymbol("name"), String::New(ndb_table->getName()));
// columns
Local<Array> columns = Array::New(ndb_table->getNoOfColumns());
for(int i = 0 ; i < ndb_table->getNoOfColumns() ; i++) {
Handle<Object> col = buildDBColumn(ndb_table->getColumn(i));
columns->Set(i, col);
}
table->Set(String::NewSymbol("columns"), columns);
// indexes (primary key & secondary)
Local<Array> js_indexes = Array::New(idx_list.count + 1);
js_indexes->Set(0, buildDBIndex_PK()); // primary key
for(unsigned int i = 0 ; i < idx_list.count ; i++) { // secondary indexes
const NdbDictionary::Index * idx =
arg0->dict->getIndex(idx_list.elements[i].name, arg2);
js_indexes->Set(i+1, buildDBIndex(idx));
}
table->Set(String::NewSymbol("indexes"), js_indexes, ReadOnly);
// partitionKey
// Table Record (implementation artifact; not part of spec)
DEBUG_PRINT("Creating Table Record");
Record * rec = new Record(arg0->dict, ndb_table->getNoOfColumns());
for(int i = 0 ; i < ndb_table->getNoOfColumns() ; i++) {
rec->addColumn(ndb_table->getColumn(i));
}
rec->completeTableRecord(ndb_table);
table->Set(String::NewSymbol("record"), Record_Wrapper(rec));
// User Callback
cb_args[1] = table;
}
else {
cb_args[0] = String::New(arg0->dict->getNdbError().message);
}
callback->Call(ctx, 2, cb_args);
}
示例3: doAsyncCallback
/* doAsyncCallback() runs in the main thread. We don't want it to block.
TODO: verify whether any IO is done
by checking WaitMetaRequestCount at the start and end.
*/
void GetTableCall::doAsyncCallback(Local<Object> ctx) {
const char *tableName;
HandleScope scope;
DEBUG_PRINT("GetTableCall::doAsyncCallback: return_val %d", return_val);
/* User callback arguments */
Handle<Value> cb_args[2];
cb_args[0] = Null();
cb_args[1] = Null();
/* TableMetadata = {
database : "" , // Database name
name : "" , // Table Name
columns : [] , // ordered array of DBColumn objects
indexes : [] , // array of DBIndex objects
partitionKey : [] , // ordered array of column numbers in the partition key
};
*/
if(ndb_table && ! return_val) {
Local<Object> table = NdbDictTableEnv.newWrapper();
const NdbDictionary::Table * js_ndb_table = ndb_table;
wrapPointerInObject(js_ndb_table, NdbDictTableEnv, table);
// database
table->Set(String::NewSymbol("database"), String::New(arg1));
// name
tableName = ndb_table->getName();
table->Set(String::NewSymbol("name"), String::New(tableName));
// partitionKey
int nPartitionKeys = 0;
Handle<Array> partitionKeys = Array::New();
table->Set(String::NewSymbol("partitionKey"), partitionKeys);
// columns
Local<Array> columns = Array::New(ndb_table->getNoOfColumns());
for(int i = 0 ; i < ndb_table->getNoOfColumns() ; i++) {
const NdbDictionary::Column *ndb_col = ndb_table->getColumn(i);
Handle<Object> col = buildDBColumn(ndb_col);
columns->Set(i, col);
if(ndb_col->getPartitionKey()) { /* partition key */
partitionKeys->Set(nPartitionKeys++, String::New(ndb_col->getName()));
}
}
table->Set(String::NewSymbol("columns"), columns);
// indexes (primary key & secondary)
Local<Array> js_indexes = Array::New(idx_list.count + 1);
js_indexes->Set(0, buildDBIndex_PK()); // primary key
for(unsigned int i = 0 ; i < idx_list.count ; i++) { // secondary indexes
const NdbDictionary::Index * idx =
dict->getIndex(idx_list.elements[i].name, arg2);
js_indexes->Set(i+1, buildDBIndex(idx));
}
table->Set(String::NewSymbol("indexes"), js_indexes, ReadOnly);
// Table Record (implementation artifact; not part of spec)
DEBUG_PRINT("Creating Table Record");
Record * rec = new Record(dict, ndb_table->getNoOfColumns());
for(int i = 0 ; i < ndb_table->getNoOfColumns() ; i++) {
rec->addColumn(ndb_table->getColumn(i));
}
rec->completeTableRecord(ndb_table);
table->Set(String::NewSymbol("record"), Record_Wrapper(rec));
// foreign keys (only foreign keys for which this table is the child)
// now create the javascript foreign key metadata objects for dictionary objects cached earlier
Local<Array> js_fks = Array::New(fk_count);
int fk_number = 0;
for(unsigned int i = 0 ; i < fk_list.count ; i++) {
NdbDictionary::ForeignKey fk;
if (fk_list.elements[i].type == NdbDictionary::Object::ForeignKey) {
const char * fk_name = fk_list.elements[i].name;
int fkGetCode = dict->getForeignKey(fk, fk_name);
DEBUG_PRINT("getForeignKey for %s returned %i", fk_name, fkGetCode);
// see if the foreign key child table is this table
if(splitNameMatchesDbAndTable(fk.getChildTable())) {
// the foreign key child table is this table; build the fk object
DEBUG_PRINT("Adding foreign key for %s at %i", fk.getName(), fk_number);
js_fks->Set(fk_number++, buildDBForeignKey(&fk));
}
}
}
table->Set(String::NewSymbol("foreignKeys"), js_fks, ReadOnly);
// Autoincrement Cache Impl (also not part of spec)
if(per_table_ndb) {
table->Set(String::NewSymbol("per_table_ndb"), Ndb_Wrapper(per_table_ndb));
}
// User Callback
cb_args[1] = table;
//.........这里部分代码省略.........
示例4: doAsyncCallback
/* doAsyncCallback() runs in the main thread. We don't want it to block.
TODO: verify whether any IO is done
by checking WaitMetaRequestCount at the start and end.
*/
void GetTableCall::doAsyncCallback(Local<Object> ctx) {
const char *ndbTableName;
EscapableHandleScope scope(isolate);
DEBUG_PRINT("GetTableCall::doAsyncCallback: return_val %d", return_val);
/* User callback arguments */
Handle<Value> cb_args[2];
cb_args[0] = Null(isolate);
cb_args[1] = Null(isolate);
/* TableMetadata = {
database : "" , // Database name
name : "" , // Table Name
columns : [] , // ordered array of DBColumn objects
indexes : [] , // array of DBIndex objects
partitionKey : [] , // ordered array of column numbers in the partition key
sparseContainer : null // default column for sparse fields
};
*/
if(ndb_table && ! return_val) {
Local<Object> table = NdbDictTableEnv.wrap(ndb_table)->ToObject();
// database
table->Set(SYMBOL(isolate, "database"), String::NewFromUtf8(isolate, arg1));
// name
ndbTableName = ndb_table->getName();
table->Set(SYMBOL(isolate, "name"), String::NewFromUtf8(isolate, ndbTableName));
// partitionKey
int nPartitionKeys = 0;
Handle<Array> partitionKeys = Array::New(isolate);
table->Set(SYMBOL(isolate, "partitionKey"), partitionKeys);
// sparseContainer
table->Set(SYMBOL(isolate,"sparseContainer"), Null(isolate));
// columns
Local<Array> columns = Array::New(isolate, ndb_table->getNoOfColumns());
for(int i = 0 ; i < ndb_table->getNoOfColumns() ; i++) {
const NdbDictionary::Column *ndb_col = ndb_table->getColumn(i);
Handle<Object> col = buildDBColumn(ndb_col);
columns->Set(i, col);
if(ndb_col->getPartitionKey()) { /* partition key */
partitionKeys->Set(nPartitionKeys++, String::NewFromUtf8(isolate, ndb_col->getName()));
}
if( ! strcmp(ndb_col->getName(), "SPARSE_FIELDS")
&& ( (! strncmp(getColumnType(ndb_col), "VARCHAR", 7)
&& (getEncoderCharsetForColumn(ndb_col)->isUnicode))
|| ( ! strncmp(getColumnType(ndb_col), "VARBINARY", 9)
|| ! strncmp(getColumnType(ndb_col), "JSON", 4))))
{
table->Set(SYMBOL(isolate,"sparseContainer"),
String::NewFromUtf8(isolate, ndb_col->getName()));
}
}
table->Set(SYMBOL(isolate, "columns"), columns);
// indexes (primary key & secondary)
Local<Array> js_indexes = Array::New(isolate, idx_list.count + 1);
js_indexes->Set(0, buildDBIndex_PK()); // primary key
for(unsigned int i = 0 ; i < idx_list.count ; i++) { // secondary indexes
const NdbDictionary::Index * idx =
dict->getIndex(idx_list.elements[i].name, arg2);
js_indexes->Set(i+1, buildDBIndex(idx));
}
SET_RO_PROPERTY(table, SYMBOL(isolate, "indexes"), js_indexes);
// foreign keys (only foreign keys for which this table is the child)
// now create the javascript foreign key metadata objects for dictionary objects cached earlier
Local<Array> js_fks = Array::New(isolate, fk_count);
int fk_number = 0;
for(unsigned int i = 0 ; i < fk_list.count ; i++) {
NdbDictionary::ForeignKey fk;
if (fk_list.elements[i].type == NdbDictionary::Object::ForeignKey) {
const char * fk_name = fk_list.elements[i].name;
int fkGetCode = dict->getForeignKey(fk, fk_name);
DEBUG_PRINT("getForeignKey for %s returned %i", fk_name, fkGetCode);
// see if the foreign key child table is this table
if(splitNameMatchesDbAndTable(fk.getChildTable())) {
// the foreign key child table is this table; build the fk object
DEBUG_PRINT("Adding foreign key for %s at %i", fk.getName(), fk_number);
js_fks->Set(fk_number++, buildDBForeignKey(&fk));
}
}
}
SET_RO_PROPERTY(table, SYMBOL(isolate, "foreignKeys"), js_fks);
// Autoincrement Cache Impl (also not part of spec)
if(per_table_ndb) {
table->Set(SYMBOL(isolate, "per_table_ndb"), Ndb_Wrapper(per_table_ndb));
}
// User Callback
cb_args[1] = table;
//.........这里部分代码省略.........