本文整理汇总了C++中ndbdictionary::Dictionary类的典型用法代码示例。如果您正苦于以下问题:C++ Dictionary类的具体用法?C++ Dictionary怎么用?C++ Dictionary使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Dictionary类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: tmp
bool
BackupRestore::createSystable(const TableS & tables){
if (!m_restore && !m_restore_meta && !m_restore_epoch)
return true;
const char *tablename = tables.getTableName();
if( strcmp(tablename, NDB_REP_DB "/def/" NDB_APPLY_TABLE) != 0 &&
strcmp(tablename, NDB_REP_DB "/def/" NDB_SCHEMA_TABLE) != 0 )
{
return true;
}
BaseString tmp(tablename);
Vector<BaseString> split;
if(tmp.split(split, "/") != 3){
err << "Invalid table name format " << tablename << endl;
return false;
}
m_ndb->setDatabaseName(split[0].c_str());
m_ndb->setSchemaName(split[1].c_str());
NdbDictionary::Dictionary* dict = m_ndb->getDictionary();
if( dict->getTable(split[2].c_str()) != NULL ){
return true;
}
return table(tables);
}
示例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
int
runCreateIndexT1(NDBT_Context* ctx, NDBT_Step* step)
{
Ndb* pNdb = GETNDB(step);
NdbDictionary::Dictionary* pDict = pNdb->getDictionary();
const NdbDictionary::Table* pTab = pDict->getTable("T1");
if (pTab == 0)
{
g_err << "getTable(T1) error: " << pDict->getNdbError() << endl;
return NDBT_FAILED;
}
NdbDictionary::Index ind;
ind.setName("T1X1");
ind.setTable("T1");
ind.setType(NdbDictionary::Index::OrderedIndex);
ind.setLogging(false);
ind.addColumn("KOL2");
ind.addColumn("KOL3");
ind.addColumn("KOL4");
if (pDict->createIndex(ind, *pTab) != 0)
{
g_err << "createIndex(T1X1) error: " << pDict->getNdbError() << endl;
return NDBT_FAILED;
}
return NDBT_OK;
}
示例4: ndb
static int
runCheckTableExists(NDBT_Context* ctx, NDBT_Step* step)
{
Ndb ndb(&ctx->m_cluster_connection, "TEST_DB");
ndb.init(1);
NdbDictionary::Dictionary* pDict = ndb.getDictionary();
const NdbDictionary::Table* pTab = ctx->getTab();
const char *tab_name= pTab->getName();
const NdbDictionary::Table* pDictTab = pDict->getTable(tab_name);
if (pDictTab == NULL)
{
g_err << "runCheckTableExists : Failed to find table "
<< tab_name << endl;
g_err << "Required schema : " << *((NDBT_Table*)pTab) << endl;
return NDBT_FAILED;
}
/* Todo : better check that table in DB is same as
* table we expect
*/
// Update ctx with a pointer to dict table
ctx->setTab(pDictTab);
ctx->setProperty("$table", tab_name);
return NDBT_OK;
}
示例5: createListenerEvent
void TableTailer::createListenerEvent() {
NdbDictionary::Dictionary *myDict = mNdbConnection->getDictionary();
if (!myDict) LOG_NDB_API_ERROR(mNdbConnection->getNdbError());
const NdbDictionary::Table *table = myDict->getTable(mTable.mTableName.c_str());
if (!table) LOG_NDB_API_ERROR(myDict->getNdbError());
NdbDictionary::Event myEvent(mEventName.c_str(), *table);
for(int i=0; i< mTable.mNoEvents; i++){
myEvent.addTableEvent(mTable.mWatchEvents[i]);
}
const char* columns[mTable.mNoColumns];
for(int i=0; i< mTable.mNoColumns; i++){
columns[i] = mTable.mColumnNames[i].c_str();
}
myEvent.addEventColumns(mTable.mNoColumns, columns);
//myEvent.mergeEvents(merge_events);
// Add event to database
if (myDict->createEvent(myEvent) == 0)
myEvent.print();
else if (myDict->getNdbError().classification ==
NdbError::SchemaObjectExists) {
LOG_ERROR("Event creation failed, event exists, dropping Event...");
if (myDict->dropEvent(mEventName.c_str())) LOG_NDB_API_ERROR(myDict->getNdbError());
// try again
// Add event to database
if (myDict->createEvent(myEvent)) LOG_NDB_API_ERROR(myDict->getNdbError());
} else
LOG_NDB_API_ERROR(myDict->getNdbError());
}
示例6: 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;
}
示例7: x
int
create_table(){
NdbDictionary::Dictionary* dict = g_ndb->getDictionary();
assert(dict);
if(g_paramters[P_CREATE].value){
g_ndb->getDictionary()->dropTable(g_tablename);
const NdbDictionary::Table * pTab = NDBT_Tables::getTable(g_tablename);
assert(pTab);
NdbDictionary::Table copy = * pTab;
copy.setLogging(false);
if(dict->createTable(copy) != 0){
g_err << "Failed to create table: " << g_tablename << endl;
return -1;
}
NdbDictionary::Index x(g_indexname);
x.setTable(g_tablename);
x.setType(NdbDictionary::Index::OrderedIndex);
x.setLogging(false);
for (unsigned k = 0; k < copy.getNoOfColumns(); k++){
if(copy.getColumn(k)->getPrimaryKey()){
x.addColumnName(copy.getColumn(k)->getName());
}
}
if(dict->createIndex(x) != 0){
g_err << "Failed to create index: " << endl;
return -1;
}
}
g_table = dict->getTable(g_tablename);
g_index = dict->getIndex(g_indexname, g_tablename);
assert(g_table);
assert(g_index);
if(g_paramters[P_CREATE].value)
{
int rows = g_paramters[P_ROWS].value;
HugoTransactions hugoTrans(* g_table);
if (hugoTrans.loadTable(g_ndb, rows)){
g_err.println("Failed to load %s with %d rows",
g_table->getName(), rows);
return -1;
}
}
return 0;
}
示例8:
bool
BackupRestore::table(const TableS & table){
if (!m_restore_meta)
{
return true;
}
NdbDictionary::Dictionary* dict = m_ndb->getDictionary();
if (dict->createTable(*table.m_dictTable) == -1)
{
err << "Create table " << table.getTableName() << " failed: "
<< dict->getNdbError() << endl;
return false;
}
info << "Successfully restored table " << table.getTableName()<< endl ;
return true;
}
示例9: run
void GetTableCall::run() {
DEBUG_PRINT("GetTableCall::run() [%s.%s]", arg1, arg2);
NdbDictionary::Dictionary * dict;
return_val = -1;
if(strlen(arg1)) {
arg0->ndb->setDatabaseName(arg1);
}
dict = arg0->ndb->getDictionary();
ndb_table = dict->getTable(arg2);
if(ndb_table) {
return_val = dict->listIndexes(idx_list, arg2);
}
if(return_val == 0) {
/* Fetch the indexes now. These calls may perform network IO, populating
the (connection) global and (Ndb) local dictionary caches. Later,
in the JavaScript main thread, we will call getIndex() again knowing
that the caches are populated.
*/
for(unsigned int i = 0 ; i < idx_list.count ; i++) {
const NdbDictionary::Index * idx = dict->getIndex(idx_list.elements[i].name, arg2);
/* It is possible to get an index for a recently dropped table rather
than the desired table. This is a known bug likely to be fixed later.
*/
if(ndb_table->getObjectVersion() !=
dict->getTable(idx->getTable())->getObjectVersion())
{
dict->invalidateIndex(idx);
idx = dict->getIndex(idx_list.elements[i].name, arg2);
}
}
}
}
示例10: 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;
}
示例11: drop_all_tables
static int drop_all_tables()
{
NdbDictionary::Dictionary * dict = g_ndb->getDictionary();
require(dict);
BaseString db = g_ndb->getDatabaseName();
BaseString schema = g_ndb->getSchemaName();
NdbDictionary::Dictionary::List list;
if (dict->listObjects(list, NdbDictionary::Object::TypeUndefined) == -1){
g_err << "Failed to list tables: " << endl
<< dict->getNdbError() << endl;
return -1;
}
for (unsigned i = 0; i < list.count; i++) {
NdbDictionary::Dictionary::List::Element& elt = list.elements[i];
switch (elt.type) {
case NdbDictionary::Object::SystemTable:
case NdbDictionary::Object::UserTable:
g_ndb->setDatabaseName(elt.database);
g_ndb->setSchemaName(elt.schema);
if(dict->dropTable(elt.name) != 0){
g_err << "Failed to drop table: "
<< elt.database << "/" << elt.schema << "/" << elt.name <<endl;
g_err << dict->getNdbError() << endl;
return -1;
}
break;
case NdbDictionary::Object::UniqueHashIndex:
case NdbDictionary::Object::OrderedIndex:
case NdbDictionary::Object::HashIndexTrigger:
case NdbDictionary::Object::IndexTrigger:
case NdbDictionary::Object::SubscriptionTrigger:
case NdbDictionary::Object::ReadOnlyConstraint:
default:
break;
}
}
g_ndb->setDatabaseName(db.c_str());
g_ndb->setSchemaName(schema.c_str());
return 0;
}
示例12: sprintf
static
int
dropEvent(Ndb *pNdb, const NdbDictionary::Table &tab)
{
char eventName[1024];
sprintf(eventName,"%s_EVENT",tab.getName());
NdbDictionary::Dictionary *myDict = pNdb->getDictionary();
if (!myDict) {
g_err << "Dictionary not found "
<< pNdb->getNdbError().code << " "
<< pNdb->getNdbError().message << endl;
return NDBT_FAILED;
}
if (myDict->dropEvent(eventName)) {
g_err << "Failed to drop event: "
<< myDict->getNdbError().code << " : "
<< myDict->getNdbError().message << endl;
return NDBT_FAILED;
}
return NDBT_OK;
}
示例13: 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;
}
示例14: 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;
}
示例15: hugoTrans
int
stressNDB_rep1(NDBT_Context* ctx, NDBT_Step* step)
{
Ndb* ndb=GETNDB(step);
NdbDictionary::Dictionary* myDict = ndb->getDictionary();
const NdbDictionary::Table * table = myDict->getTable("rep1");
HugoTransactions hugoTrans(* table);
while(!ctx->isTestStopped())
{
if (hugoTrans.pkUpdateRecords(GETNDB(step), ctx->getNumRecords(), 1, 30)
== NDBT_FAILED)
{
g_err << "pkUpdate Failed!" << endl;
return NDBT_FAILED;
}
if (hugoTrans.scanUpdateRecords(GETNDB(step), ctx->getNumRecords(), 1, 30)
== NDBT_FAILED)
{
g_err << "scanUpdate Failed!" << endl;
return NDBT_FAILED;
}
}
return NDBT_OK;
}