本文整理汇总了C++中Transaction::commit方法的典型用法代码示例。如果您正苦于以下问题:C++ Transaction::commit方法的具体用法?C++ Transaction::commit怎么用?C++ Transaction::commit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Transaction
的用法示例。
在下文中一共展示了Transaction::commit方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: putOne
bool JsonDbBtree::putOne(const QByteArray &key, const QByteArray &value)
{
bool inTransaction = mBtree->isWriting();
Transaction *txn = inTransaction ? mBtree->writeTransaction() : mBtree->beginWrite();
bool ok = txn->put(key, value);
if (!inTransaction) {
qWarning() << "JsonDbBtree::putOne" << "auto commiting tag 0";
ok &= txn->commit(0);
}
return ok;
}
示例2: dispose
// IToolLoop interface
void dispose() override
{
bool redraw = false;
if (!m_canceled) {
// Paint ink
if (getInk()->isPaint()) {
try {
ContextReader reader(m_context, 500);
ContextWriter writer(reader, 500);
m_expandCelCanvas.commit();
}
catch (const LockedDocumentException& ex) {
Console::showException(ex);
}
}
// Selection ink
else if (getInk()->isSelection()) {
m_document->generateMaskBoundaries();
redraw = true;
// Show selection edges
m_docPref.show.selectionEdges(true);
}
m_transaction.commit();
}
else
redraw = true;
// If the trace was canceled or it is not a 'paint' ink...
if (m_canceled || !getInk()->isPaint()) {
try {
ContextReader reader(m_context, 500);
ContextWriter writer(reader, 500);
m_expandCelCanvas.rollback();
}
catch (const LockedDocumentException& ex) {
Console::showException(ex);
}
}
if (redraw)
update_screen_for_document(m_document);
}
示例3: SaveToDatabase
void PackageGroup::SaveToDatabase(Transaction *transaction)
{
Database *database = Database::getInstance();
Transaction *ts = transaction;
auto_ptr<Transaction> local_ts;
if (!transaction) {
local_ts = auto_ptr<Transaction>(database->getTransaction("SavePackageGroup"));
ts = local_ts.get();
}
if (!mTapeSourcePackage->isPersistent())
database->savePackage(mTapeSourcePackage, ts);
size_t i;
for (i = 0; i < mFileSourcePackages.size(); i++)
database->savePackage(mFileSourcePackages[i], ts);
database->savePackage(mMaterialPackage, ts);
if (!transaction)
ts->commit();
}
示例4: blockOrder
//this command lets you select an a block reference (no xrefs supported yet, but I hope to add
//that by FCS) and then an (first level) object within the block reference.
//Then you can decide if you want to move the object to the top or to the bottom in the
//draworder.
//Note that this command uses the AcDbFilter and AcDbIndex classes. This mechanism is
//NOT the same that DRAWORDER command uses in model space and layout.
void blockOrder()
{
resbuf* res = NULL;
try
{
Transaction trans;
int rt;
ads_name ename;
ads_point pt;
if ((rt=acedEntSel("Select a reference:",ename,pt))==RTCAN)
return;
if (rt!=RTNORM)
throw Acad::eInvalidInput;
Ptr<AcDbBlockReference> pBlkRef(ename,AcDb::kForWrite);
//get block table record
Ptr<AcDbBlockTableRecord> pBTR(pBlkRef->blockTableRecord(),AcDb::kForWrite);
Acad::ErrorStatus es;
//get or add index
Ptr<AsdkBlockOrderIndex> pIndex;
es = AcDbIndexFilterManager::getIndex(pBTR,AsdkBlockOrderIndex::desc(),AcDb::kForWrite,(AcDbIndex*&)pIndex);
if (es==Acad::eKeyNotFound)
{
if ((pIndex=AsdkBlockOrderIndex::cast(
AsdkBlockOrderIndex::desc()->create()))==NULL)
throw Acad::eOutOfMemory;
ARXOK(AcDbIndexFilterManager::addIndex(pBTR, pIndex));
} else if (es!=Acad::eOk)
throw es;
//get or add filter
Ptr<AsdkBlockOrderFilter> pFilter;
es = AcDbIndexFilterManager::getFilter(pBlkRef,AsdkBlockOrderFilter::desc(),AcDb::kForWrite,(AcDbFilter*&)pFilter);
if (es==Acad::eKeyNotFound)
{
if ((pFilter=AsdkBlockOrderFilter::cast(
AsdkBlockOrderFilter::desc()->create()))==NULL)
throw Acad::eOutOfMemory;
ARXOK(AcDbIndexFilterManager::addFilter(pBlkRef,pFilter));
} else if (es!=Acad::eOk)
throw es;
//prompt for object to be moved
ads_point xform[4];
resbuf *temp,*last,*lastButOne;
ads_name eobj;
do
{
if (res!=NULL)
acutRelRb(res);
res = NULL;temp = NULL;last = NULL; lastButOne=NULL;
if ((rt=acedNEntSel("\nSelect entity to order:",eobj,pt,xform,&res))==RTCAN)
return;
if (rt!=RTNORM)
throw Acad::eInvalidInput;
temp=res;
last=temp;
while (temp!=NULL && temp->rbnext!=NULL){
lastButOne=temp;
temp=temp->rbnext;
last = temp;
}
}
//prompt until we find an object within the original block reference
while (res==NULL || last==NULL || (last!=NULL && last->resval.rlname[0]!=ename[0]));
AcDbObjectId idObj;
//if the object selected is within a block reference (nested block)
//then just add the block reference (NOTE that eobj is the inner most object
//and we only sort objects within the this reference.)
if (lastButOne!=NULL)
ARXOK(acdbGetObjectId(idObj,lastButOne->resval.rlname));
else
ARXOK(acdbGetObjectId(idObj,eobj));
acutRelRb(res);
//find out where to move the object
if (acedInitGet(0,"TOP,T BOTTOM,B")!=RTNORM)
throw Acad::eInvalidInput;
char result[512];
if ((rt=acedGetKword("\nMove to [Top/Bottom]:",result))==RTCAN)
return;
if (rt!=RTNORM)
throw Acad::eInvalidInput;
if (stricmp(result,"TOP")==0)
pFilter->moveToTop(idObj);
else if (stricmp(result,"BOTTOM")==0)
pFilter->moveToBottom(idObj);
pIndex->setLastUpdatedAtU(pBTR->database()->tduupdate());
//make sure that the reference is redrawn
pBlkRef->assertWriteEnabled();
trans.commit();
}
catch (Acad::ErrorStatus es)
{
if (res!=NULL)
acutRelRb(res);
acutPrintf("\nError: es==%s",acadErrorStatusText(es));
}
//.........这里部分代码省略.........
示例5: main
int main(int argc, char* argv[])
{
bool debug = false;
char *inStr = argv[1];
long pkg_identifier;
long packages[100000];
// Delete packages from database
try
{
// Initialise
prodauto::Database::initialise("localhost", "prodautodb", "bamzooki", "bamzooki", 4, 12);
Database* db = Database::getInstance();
Transaction* transaction = (db->getTransaction("DeletePackages"));
// String to array
char *nextTok = strtok(inStr, ",");
int i=0;
while(nextTok != NULL){
packages[i] = atol(nextTok);
i++;
nextTok = strtok(NULL, ",");
}
int noPackages = i;
if(noPackages == 0){
printf("Error! No package IDs supplied.\n");
return 1;
}
for (i = 0; i < noPackages; i++){
try
{
pkg_identifier = packages[i];
if(debug){printf("Loading package: %li\n", pkg_identifier);}
Package* package = (db->loadPackage(pkg_identifier));
db->deletePackageChain(package, transaction);
transaction->commit();
if(debug){printf("Deleted package\n");}
}
catch (const prodauto::DBException & dbe)
{
printf("Error deleting packages\n");
return 1;
}
}
printf("Deleted %i material item(s)\n", noPackages);
return 0;
//TODO: Check for unreferenced isolated packages
}
catch (const prodauto::DBException & dbe)
{
printf("Error\n");
return 1;
}
}
示例6: selectionWriter
//.........这里部分代码省略.........
selectionWriter.write<int32_t>(0); // we are going to vary this
selectionWriter.write<uint16_t>(context.callsSumLocalWeek);
selectionWriter.write<uint16_t>(0x1u);
selectionWriter.set(0, 4);
selectionWriter.write<uint8_t>(crossbow::to_underlying(PredicateType::GREATER));
selectionWriter.write<uint8_t>(0x1u);
selectionWriter.set(0, 2);
selectionWriter.write<int32_t>(in.alpha);
selectionWriter.write<uint16_t>(context.durSumLocalWeek);
selectionWriter.write<uint16_t>(0x1u);
selectionWriter.set(0, 4);
selectionWriter.write<uint8_t>(crossbow::to_underlying(PredicateType::GREATER));
selectionWriter.write<uint8_t>(0x2u);
selectionWriter.set(0, 6);
selectionWriter.write<int64_t>(in.beta);
// sort aggregation attributes
std::array<std::tuple<id_t, AggregationType, FieldType, crossbow::string>, 3> aggregationAttributes = {{
std::make_tuple(context.callsSumLocalWeek, AggregationType::SUM, FieldType::BIGINT,
"sum_calls_sum_local_week"),
std::make_tuple(context.callsSumLocalWeek, AggregationType::CNT, FieldType::BIGINT,
"cnt_calls_sum_local_week"),
std::make_tuple(context.durSumLocalWeek, AggregationType::SUM, FieldType::BIGINT,
"dur_sum_local_week")
}};
Schema resultSchema(schema.type());
uint32_t aggregationLength = 4 * aggregationAttributes.size();
std::unique_ptr<char[]> aggregation(new char[aggregationLength]);
crossbow::buffer_writer aggregationWriter(aggregation.get(), aggregationLength);
for (auto &attribute : aggregationAttributes) {
aggregationWriter.write<uint16_t>(std::get<0>(attribute));
aggregationWriter.write<uint16_t>(crossbow::to_underlying(std::get<1>(attribute)));
resultSchema.addField(std::get<2>(attribute), std::get<3>(attribute), true);
}
Table resultTable(context.wideTable.value, std::move(resultSchema));
auto &snapshot = tx.snapshot();
auto &clientHandle = tx.getHandle();
std::vector<std::shared_ptr<ScanIterator>> scanIterators;
uint16_t numberOfCities = region_unique_city.size();
scanIterators.reserve(numberOfCities);
for (int16_t i = 0; i < numberOfCities; ++i)
{
*varyPtr = i;
scanIterators.push_back(clientHandle.scan(resultTable, snapshot,
*context.scanMemoryMananger, ScanQueryType::AGGREGATION, selectionLength,
selection.get(), aggregationLength, aggregation.get()));
}
// process results from aggregations
for (int16_t i = 0; i < numberOfCities; ++i)
{
auto &scanIterator = scanIterators[i];
if (scanIterator->hasNext()) {
const char* tuple;
size_t tupleLength;
std::tie(std::ignore, tuple, tupleLength) = scanIterator->next();
auto sumCallsSumLocalWeek = resultTable.field<int64_t>(
"sum_calls_sum_local_week", tuple);
auto cntCallsSumLocalWeek = resultTable.field<int64_t>(
"cnt_calls_sum_local_week", tuple);
auto durSumLocalWeek = resultTable.field<int64_t>(
"dur_sum_local_week", tuple);
if (cntCallsSumLocalWeek > 0) {
Q4Out::Q4Tuple q4Tuple;
q4Tuple.city_name = region_unique_city[i];
q4Tuple.avg_num_local_calls_week =
static_cast<double>(sumCallsSumLocalWeek)
/ cntCallsSumLocalWeek;
q4Tuple.sum_duration_local_calls_week = durSumLocalWeek;
result.results.push_back(std::move(q4Tuple));
}
}
}
result.success = true;
tx.commit();
for (auto &scanIterator: scanIterators) {
if (scanIterator->error()) {
result.error = crossbow::to_string(scanIterator->error().value());
result.success = false;
return result;
}
}
} catch (std::exception& ex) {
result.success = false;
result.error = ex.what();
}
return result;
}