当前位置: 首页>>代码示例>>C++>>正文


C++ MojDb::shardEngine方法代码示例

本文整理汇总了C++中MojDb::shardEngine方法的典型用法代码示例。如果您正苦于以下问题:C++ MojDb::shardEngine方法的具体用法?C++ MojDb::shardEngine怎么用?C++ MojDb::shardEngine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MojDb的用法示例。


在下文中一共展示了MojDb::shardEngine方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: run

/**
 * run
 */
MojErr MojDbShardManagerTest::run()
{
    MojErr err = MojErrNone;
    MojDb db;

    // open
    err = db.open(MojDbTestDir);
    MojTestErrCheck(err);

    MojDbShardEngine* p_eng = db.shardEngine();
    MojDbShardIdCache cache;
    err = testShardIdCacheIndexes(&cache);
    MojTestErrCheck(err);
    err = testShardIdCacheOperations(&cache);
    MojTestErrCheck(err);
    err = testShardEngine(p_eng);
    MojTestErrCheck(err);

    err = testShardCreateAndRemoveWithRecords(db);
    MojTestErrCheck(err);

    err = db.close();
    MojTestErrCheck(err);

    return err;
}
开发者ID:ctbrowser,项目名称:db8,代码行数:29,代码来源:MojDbShardManagerTest.cpp

示例2: verifyShardExistance

/**
 * verifyExistance1
 */
MojErr MojDbShardManagerTest::verifyShardExistance (MojDb& db, const MojDbShardInfo& shard)
{
    bool found;

    MojErr err = db.shardEngine()->isIdExist(shard.id, found);
    MojTestErrCheck(err);

    if (!found)
    {
        err = MojErrDbVerificationFailed;
        MojErrCheck(err);
    }

    return MojErrNone;
}
开发者ID:ctbrowser,项目名称:db8,代码行数:18,代码来源:MojDbShardManagerTest.cpp

示例3: 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;
}
开发者ID:ctbrowser,项目名称:db8,代码行数:44,代码来源:MojDbShardManagerTest.cpp

示例4: testShardCreateAndRemoveWithRecords

/**
 * testShardCreateAndRemoveWithRecords
 *
 * - create 3 new shards
 * - add records to 1st and 2nd shard
 * - remove shard 1
 * - verify existance of shard 1
 * - verify records of shard 2
 * - remove shard 2
 * - verify existance of shard 2
 * - verify records of shard 3 (== 0)
 * - remove shard 3
 * - verify existance of shard 3
 */
MojErr MojDbShardManagerTest::testShardCreateAndRemoveWithRecords (MojDb& db)
{
    MojDbShardEngine* p_eng = db.shardEngine();
    MojTestAssert(p_eng);

    MojDbShardInfo shard1, shard2;
    MojVector<MojUInt32> arrShardIds;
    MojUInt32 count;

    //---------------------------------------------------------------
    // test shard 1
    //---------------------------------------------------------------

    MojErr err = createShardObjects1(db, shard1);
    MojErrCheck(err);

    //verify number of records for shard 1 (shard is active)
    err = verifyRecords(_T("TestShard1:1"), db, shard1, count);
    MojTestErrCheck(err);
    MojTestAssert(count == 1);

    //err = db.shardEngine()->purgeShardObjects(1);
    //MojTestErrCheck(err);

    //remove shard 1
    arrShardIds.push(shard1.id);
    err = p_eng->removeShardObjects(arrShardIds);
    MojErrCheck(err);

    //verify number of records for shard 1
    err = verifyRecords(_T("TestShard1:1"), db, shard1, count);
    MojErrCheck(err);
    MojTestAssert(count == 0);

    //verify existance of shard 1
    err = verifyShardExistance(db, shard1);
    MojErrCheck(err);

    //---------------------------------------------------------------
    // test shard 2
    //---------------------------------------------------------------

    err = createShardObjects2(db, shard2);
    MojErrCheck(err);

    //verify number of records for shard 1 (shard is active)
    err = verifyRecords(_T("TestShard1:1"), db, shard2, count);
    MojTestErrCheck(err);
    MojTestAssert(count == 1);

    err = verifyRecords(_T("TestShard2:1"), db, shard2, count);
    MojTestErrCheck(err);
    MojTestAssert(count == 1);

    err = verifyRecords(_T("TestShard3:1"), db, shard2, count);
    MojTestErrCheck(err);
    MojTestAssert(count == 1);

    //remove shard 1
    arrShardIds.push(shard2.id);
    err = p_eng->removeShardObjects(arrShardIds);
    MojErrCheck(err);

    //verify number of records for shard 1
    err = verifyRecords(_T("TestShard1:1"), db, shard2, count);
    MojErrCheck(err);
    MojTestAssert(count == 0);

    err = verifyRecords(_T("TestShard2:1"), db, shard2, count);
    MojErrCheck(err);
    MojTestAssert(count == 0);

    err = verifyRecords(_T("TestShard3:1"), db, shard2, count);
    MojErrCheck(err);
    MojTestAssert(count == 0);

    //verify existance of shard 1
    err = verifyShardExistance(db, shard2);
    MojErrCheck(err);

    return MojErrNone;
}
开发者ID:ctbrowser,项目名称:db8,代码行数:96,代码来源:MojDbShardManagerTest.cpp


注:本文中的MojDb::shardEngine方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。