您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ uow函数代码示例

51自学网 2021-06-03 09:12:44
  C++
这篇教程C++ uow函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中uow函数的典型用法代码示例。如果您正苦于以下问题:C++ uow函数的具体用法?C++ uow怎么用?C++ uow使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

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

示例1: TEST

    // Insert a record and try to perform an in-place update on it.    TEST( RecordStoreTestHarness, UpdateWithDamages ) {        scoped_ptr<HarnessHelper> harnessHelper( newHarnessHelper() );        scoped_ptr<RecordStore> rs( harnessHelper->newNonCappedRecordStore() );        {            scoped_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() );            ASSERT_EQUALS( 0, rs->numRecords( opCtx.get() ) );        }        string data = "00010111";        DiskLoc loc;        const RecordData rec(data.c_str(), data.size() + 1);        {            scoped_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() );            {                WriteUnitOfWork uow( opCtx.get() );                StatusWith<DiskLoc> res = rs->insertRecord( opCtx.get(),                                                            rec.data(),                                                            rec.size(),                                                            false );                ASSERT_OK( res.getStatus() );                loc = res.getValue();                uow.commit();            }        }        {            scoped_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() );            ASSERT_EQUALS( 1, rs->numRecords( opCtx.get() ) );        }        {            scoped_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() );            {                mutablebson::DamageVector dv( 3 );                dv[0].sourceOffset = 5;                dv[0].targetOffset = 0;                dv[0].size = 2;                dv[1].sourceOffset = 3;                dv[1].targetOffset = 2;                dv[1].size = 3;                dv[2].sourceOffset = 0;                dv[2].targetOffset = 5;                dv[2].size = 3;                WriteUnitOfWork uow( opCtx.get() );                ASSERT_OK( rs->updateWithDamages( opCtx.get(), loc, rec, data.c_str(), dv ) );                uow.commit();            }        }        data = "11101000";        {            scoped_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() );            {                RecordData record = rs->dataFor( opCtx.get(), loc );                ASSERT_EQUALS( data, record.data() );            }        }    }
开发者ID:Aaron20141021,项目名称:mongo,代码行数:61,


示例2: run

    void run() {        string ns = "unittests.rollback_set_index_head";        const ServiceContext::UniqueOperationContext opCtxPtr = cc().makeOperationContext();        OperationContext& opCtx = *opCtxPtr;        NamespaceString nss(ns);        dropDatabase(&opCtx, nss);        createCollection(&opCtx, nss);        AutoGetDb autoDb(&opCtx, nss.db(), MODE_X);        Collection* coll = autoDb.getDb()->getCollection(&opCtx, nss);        IndexCatalog* catalog = coll->getIndexCatalog();        string idxName = "a";        BSONObj spec = BSON("ns" << ns << "key" << BSON("a" << 1) << "name" << idxName << "v"                                 << static_cast<int>(kIndexVersion));        {            WriteUnitOfWork uow(&opCtx);            ASSERT_OK(catalog->createIndexOnEmptyCollection(&opCtx, spec));            uow.commit();        }        IndexDescriptor* indexDesc = catalog->findIndexByName(&opCtx, idxName);        invariant(indexDesc);        const IndexCatalogEntry* ice = catalog->getEntry(indexDesc);        invariant(ice);        HeadManager* headManager = ice->headManager();        const RecordId oldHead = headManager->getHead(&opCtx);        ASSERT_EQ(oldHead, ice->head(&opCtx));        const RecordId dummyHead(123, 456);        ASSERT_NE(oldHead, dummyHead);        // END SETUP / START TEST        {            WriteUnitOfWork uow(&opCtx);            headManager->setHead(&opCtx, dummyHead);            ASSERT_EQ(ice->head(&opCtx), dummyHead);            ASSERT_EQ(headManager->getHead(&opCtx), dummyHead);            if (!rollback) {                uow.commit();            }        }        if (rollback) {            ASSERT_EQ(ice->head(&opCtx), oldHead);            ASSERT_EQ(headManager->getHead(&opCtx), oldHead);        } else {            ASSERT_EQ(ice->head(&opCtx), dummyHead);            ASSERT_EQ(headManager->getHead(&opCtx), dummyHead);        }    }
开发者ID:i80and,项目名称:mongo,代码行数:58,


示例3: TEST

    TEST( RecordStoreTestHarness, Simple1 ) {        scoped_ptr<HarnessHelper> harnessHelper( newHarnessHelper() );        scoped_ptr<RecordStore> rs( harnessHelper->newNonCappedRecordStore() );        {            scoped_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() );            ASSERT_EQUALS( 0, rs->numRecords( opCtx.get() ) );        }        string s = "eliot was here";        DiskLoc loc1;        {            scoped_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() );            {                WriteUnitOfWork uow( opCtx.get() );                StatusWith<DiskLoc> res = rs->insertRecord( opCtx.get(), s.c_str(), s.size() + 1, false );                ASSERT_OK( res.getStatus() );                loc1 = res.getValue();                uow.commit();            }            ASSERT_EQUALS( s, rs->dataFor( opCtx.get(), loc1 ).data() );        }        {            scoped_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() );            ASSERT_EQUALS( s, rs->dataFor( opCtx.get(), loc1 ).data() );            ASSERT_EQUALS( 1, rs->numRecords( opCtx.get() ) );            RecordData rd;            ASSERT( !rs->findRecord( opCtx.get(), DiskLoc(111,17), &rd ) );            ASSERT( rd.data() == NULL );            ASSERT( rs->findRecord( opCtx.get(), loc1, &rd ) );            ASSERT_EQUALS( s, rd.data() );        }        {            scoped_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() );            {                WriteUnitOfWork uow( opCtx.get() );                StatusWith<DiskLoc> res = rs->insertRecord( opCtx.get(), s.c_str(), s.size() + 1, false );                ASSERT_OK( res.getStatus() );                uow.commit();            }        }        {            scoped_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() );            ASSERT_EQUALS( 2, rs->numRecords( opCtx.get() ) );        }    }
开发者ID:dpercy,项目名称:mongo,代码行数:55,


示例4: TEST

    // Insert a record and try to call updateWithDamages() with an empty DamageVector.    TEST( RecordStoreTestHarness, UpdateWithNoDamages ) {        scoped_ptr<HarnessHelper> harnessHelper( newHarnessHelper() );        scoped_ptr<RecordStore> rs( harnessHelper->newNonCappedRecordStore() );        if (!rs->updateWithDamagesSupported())            return;        {            scoped_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() );            ASSERT_EQUALS( 0, rs->numRecords( opCtx.get() ) );        }        string data = "my record";        RecordId loc;        const RecordData rec(data.c_str(), data.size() + 1);        {            scoped_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() );            {                WriteUnitOfWork uow( opCtx.get() );                StatusWith<RecordId> res = rs->insertRecord( opCtx.get(),                                                            rec.data(),                                                            rec.size(),                                                            false );                ASSERT_OK( res.getStatus() );                loc = res.getValue();                uow.commit();            }        }        {            scoped_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() );            ASSERT_EQUALS( 1, rs->numRecords( opCtx.get() ) );        }        {            scoped_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() );            {                mutablebson::DamageVector dv;                WriteUnitOfWork uow( opCtx.get() );                ASSERT_OK( rs->updateWithDamages( opCtx.get(), loc, rec, "", dv ) );                uow.commit();            }        }        {            scoped_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() );            {                RecordData record = rs->dataFor( opCtx.get(), loc );                ASSERT_EQUALS( data, record.data() );            }        }    }
开发者ID:7segments,项目名称:mongo-1,代码行数:54,


示例5: TEST_F

TEST_F(KVCatalogTest, Coll1) {    unique_ptr<KVHarnessHelper> helper(KVHarnessHelper::create());    KVEngine* engine = helper->getEngine();    unique_ptr<RecordStore> rs;    unique_ptr<KVCatalog> catalog;    {        MyOperationContext opCtx(engine);        WriteUnitOfWork uow(&opCtx);        ASSERT_OK(engine->createRecordStore(&opCtx, "catalog", "catalog", CollectionOptions()));        rs = engine->getRecordStore(&opCtx, "catalog", "catalog", CollectionOptions());        catalog.reset(new KVCatalog(rs.get(), false, false, nullptr));        uow.commit();    }    {        MyOperationContext opCtx(engine);        WriteUnitOfWork uow(&opCtx);        ASSERT_OK(newCollection(&opCtx,                                NamespaceString("a.b"),                                CollectionOptions(),                                KVPrefix::kNotPrefixed,                                catalog.get()));        ASSERT_NOT_EQUALS("a.b", catalog->getCollectionIdent("a.b"));        uow.commit();    }    string ident = catalog->getCollectionIdent("a.b");    {        MyOperationContext opCtx(engine);        WriteUnitOfWork uow(&opCtx);        catalog.reset(new KVCatalog(rs.get(), false, false, nullptr));        catalog->init(&opCtx);        uow.commit();    }    ASSERT_EQUALS(ident, catalog->getCollectionIdent("a.b"));    {        MyOperationContext opCtx(engine);        WriteUnitOfWork uow(&opCtx);        dropCollection(&opCtx, "a.b", catalog.get()).transitional_ignore();        newCollection(&opCtx,                      NamespaceString("a.b"),                      CollectionOptions(),                      KVPrefix::kNotPrefixed,                      catalog.get())            .transitional_ignore();        uow.commit();    }    ASSERT_NOT_EQUALS(ident, catalog->getCollectionIdent("a.b"));}
开发者ID:acmorrow,项目名称:mongo,代码行数:51,


示例6: TEST

    TEST( RocksRecordStoreTest, Truncate1 ) {        unittest::TempDir td( _rocksRecordStoreTestDir );        scoped_ptr<rocksdb::DB> db( getDB( td.path() ) );        {            rocksdb::ColumnFamilyHandle* cf1;            rocksdb::ColumnFamilyHandle* cf1_m;            rocksdb::Status status;            status = db->CreateColumnFamily( getColumnFamilyOptions(), "foo.bar1", &cf1 );            ASSERT_OK( toMongoStatus( status ) );            status = db->CreateColumnFamily( rocksdb::ColumnFamilyOptions(), "foo.bar1&", &cf1_m );            ASSERT_OK( toMongoStatus( status ) );            RocksRecordStore rs( "foo.bar", db.get(), cf1, cf1_m );            string s = "antonio was here";            {                MyOperationContext opCtx( db.get() );                WriteUnitOfWork uow( opCtx.recoveryUnit() );                StatusWith<DiskLoc> res = rs.insertRecord( &opCtx, s.c_str(), s.size() + 1, -1 );                ASSERT_OK( res.getStatus() );                res = rs.insertRecord( &opCtx, s.c_str(), s.size() + 1, -1 );                ASSERT_OK( res.getStatus() );            }            {                MyOperationContext opCtx( db.get() );                WriteUnitOfWork uow( opCtx.recoveryUnit() );                Status stat = rs.truncate( &opCtx );                ASSERT_OK( stat );                ASSERT_EQUALS( 0, rs.numRecords() );                ASSERT_EQUALS( 0, rs.dataSize() );            }            // Test that truncate does not fail on an empty collection            {                MyOperationContext opCtx( db.get() );                WriteUnitOfWork uow( opCtx.recoveryUnit() );                Status stat = rs.truncate( &opCtx );                ASSERT_OK( stat );                ASSERT_EQUALS( 0, rs.numRecords() );                ASSERT_EQUALS( 0, rs.dataSize() );            }        }    }
开发者ID:li--paul,项目名称:mongo,代码行数:49,


示例7: lk

 long long BackgroundSync::_readLastAppliedHash(OperationContext* txn) {     BSONObj oplogEntry;     try {         // Uses WuoW because there is no way to demarcate a read transaction boundary.         Lock::DBLock lk(txn->lockState(), "local", MODE_X);         WriteUnitOfWork uow(txn);         bool success = Helpers::getLast(txn, rsoplog, oplogEntry);         uow.commit();         if (!success) {             // This can happen when we are to do an initial sync.  lastHash will be set             // after the initial sync is complete.             return 0;         }     }     catch (const DBException& ex) {         severe() << "Problem reading " << rsoplog << ": " << ex.toStatus();         fassertFailed(18904);     }     BSONElement hashElement = oplogEntry[hashFieldName];     if (hashElement.eoo()) {         severe() << "Most recent entry in " << rsoplog << " missing /"" << hashFieldName <<             "/" field";         fassertFailed(18902);     }     if (hashElement.type() != NumberLong) {         severe() << "Expected type of /"" << hashFieldName << "/" in most recent " <<              rsoplog << " entry to have type NumberLong, but found " <<              typeName(hashElement.type());         fassertFailed(18903);     }     return hashElement.safeNumberLong(); }
开发者ID:FranckBel,项目名称:mongo,代码行数:32,


示例8: TEST

    // Call savePosition() on a reverse cursor without ever calling restorePosition().    // May be useful to run this test under valgrind to verify there are no leaks.    TEST( SortedDataInterface, SavePositionWithoutRestoreReversed ) {        scoped_ptr<HarnessHelper> harnessHelper( newHarnessHelper() );        scoped_ptr<SortedDataInterface> sorted( harnessHelper->newSortedDataInterface( false ) );        {            scoped_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() );            ASSERT( sorted->isEmpty( opCtx.get() ) );        }        {            scoped_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() );            {                WriteUnitOfWork uow( opCtx.get() );                ASSERT_OK( sorted->insert( opCtx.get(), key1, loc1, true ) );                uow.commit();            }        }        {            scoped_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() );            ASSERT_EQUALS( 1, sorted->numEntries( opCtx.get() ) );        }        {            scoped_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() );            scoped_ptr<SortedDataInterface::Cursor> cursor( sorted->newCursor( opCtx.get(), -1 ) );            cursor->savePosition();        }    }
开发者ID:Aaron20141021,项目名称:mongo,代码行数:31,


示例9: TEST

    TEST( KVEngineTestHarness, SimpleRS1 ) {        scoped_ptr<KVHarnessHelper> helper( KVHarnessHelper::create() );        KVEngine* engine = helper->getEngine();        ASSERT( engine );        string ns = "a.b";        scoped_ptr<RecordStore> rs;        {            MyOperationContext opCtx( engine );            ASSERT_OK( engine->createRecordStore( &opCtx, ns, CollectionOptions() ) );            rs.reset( engine->getRecordStore( &opCtx, ns, ns, CollectionOptions() ) );            ASSERT( rs );        }        DiskLoc loc;        {            MyOperationContext opCtx( engine );            WriteUnitOfWork uow( &opCtx );            StatusWith<DiskLoc> res = rs->insertRecord( &opCtx, "abc", 4, false );            ASSERT_OK( res.getStatus() );            loc = res.getValue();            uow.commit();        }        {            MyOperationContext opCtx( engine );            ASSERT_EQUALS( string("abc"), rs->dataFor( &opCtx, loc ).data() );        }    }
开发者ID:dpercy,项目名称:mongo,代码行数:31,


示例10: TEST

// Insert multiple keys and verify that fullValidate() either sets// the `numKeysOut` as the number of entries in the index, or as -1.TEST(SortedDataInterface, FullValidate) {    const std::unique_ptr<HarnessHelper> harnessHelper(newHarnessHelper());    const std::unique_ptr<SortedDataInterface> sorted(harnessHelper->newSortedDataInterface(false));    {        const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext());        ASSERT(sorted->isEmpty(opCtx.get()));    }    int nToInsert = 10;    for (int i = 0; i < nToInsert; i++) {        const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext());        {            WriteUnitOfWork uow(opCtx.get());            BSONObj key = BSON("" << i);            RecordId loc(42, i * 2);            ASSERT_OK(sorted->insert(opCtx.get(), key, loc, true));            uow.commit();        }    }    {        const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext());        ASSERT_EQUALS(nToInsert, sorted->numEntries(opCtx.get()));    }    {        long long numKeysOut;        const std::unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext());        sorted->fullValidate(opCtx.get(), &numKeysOut, NULL);        // fullValidate() can set numKeysOut as the number of existing keys or -1.        ASSERT(numKeysOut == nToInsert || numKeysOut == -1);    }}
开发者ID:AlexOreshkevich,项目名称:mongo,代码行数:36,


示例11: TEST

// Verify that a nonempty collection maybe takes up some space on disk.TEST(RecordStoreTestHarness, StorageSizeNonEmpty) {    unique_ptr<HarnessHelper> harnessHelper(newHarnessHelper());    unique_ptr<RecordStore> rs(harnessHelper->newNonCappedRecordStore());    {        unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext());        ASSERT_EQUALS(0, rs->numRecords(opCtx.get()));    }    int nToInsert = 10;    for (int i = 0; i < nToInsert; i++) {        unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext());        {            stringstream ss;            ss << "record " << i;            string data = ss.str();            WriteUnitOfWork uow(opCtx.get());            StatusWith<RecordId> res =                rs->insertRecord(opCtx.get(), data.c_str(), data.size() + 1, false);            ASSERT_OK(res.getStatus());            uow.commit();        }    }    {        unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext());        ASSERT_EQUALS(nToInsert, rs->numRecords(opCtx.get()));    }    {        unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext());        ASSERT(rs->storageSize(opCtx.get(), NULL) >= 0);    }}
开发者ID:stevelyall,项目名称:mongol-db,代码行数:36,


示例12: TEST

    TEST( RocksEngineTest, CreateDirect1 ) {        std::string path = "/tmp/mongo-rocks-engine-test";        boost::filesystem::remove_all( path );        RocksEngine engine( path );        {            MyOperationContext opCtx( &engine );            Status status = engine.createCollection( &opCtx,                                                     "test.foo",                                                     CollectionOptions() );            ASSERT_OK( status );        }        RocksRecordStore* rs = engine.getEntry( "test.foo" )->recordStore.get();        string s = "eliot was here";        {            MyOperationContext opCtx( &engine );            DiskLoc loc;            {                WriteUnitOfWork uow( opCtx.recoveryUnit() );                StatusWith<DiskLoc> res = rs->insertRecord( &opCtx, s.c_str(), s.size() + 1, -1 );                ASSERT_OK( res.getStatus() );                loc = res.getValue();            }            ASSERT_EQUALS( s, rs->dataFor( loc ).data() );        }    }
开发者ID:li--paul,项目名称:mongo,代码行数:29,


示例13: TEST

TEST(KVEngineTestHarness, SimpleSorted1) {    unique_ptr<KVHarnessHelper> helper(KVHarnessHelper::create());    KVEngine* engine = helper->getEngine();    ASSERT(engine);    string ident = "abc";    IndexDescriptor desc(nullptr,                         "",                         BSON("v" << static_cast<int>(IndexDescriptor::kLatestIndexVersion) << "ns"                                  << "mydb.mycoll"                                  << "key"                                  << BSON("a" << 1)));    unique_ptr<SortedDataInterface> sorted;    {        MyOperationContext opCtx(engine);        ASSERT_OK(engine->createSortedDataInterface(&opCtx, ident, &desc));        sorted.reset(engine->getSortedDataInterface(&opCtx, ident, &desc));        ASSERT(sorted);    }    {        MyOperationContext opCtx(engine);        WriteUnitOfWork uow(&opCtx);        ASSERT_OK(sorted->insert(&opCtx, BSON("" << 5), RecordId(6, 4), true));        uow.commit();    }    {        MyOperationContext opCtx(engine);        ASSERT_EQUALS(1, sorted->numEntries(&opCtx));    }}
开发者ID:acmorrow,项目名称:mongo,代码行数:32,


示例14: TEST

// Insert multiple records and create a random iterator for the record storeTEST(RecordStoreTestHarness, GetRandomIteratorNonEmpty) {    unique_ptr<HarnessHelper> harnessHelper(newHarnessHelper());    unique_ptr<RecordStore> rs(harnessHelper->newNonCappedRecordStore());    {        unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext());        ASSERT_EQUALS(0, rs->numRecords(opCtx.get()));    }    const unsigned nToInsert =        5000;  // should be non-trivial amount, so we get multiple btree levels    RecordId locs[nToInsert];    for (unsigned i = 0; i < nToInsert; i++) {        unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext());        {            stringstream ss;            ss << "record " << i;            string data = ss.str();            WriteUnitOfWork uow(opCtx.get());            StatusWith<RecordId> res =                rs->insertRecord(opCtx.get(), data.c_str(), data.size() + 1, false);            ASSERT_OK(res.getStatus());            locs[i] = res.getValue();            uow.commit();        }    }    {        unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext());        ASSERT_EQUALS(nToInsert, rs->numRecords(opCtx.get()));    }    set<RecordId> remain(locs, locs + nToInsert);    {        unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext());        auto cursor = rs->getRandomCursor(opCtx.get());        // returns NULL if getRandomCursor is not supported        if (!cursor) {            return;        }        // Iterate documents and mark those visited, but let at least one remain        for (unsigned i = 0; i < nToInsert - 1; i++) {            // Get a new cursor once in a while, shouldn't affect things            if (i % (nToInsert / 8) == 0) {                cursor = rs->getRandomCursor(opCtx.get());            }            remain.erase(cursor->next()->id);  // can happen more than once per doc        }        ASSERT(!remain.empty());        ASSERT(cursor->next());        // We should have at least visited a quarter of the items if we're any random at all        // The expected fraction of visited records is 62.3%.        ASSERT_LT(remain.size(), nToInsert * 3 / 4);    }}
开发者ID:stevelyall,项目名称:mongol-db,代码行数:59,


示例15: TEST

TEST(KVCatalogTest, DirectoryPerAndSplit1) {    unique_ptr<KVHarnessHelper> helper(KVHarnessHelper::create());    KVEngine* engine = helper->getEngine();    unique_ptr<RecordStore> rs;    unique_ptr<KVCatalog> catalog;    {        MyOperationContext opCtx(engine);        WriteUnitOfWork uow(&opCtx);        ASSERT_OK(engine->createRecordStore(&opCtx, "catalog", "catalog", CollectionOptions()));        rs = engine->getRecordStore(&opCtx, "catalog", "catalog", CollectionOptions());        catalog.reset(new KVCatalog(rs.get(), true, true));        uow.commit();    }    {        MyOperationContext opCtx(engine);        WriteUnitOfWork uow(&opCtx);        ASSERT_OK(            catalog->newCollection(&opCtx, "a.b", CollectionOptions(), KVPrefix::kNotPrefixed));        ASSERT_STRING_CONTAINS(catalog->getCollectionIdent("a.b"), "a/collection/");        ASSERT_TRUE(catalog->isUserDataIdent(catalog->getCollectionIdent("a.b")));        uow.commit();    }    {  // index        MyOperationContext opCtx(engine);        WriteUnitOfWork uow(&opCtx);        BSONCollectionCatalogEntry::MetaData md;        md.ns = "a.b";        md.indexes.push_back(BSONCollectionCatalogEntry::IndexMetaData(BSON("name"                                                                            << "foo"),                                                                       false,                                                                       RecordId(),                                                                       false,                                                                       KVPrefix::kNotPrefixed,                                                                       false));        catalog->putMetaData(&opCtx, "a.b", md);        ASSERT_STRING_CONTAINS(catalog->getIndexIdent(&opCtx, "a.b", "foo"), "a/index/");        ASSERT_TRUE(catalog->isUserDataIdent(catalog->getIndexIdent(&opCtx, "a.b", "foo")));        uow.commit();    }}
开发者ID:RyanBard,项目名称:mongo,代码行数:44,



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


C++ up函数代码示例
C++ unzlocal_getShort函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。