本文整理汇总了C++中Ndb::getAutoIncrementValue方法的典型用法代码示例。如果您正苦于以下问题:C++ Ndb::getAutoIncrementValue方法的具体用法?C++ Ndb::getAutoIncrementValue怎么用?C++ Ndb::getAutoIncrementValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ndb
的用法示例。
在下文中一共展示了Ndb::getAutoIncrementValue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//.........这里部分代码省略.........
break;
}
else { // used
cursor += 1;
if (cursor >= MAXTRANS) {
cursor = 0;
}
}
}
if(current == -1) {
cerr << "WARNING: Number of transactions in parallel exceeds the maximum. retrying..." << endl;
usleep(1000);
continue;
} else {
break;
}
}
transaction[current].conn = ndb->startTransaction();
istringstream ss(row);
// NdbOperation *myOperation= myTransaction->getNdbOperation(myTable);
NdbOperation *myOperation= transaction[current].conn->getNdbOperation(myTable);
myOperation->insertTuple();
// If no primary key is assigned, have to set the tupleId explicitly
if (noKey) {
unsigned long long tupleId = 0;
// int
// Ndb::getAutoIncrementValue(const char* aTableName,
// Uint64 & autoValue, Uint32 cacheSize,
// Uint64 step, Uint64 start)
if (ndb->getAutoIncrementValue(myTable, tupleId, TUPLEID_FETCH_SIZE, 1, 1) != 0) {
cerr << "Error occurs while getting tupleID to insert.\n";
exit(-1);
}
myOperation->equal("$PK", tupleId);
//if (tupleId % 10000 == 0) {
// cerr <<"DEBUG: set tupleID to " << tupleId << endl;
//}
}
// Iterate for each field
int i = 0;
for (string field; getline(ss, field, field_delim); i++) {
// For NULL value, do not set value for this field
if (strcmp(field.c_str(), "\\N") == 0) {
continue;
}
if (strcmp(fieldType[i].c_str(), "int") == 0) {
// using a int64 to prevent problems..
long long value = atoll(field.c_str());
myOperation->setValue(fieldName[i].c_str(), value);
}
if (strcmp(fieldType[i].c_str(), "real") == 0) {
double value = atof(field.c_str());
myOperation->setValue(fieldName[i].c_str(), value);
}
if (strcmp(fieldType[i].c_str(), "varchar") == 0) {
char buffer[65535] = {};
make_ndb_varchar(buffer, field.c_str());