本文整理汇总了C++中Ndb::sendPollNdb方法的典型用法代码示例。如果您正苦于以下问题:C++ Ndb::sendPollNdb方法的具体用法?C++ Ndb::sendPollNdb怎么用?C++ Ndb::sendPollNdb使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ndb
的用法示例。
在下文中一共展示了Ndb::sendPollNdb方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//.........这里部分代码省略.........
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());
myOperation->setValue(fieldName[i].c_str(), buffer);
}
if (strcmp(fieldType[i].c_str(), "char") == 0) {
char buffer[65535] = {};
make_ndb_char(buffer, field.c_str());
myOperation->setValue(fieldName[i].c_str(), buffer);
// myOperation->setValue(fieldName[i].c_str(), field.c_str());
}
if (strcmp(fieldType[i].c_str(), "boolean") == 0) {
int value = atoi(field.c_str());
myOperation->setValue(fieldName[i].c_str(), value);
}
if (strcmp(fieldType[i].c_str(), "text") == 0) {
NdbBlob *myBlobHandle = myOperation->getBlobHandle(fieldName[i].c_str());
if (myBlobHandle == NULL) {
cerr << "Hint: in the TSV file any TEXT/BLOB attribute must come after the primary key column.\n";
APIERROR(myOperation->getNdbError());
}
myBlobHandle->setValue(field.c_str(), field.length());
// myBlobHandle->setNull();
}
}
transaction[current].conn->executeAsynchPrepare( NdbTransaction::Commit,
&callback,
cb
);
nPreparedTransactions++;
rowCounter++;
dataleft = true;
/**
* When we have prepared parallelism number of transactions ->
* send the transaction to ndb.
* Next time we will deal with the transactions are in the
* callback. There we will see which ones that were successful
* and which ones to retry.
*/
if (nPreparedTransactions >= tNoOfParallelTrans)
{
// send-poll all transactions
// close transaction is done in callback
ndb->sendPollNdb(3000, tNoOfParallelTrans );
nPreparedTransactions=0;
dataleft = false;
usleep(sleepTimeMilli);
}
// The SYNC way that can set multiple operations in one commit:
// if (myTransaction->execute( NdbTransaction::NoCommit ) == -1)
// APIERROR(myTransaction->getNdbError());
// if (rowCounter % TRANACTION_SIZE == 0) {
// // commit
// if (myTransaction->execute( NdbTransaction::Commit ) == -1)
// APIERROR(myTransaction->getNdbError());
// ndb->closeTransaction(myTransaction);
// myTransaction = ndb->startTransaction();
// dataleft = false;
// }
}
if (dataleft) {
ndb->sendPollNdb(3000, nPreparedTransactions );
nPreparedTransactions=0;
// SYNC way
// if (myTransaction->execute( NdbTransaction::Commit ) == -1)
// APIERROR(myTransaction->getNdbError());
// ndb->closeTransaction(myTransaction);
}
ndb->waitUntilReady(10000);
delete ndb;
disconnect_from_cluster(conn);
return EXIT_SUCCESS;
}