本文整理汇总了C++中MojDb::put方法的典型用法代码示例。如果您正苦于以下问题:C++ MojDb::put方法的具体用法?C++ MojDb::put怎么用?C++ MojDb::put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MojDb
的用法示例。
在下文中一共展示了MojDb::put方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: run
MojErr MojDbSearchTest::run()
{
MojDb db;
MojErr err = db.open(MojDbTestDir);
MojTestErrCheck(err);
// add kind
MojObject kindObj;
err = kindObj.fromJson(MojSearchKindStr);
MojTestErrCheck(err);
err = db.putKind(kindObj);
MojTestErrCheck(err);
// put test objects
for (MojSize i = 0; i < sizeof(MojSearchTestObjects) / sizeof(MojChar*); ++i) {
MojObject obj;
err = obj.fromJson(MojSearchTestObjects[i]);
MojTestErrCheck(err);
err = db.put(obj);
MojTestErrCheck(err);
}
err = simpleTest(db);
MojTestErrCheck(err);
err = filterTest(db);
MojTestErrCheck(err);
// add kind for page test
err = kindObj.fromJson(MojSearchKindStr2);
MojTestErrCheck(err);
err = db.putKind(kindObj);
MojTestErrCheck(err);
// put test objects for page test
for (MojSize i = 0; i < sizeof(MojSearchTestObjects2) / sizeof(MojChar*); ++i) {
MojObject obj;
err = obj.fromJson(MojSearchTestObjects2[i]);
MojTestErrCheck(err);
err = db.put(obj);
MojTestErrCheck(err);
}
err = pageTest(db);
MojTestErrCheck(err);
err = db.close();
MojTestErrCheck(err);
return MojErrNone;
}
示例2: putLargeArrayObj
MojErr MojDbPerfCreateTest::putLargeArrayObj(MojDb& db, const MojChar* kindId, MojUInt64& lgArrayObjTime)
{
timespec startTime;
startTime.tv_nsec = 0;
startTime.tv_sec = 0;
timespec endTime;
endTime.tv_nsec = 0;
endTime.tv_sec = 0;
for (MojUInt64 i = 0; i < numInsert; i++) {
MojObject obj;
MojErr err = obj.putString(MojDb::KindKey, kindId);
MojTestErrCheck(err);
err = createLargeArrayObj(obj, i);
MojTestErrCheck(err);
clock_gettime(CLOCK_REALTIME, &startTime);
err = db.put(obj);
MojTestErrCheck(err);
clock_gettime(CLOCK_REALTIME, &endTime);
lgArrayObjTime += timeDiff(startTime, endTime);
totalTestTime += timeDiff(startTime, endTime);
}
return MojErrNone;
}
示例3: batchPutLargeArrayObj
MojErr MojDbPerfCreateTest::batchPutLargeArrayObj(MojDb& db, const MojChar* kindId, MojUInt64& lgArrayObjTime)
{
timespec startTime;
startTime.tv_nsec = 0;
startTime.tv_sec = 0;
timespec endTime;
endTime.tv_nsec = 0;
endTime.tv_sec = 0;
MojObject objArray;
for (MojUInt64 i = 0; i < numInsert; i++) {
MojObject obj;
MojErr err = obj.putString(MojDb::KindKey, kindId);
MojTestErrCheck(err);
err = createLargeArrayObj(obj, i);
MojTestErrCheck(err);
err = objArray.push(obj);
MojTestErrCheck(err);
}
MojObject::ArrayIterator begin;
MojErr err = objArray.arrayBegin(begin);
MojTestErrCheck(err);
MojObject::ConstArrayIterator end = objArray.arrayEnd();
clock_gettime(CLOCK_REALTIME, &startTime);
err = db.put(begin, end);
MojTestErrCheck(err);
clock_gettime(CLOCK_REALTIME, &endTime);
lgArrayObjTime += timeDiff(startTime, endTime);
totalTestTime += timeDiff(startTime, endTime);
return MojErrNone;
}
示例4: run
MojErr MojDbDistinctTest::run()
{
// TODO : description, youngseung.ji
MojDb db;
MojErr err = db.open(MojDbTestDir);
MojTestErrCheck(err);
// add kind
MojObject kindObj;
err = kindObj.fromJson(MojDistinctKindStr);
MojTestErrCheck(err);
err = db.putKind(kindObj);
MojTestErrCheck(err);
// put test objects
for (MojSize i = 0; i < sizeof(MojDistinctTestObjects) / sizeof(MojChar*); ++i) {
MojObject obj;
err = obj.fromJson(MojDistinctTestObjects[i]);
MojTestErrCheck(err);
err = db.put(obj);
MojTestErrCheck(err);
}
// Start testing
err = simpleTest(db);
MojTestErrCheck(err);
err = db.close();
MojTestErrCheck(err);
return MojErrNone;
}
示例5: batchPutLargeArrayObj
MojErr MojDbPerfCreateTest::batchPutLargeArrayObj(MojDb& db, const MojChar* kindId, MojTime& lgArrayObjTime)
{
MojTime startTime;
MojTime endTime;
MojObject objArray;
for (MojUInt64 i = 0; i < numInsert; i++) {
MojObject obj;
MojErr err = obj.putString(MojDb::KindKey, kindId);
MojTestErrCheck(err);
err = createLargeArrayObj(obj, i);
MojTestErrCheck(err);
err = objArray.push(obj);
MojTestErrCheck(err);
}
MojObject::ArrayIterator begin;
MojErr err = objArray.arrayBegin(begin);
MojTestErrCheck(err);
MojObject::ConstArrayIterator end = objArray.arrayEnd();
err = MojGetCurrentTime(startTime);
MojTestErrCheck(err);
err = db.put(begin, end);
MojTestErrCheck(err);
err = MojGetCurrentTime(endTime);
MojTestErrCheck(err);
lgArrayObjTime += (endTime - startTime);
totalTestTime += (endTime - startTime);
return MojErrNone;
}
示例6: put
MojErr MojDbQuotaTest::put(MojDb& db, const MojChar* objJson)
{
MojObject obj;
MojErr err = obj.fromJson(objJson);
MojTestErrCheck(err);
err = db.put(obj);
MojErrCheck(err);
return MojErrNone;
}
示例7: buildSample
void buildSample()
{
for (int i = 0; i < 100; ++i) {
MojObject obj;
MojAssertNoErr( obj.putString(MojDb::KindKey, _T("Test:1")) );
MojAssertNoErr( obj.put(_T("foo"), (i + 25) % 100) );
MojAssertNoErr( obj.put(_T("bar"), i % 3) );
MojExpectNoErr( db.put(obj) ) << "Failed to put record #" << i;
}
// db: x0 = (25, 0), (26, 1), (27, 2), (28, 0) .. x74 = (99,2), x75 = (0,0) .. x99 = (24,0)
}
示例8: createRevTimestamp
MojErr MojDbPurgeTest::createRevTimestamp(MojDb& db, MojObject& revNum, MojInt64 timestamp)
{
MojObject revTimeObj;
MojErr err = revTimeObj.put(_T("rev"), revNum);
MojTestErrCheck(err);
err = revTimeObj.put(_T("timestamp"), timestamp);
MojTestErrCheck(err);
err = revTimeObj.putString(MojDb::KindKey, MojDbKindEngine::RevTimestampId);
MojTestErrCheck(err);
err = db.put(revTimeObj);
MojTestErrCheck(err);
return MojErrNone;
}
示例9: batchPutObj
MojErr MojDbPerfUpdateTest::batchPutObj(MojDb& db, MojObject* begin, const MojObject* end, MojTime& objTime)
{
MojTime startTime;
MojTime endTime;
for (MojUInt64 i = 0; i < numBatchPutIterations; i++) {
MojErr err = MojGetCurrentTime(startTime);
MojTestErrCheck(err);
err = db.put(begin, end);
MojTestErrCheck(err);
err = MojGetCurrentTime(endTime);
MojTestErrCheck(err);
objTime += (endTime - startTime);
totalTestTime += (endTime - startTime);
}
return MojErrNone;
}
示例10: putObjs
MojErr MojDbPerfUpdateTest::putObjs(MojDb& db, const MojChar* kindId, MojUInt64 numInsert,
MojErr (MojDbPerfTest::*createFn) (MojObject&, MojUInt64), MojObject& objs)
{
for (MojUInt64 i = 0; i < numInsert; i++) {
MojObject obj;
MojErr err = obj.putString(MojDb::KindKey, kindId);
MojTestErrCheck(err);
err = (*this.*createFn)(obj, i);
MojTestErrCheck(err);
err = db.put(obj);
MojTestErrCheck(err);
err = objs.push(obj);
MojTestErrCheck(err);
}
return MojErrNone;
}
示例11: put
MojErr MojDbWatchTest::put(MojDb& db, const MojObject& fooVal, const MojObject& barVal, MojObject& idOut, MojInt64& revOut)
{
MojObject obj;
MojErr err = obj.putString(_T("_kind"), _T("WatchTest:1"));
MojTestErrCheck(err);
err = obj.put(_T("foo"), fooVal);
MojTestErrCheck(err);
err = obj.put(_T("bar"), barVal);
MojTestErrCheck(err);
err = db.put(obj);
MojTestErrCheck(err);
err = obj.getRequired(MojDb::IdKey, idOut);
MojTestErrCheck(err);
err = obj.getRequired(MojDb::RevKey, revOut);
MojTestErrCheck(err);
return MojErrNone;
}
示例12: objId
/**
* Add records to first shard for a single Kind
*/
MojErr MojDbShardManagerTest::createShardObjects1 (MojDb& db, MojDbShardInfo& shard)
{
MojObject objKind;
MojString kindId;
MojErr err = kindId.assign(_T("TestShard1:1"));
MojErrCheck(err);
err = objKind.putString(_T("_kind"), kindId.data());
MojErrCheck(err);
//generate
err = generateItem(shard);
MojErrCheck(err);
err = addKind(TestShardKind1Str, db);
MojErrCheck(err);
err = verifyKindExistance(kindId, db);
MojErrCheck(err);
//store shard info
err = db.shardEngine()->put(shard);
MojErrCheck(err);
//add record
MojObject record;
err = record.putString(_T("_kind"), kindId.data());
MojErrCheck(err);
//add value
MojObject objId(static_cast<MojInt32>(shard.id));
err = record.put(_T("recId"), objId);
MojErrCheck(err);
//put
MojString strShardId;
MojDbShardEngine::convertId(shard.id, strShardId);
err = db.put(record, MojDb::FlagNone, MojDbReq(), strShardId);
MojErrCheck(err);
return MojErrNone;
}
示例13: run
MojErr MojDbSearchCacheTest::run()
{
MojDb db;
MojErr err = db.open(MojDbTestDir);
MojTestErrCheck(err);
// add kind
MojObject kindObj;
err = kindObj.fromJson(SearchCacheKindStr);
MojTestErrCheck(err);
err = db.putKind(kindObj);
MojTestErrCheck(err);
// put test objects
for (MojSize i = 0; i < sizeof(MojSearchCacheObjects) / sizeof(MojChar*); ++i) {
MojObject obj;
err = obj.fromJson(MojSearchCacheObjects[i]);
MojTestErrCheck(err);
err = db.put(obj);
MojTestErrCheck(err);
}
err = testQueryKey();
MojTestErrCheck(err);
err = operatorTest(db);
MojTestErrCheck(err);
/*** :: TODO :: make query scenario
err = queryTest(db);
MojTestErrCheck(err);
***/
err = db.close();
MojTestErrCheck(err);
return MojErrNone;
}
示例14: putLargeArrayObj
MojErr MojDbPerfCreateTest::putLargeArrayObj(MojDb& db, const MojChar* kindId, MojTime& lgArrayObjTime)
{
MojTime startTime;
MojTime endTime;
for (MojUInt64 i = 0; i < numInsert; i++) {
MojObject obj;
MojErr err = obj.putString(MojDb::KindKey, kindId);
MojTestErrCheck(err);
err = createLargeArrayObj(obj, i);
MojTestErrCheck(err);
err = MojGetCurrentTime(startTime);
MojTestErrCheck(err);
err = db.put(obj);
MojTestErrCheck(err);
err = MojGetCurrentTime(endTime);
MojTestErrCheck(err);
lgArrayObjTime += (endTime - startTime);
totalTestTime += (endTime - startTime);
}
return MojErrNone;
}
示例15: put
void put(MojDb& db, const MojChar* objJson)
{
MojObject obj;
MojAssertNoErr( obj.fromJson(objJson) );
MojAssertNoErr( db.put(obj) );
}