本文整理汇总了C++中Ndb::getDictionary方法的典型用法代码示例。如果您正苦于以下问题:C++ Ndb::getDictionary方法的具体用法?C++ Ndb::getDictionary怎么用?C++ Ndb::getDictionary使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ndb
的用法示例。
在下文中一共展示了Ndb::getDictionary方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dropTable
int dropTable(NDBT_Context* ctx, NDBT_Step* step, Uint32 num)
{
Ndb* pNdb = GETNDB(step);
const NdbDictionary::Table* pTab= ctx->getTab();
/* Run as a 'T1' testcase - do nothing for other tables */
if (strcmp(pTab->getName(), "T1") != 0)
return NDBT_OK;
char tabnameBuff[10];
snprintf(tabnameBuff, sizeof(tabnameBuff), "TAB%u", num);
if (pNdb->getDictionary()->dropTable(tabnameBuff) != 0)
{
ndbout << "Drop table failed with error : "
<< pNdb->getDictionary()->getNdbError().code
<< " "
<< pNdb->getDictionary()->getNdbError().message
<< endl;
}
else
{
ndbout << "Dropped table " << tabnameBuff << endl;
}
return NDBT_OK;
}
示例2: createIndex
static void createIndex(Ndb &myNdb, bool includePrimary, unsigned int noOfIndexes)
{
Uint64 before, after;
NdbDictionary::Dictionary* dict = myNdb.getDictionary();
char indexName[] = "PNUMINDEX0000";
int res;
for(unsigned int indexNum = 0; indexNum < noOfIndexes; indexNum++) {
sprintf(indexName, "PNUMINDEX%.4u", indexNum);
NdbDictionary::Index index(indexName);
index.setTable("PERSON");
index.setType(NdbDictionary::Index::UniqueHashIndex);
if (includePrimary) {
const char* attr_arr[] = {"NAME", "PNUM1", "PNUM3"};
index.addIndexColumns(3, attr_arr);
}
else {
const char* attr_arr[] = {"PNUM1", "PNUM3"};
index.addIndexColumns(2, attr_arr);
}
before = NdbTick_CurrentMillisecond();
if ((res = dict->createIndex(index)) == -1) {
error_handler(dict->getNdbError());
}
after = NdbTick_CurrentMillisecond();
ndbout << "Created index " << indexName << ", " << after - before << " msec" << endl;
}
}
示例3: GETNDB
static
int
createDropEvent(NDBT_Context* ctx, NDBT_Step* step)
{
Ndb* pNdb = GETNDB(step);
NdbDictionary::Dictionary *myDict = pNdb->getDictionary();
if (ctx->getProperty("NoDDL", Uint32(0)) == 0)
{
for (unsigned i = 0; i<table_list.size(); i++)
{
int res = NDBT_OK;
const NdbDictionary::Table* tab = myDict->getTable(table_list[i].c_str());
if (tab == 0)
{
continue;
}
if ((res = createEvent(pNdb, *tab) != NDBT_OK))
{
return res;
}
if ((res = dropEvent(pNdb, *tab)) != NDBT_OK)
{
return res;
}
}
}
return NDBT_OK;
}
示例4: do_update
/*****************************************************************
* Update the second attribute in half of the tuples (adding 10) *
*****************************************************************/
static void do_update(Ndb &myNdb, const char* table)
{
const NdbDictionary::Dictionary* myDict= myNdb.getDictionary();
const NdbDictionary::Table *myTable= myDict->getTable(table);
if (myTable == NULL)
APIERROR(myDict->getNdbError());
for (int i = 0; i < 10; i+=2) {
NdbTransaction *myTransaction= myNdb.startTransaction();
if (myTransaction == NULL) APIERROR(myNdb.getNdbError());
NdbOperation *myOperation= myTransaction->getNdbOperation(myTable);
if (myOperation == NULL) APIERROR(myTransaction->getNdbError());
myOperation->updateTuple();
myOperation->equal( "ATTR1", i );
myOperation->setValue( "ATTR2", i+10);
if( myTransaction->execute( NdbTransaction::Commit ) == -1 )
APIERROR(myTransaction->getNdbError());
myNdb.closeTransaction(myTransaction);
}
}
示例5: do_insert
/**************************************************************************
* Using 5 transactions, insert 10 tuples in table: (0,0),(1,1),...,(9,9) *
**************************************************************************/
static void do_insert(Ndb &myNdb)
{
const NdbDictionary::Dictionary* myDict= myNdb.getDictionary();
const NdbDictionary::Table *myTable= myDict->getTable("MYTABLENAME");
if (myTable == NULL)
APIERROR(myDict->getNdbError());
for (int i = 0; i < 5; i++) {
NdbTransaction *myTransaction= myNdb.startTransaction();
if (myTransaction == NULL) APIERROR(myNdb.getNdbError());
NdbOperation *myOperation= myTransaction->getNdbOperation(myTable);
if (myOperation == NULL) APIERROR(myTransaction->getNdbError());
myOperation->insertTuple();
myOperation->equal("ATTR1", i);
myOperation->setValue("ATTR2", i);
myOperation= myTransaction->getNdbOperation(myTable);
if (myOperation == NULL) APIERROR(myTransaction->getNdbError());
myOperation->insertTuple();
myOperation->equal("ATTR1", i+5);
myOperation->setValue("ATTR2", i+5);
if (myTransaction->execute( NdbTransaction::Commit ) == -1)
APIERROR(myTransaction->getNdbError());
myNdb.closeTransaction(myTransaction);
}
}
示例6: dropIndex
static void dropIndex(Ndb &myNdb, unsigned int noOfIndexes)
{
for(unsigned int indexNum = 0; indexNum < noOfIndexes; indexNum++) {
char indexName[255];
sprintf(indexName, "PNUMINDEX%.4u", indexNum);
const Uint64 before = NdbTick_CurrentMillisecond();
const int retVal = myNdb.getDictionary()->dropIndex(indexName, "PERSON");
const Uint64 after = NdbTick_CurrentMillisecond();
if(retVal == 0){
ndbout << "Dropped index " << indexName << ", "
<< after - before << " msec" << endl;
} else {
ndbout << "Failed to drop index " << indexName << endl;
ndbout << myNdb.getDictionary()->getNdbError() << endl;
}
}
}
示例7: create100Tables
int create100Tables(NDBT_Context* ctx, NDBT_Step* step)
{
Ndb* pNdb = GETNDB(step);
const NdbDictionary::Table* pTab= ctx->getTab();
/* Run as a 'T1' testcase - do nothing for other tables */
if (strcmp(pTab->getName(), "T1") != 0)
return NDBT_OK;
for (Uint32 t=0; t < 100; t++)
{
char tabnameBuff[10];
snprintf(tabnameBuff, sizeof(tabnameBuff), "TAB%u", t);
NdbDictionary::Table tab;
tab.setName(tabnameBuff);
NdbDictionary::Column pk;
pk.setName("PK");
pk.setType(NdbDictionary::Column::Varchar);
pk.setLength(20);
pk.setNullable(false);
pk.setPrimaryKey(true);
tab.addColumn(pk);
pNdb->getDictionary()->dropTable(tab.getName());
if(pNdb->getDictionary()->createTable(tab) != 0)
{
ndbout << "Create table failed with error : "
<< pNdb->getDictionary()->getNdbError().code
<< " "
<< pNdb->getDictionary()->getNdbError().message
<< endl;
return NDBT_FAILED;
}
ndbout << "Created table " << tabnameBuff << endl;
}
return NDBT_OK;
}
示例8: runRestoreOne
int runRestoreOne(NDBT_Context* ctx, NDBT_Step* step){
NdbBackup backup(GETNDB(step)->getNodeId()+1);
unsigned backupId = ctx->getProperty("BackupId");
ndbout << "Restoring backup " << backupId << endl;
if (backup.restore(backupId) == -1){
return NDBT_FAILED;
}
Ndb* pNdb = GETNDB(step);
pNdb->getDictionary()->invalidateTable(tabname);
const NdbDictionary::Table* tab = pNdb->getDictionary()->getTable(tabname);
if (tab)
{
ctx->setTab(tab);
return NDBT_OK;
}
return NDBT_FAILED;
}
示例9: calc
int
runInterpretedUKLookup(NDBT_Context* ctx, NDBT_Step* step)
{
const NdbDictionary::Table * pTab = ctx->getTab();
Ndb* pNdb = GETNDB(step);
NdbDictionary::Dictionary * dict = pNdb->getDictionary();
const NdbDictionary::Index* pIdx= dict->getIndex(pkIdxName, pTab->getName());
CHK_RET_FAILED(pIdx != 0);
const NdbRecord * pRowRecord = pTab->getDefaultRecord();
CHK_RET_FAILED(pRowRecord != 0);
const NdbRecord * pIdxRecord = pIdx->getDefaultRecord();
CHK_RET_FAILED(pIdxRecord != 0);
const Uint32 len = NdbDictionary::getRecordRowLength(pRowRecord);
Uint8 * pRow = new Uint8[len];
bzero(pRow, len);
HugoCalculator calc(* pTab);
calc.equalForRow(pRow, pRowRecord, 0);
NdbTransaction* pTrans = pNdb->startTransaction();
CHK_RET_FAILED(pTrans != 0);
NdbInterpretedCode code;
code.interpret_exit_ok();
code.finalise();
NdbOperation::OperationOptions opts;
bzero(&opts, sizeof(opts));
opts.optionsPresent = NdbOperation::OperationOptions::OO_INTERPRETED;
opts.interpretedCode = &code;
const NdbOperation * pOp = pTrans->readTuple(pIdxRecord, (char*)pRow,
pRowRecord, (char*)pRow,
NdbOperation::LM_Read,
0,
&opts,
sizeof(opts));
CHK_RET_FAILED(pOp);
int res = pTrans->execute(Commit, AbortOnError);
CHK_RET_FAILED(res == 0);
delete [] pRow;
return NDBT_OK;
}
示例10: runDropTablesRestart
int runDropTablesRestart(NDBT_Context* ctx, NDBT_Step* step){
NdbRestarter restarter;
Ndb* pNdb = GETNDB(step);
const NdbDictionary::Table *tab = ctx->getTab();
pNdb->getDictionary()->dropTable(tab->getName());
if (restarter.restartAll(false) != 0)
return NDBT_FAILED;
if (restarter.waitClusterStarted() != 0)
return NDBT_FAILED;
return NDBT_OK;
}
示例11: getRecordForMapping
/* arg0: TableMetadata wrapping NdbDictionary::Table *
arg1: Ndb *
arg2: number of columns
arg3: array of NdbDictionary::Column *
*/
Handle<Value> getRecordForMapping(const Arguments &args) {
DEBUG_MARKER(UDEB_DEBUG);
HandleScope scope;
const NdbDictionary::Table *table =
unwrapPointer<const NdbDictionary::Table *>(args[0]->ToObject());
Ndb * ndb = unwrapPointer<Ndb *>(args[1]->ToObject());
unsigned int nColumns = args[2]->Int32Value();
Record * record = new Record(ndb->getDictionary(), nColumns);
for(unsigned int i = 0 ; i < nColumns ; i++) {
const NdbDictionary::Column * col =
unwrapPointer<const NdbDictionary::Column *>
(args[3]->ToObject()->Get(i)->ToObject());
record->addColumn(col);
}
record->completeTableRecord(table);
return scope.Close(Record_Wrapper(record));
}
示例12: trans
int
runLoadAll(NDBT_Context* ctx, NDBT_Step* step)
{
Ndb* pNdb = GETNDB(step);
NdbDictionary::Dictionary * pDict = pNdb->getDictionary();
int records = ctx->getNumRecords();
int result = NDBT_OK;
for (unsigned i = 0; i<table_list.size(); i++)
{
const NdbDictionary::Table* tab = pDict->getTable(table_list[i].c_str());
HugoTransactions trans(* tab);
trans.loadTable(pNdb, records);
trans.scanUpdateRecords(pNdb, records);
}
return result;
}
示例13: dropManyTables
int dropManyTables(NDBT_Context* ctx, NDBT_Step* step)
{
Ndb* pNdb = GETNDB(step);
Uint32 tableCount = ctx->getProperty("ManyTableCount", defaultManyTableCount);
char buf[100];
for (Uint32 tn = 0; tn < tableCount; tn++)
{
BaseString::snprintf(buf, sizeof(buf),
"%s_%u",
ctx->getTab()->getName(),
tn);
ndbout << "Dropping " << buf << endl;
pNdb->getDictionary()->dropTable(buf);
}
return NDBT_OK;
}
示例14: APIERROR
static int
prepare_master_or_slave(Ndb &myNdb,
const char* table,
const char* pk,
Uint32 pk_val,
const char* col,
struct Xxx &xxx,
struct XxxR &xxxr)
{
if (myNdb.init())
APIERROR(myNdb.getNdbError());
const NdbDictionary::Dictionary* myDict = myNdb.getDictionary();
const NdbDictionary::Table *myTable = myDict->getTable(table);
if (myTable == NULL)
APIERROR(myDict->getNdbError());
const NdbDictionary::Column *myPkCol = myTable->getColumn(pk);
if (myPkCol == NULL)
APIERROR(myDict->getNdbError());
if (myPkCol->getType() != NdbDictionary::Column::Unsigned)
{
PRINT_ERROR(0, "Primary key column not of type unsigned");
exit(-1);
}
const NdbDictionary::Column *myCol = myTable->getColumn(col);
if (myCol == NULL)
APIERROR(myDict->getNdbError());
if (myCol->getType() != NdbDictionary::Column::Unsigned)
{
PRINT_ERROR(0, "Update column not of type unsigned");
exit(-1);
}
xxx.ndb = &myNdb;
xxx.table = myTable;
xxx.pk_col = myPkCol->getColumnNo();
xxx.col = myCol->getColumnNo();
xxxr.pk_val = pk_val;
return 0;
}
示例15: GETNDB
static int
runDropIndex(NDBT_Context* ctx, NDBT_Step* step)
{
const NdbDictionary::Table* pTab = ctx->getTab();
Ndb* pNdb = GETNDB(step);
NdbDictionary::Dictionary* pDic = pNdb->getDictionary();
NdbDictionary::Dictionary::List list;
if (pDic->listIndexes(list, pTab->getName()) != 0) {
g_err << pTab->getName() << ": listIndexes failed" << endl;
ERR(pDic->getNdbError());
return NDBT_FAILED;
}
for (unsigned i = 0; i < list.count; i++) {
NDBT_Index* pInd = new NDBT_Index(list.elements[i].name);
pInd->setTable(pTab->getName());
g_info << "Drop index:" << endl << *pInd;
if (pInd->dropIndexInDb(pNdb) != 0) {
return NDBT_FAILED;
}
}
return NDBT_OK;
}