本文整理汇总了C++中MojDbReq::autobatch方法的典型用法代码示例。如果您正苦于以下问题:C++ MojDbReq::autobatch方法的具体用法?C++ MojDbReq::autobatch怎么用?C++ MojDbReq::autobatch使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MojDbReq
的用法示例。
在下文中一共展示了MojDbReq::autobatch方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: purgeImpl
MojErr MojDb::purgeImpl(MojObject& obj, MojUInt32& countOut, MojDbReq& req)
{
MojLogTrace(s_log);
MojObject val;
MojErr err = obj.getRequired(RevNumKey, val);
MojErrCheck(err);
MojObject timestamp;
err = obj.getRequired(TimestampKey, timestamp);
MojErrCheck(err);
// purge all objects that were deleted on or prior to this rev num
// query for objects in two passes - once where backup is true and once where backup is false
MojDbQuery objQuery;
err = objQuery.from(MojDbKindEngine::RootKindId);
MojErrCheck(err);
err = objQuery.where(DelKey, MojDbQuery::OpEq, true);
MojErrCheck(err);
err = objQuery.where(SyncKey, MojDbQuery::OpEq, true);
MojErrCheck(err);
err = objQuery.where(RevKey, MojDbQuery::OpLessThanEq, val);
MojErrCheck(err);
MojUInt32 backupCount = 0;
req.autobatch(true);
req.fixmode(true);
objQuery.limit(AutoBatchSize);
err = delImpl(objQuery, backupCount, req, FlagPurge);
MojErrCheck(err);
MojDbQuery objQuery2;
err = objQuery2.from(MojDbKindEngine::RootKindId);
MojErrCheck(err);
err = objQuery2.where(DelKey, MojDbQuery::OpEq, true);
MojErrCheck(err);
err = objQuery2.where(SyncKey, MojDbQuery::OpEq, false);
MojErrCheck(err);
err = objQuery2.where(RevKey, MojDbQuery::OpLessThanEq, val);
MojErrCheck(err);
MojUInt32 count = 0;
MojUInt32 batchRemain = 0;
if (backupCount <= AutoBatchSize)
batchRemain = AutoBatchSize - backupCount;
req.autobatch(true); // enable auto batch
req.fixmode(true); // force deletion of bad entries
if (batchRemain > 0) {
objQuery2.limit(batchRemain);
err = delImpl(objQuery2, count, req, FlagPurge);
MojErrCheck(err);
}
countOut = count + backupCount;
req.autobatch(false);
// if we actually deleted objects, store this rev num as the last purge rev
if (countOut > 0) {
err = updateState(LastPurgedRevKey, val, req);
MojErrCheck(err);
}
// delete all the RevTimestamp entries prior to this one
MojDbQuery revTimestampQuery;
err = revTimestampQuery.from(MojDbKindEngine::RevTimestampId);
MojErrCheck(err);
err = revTimestampQuery.where(TimestampKey, MojDbQuery::OpLessThanEq, timestamp);
MojErrCheck(err);
count = 0;
err = delImpl(revTimestampQuery, count, req, FlagPurge);
MojErrCheck(err);
return MojErrNone;
}