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

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

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

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

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

示例1: insertDocument

    void insertDocument(Collection* collection, BSONObj obj) {        WriteUnitOfWork wuow(&_txn);        const bool enforceQuota = false;        StatusWith<RecordId> res = collection->insertDocument(&_txn, obj, enforceQuota);        ASSERT(res.isOK());        wuow.commit();    }
开发者ID:alabid,项目名称:mongo,代码行数:9,


示例2: autoDb

mongo::Status mongo::emptyCapped(OperationContext* opCtx, const NamespaceString& collectionName) {    AutoGetDb autoDb(opCtx, collectionName.db(), MODE_X);    bool userInitiatedWritesAndNotPrimary = opCtx->writesAreReplicated() &&        !repl::ReplicationCoordinator::get(opCtx)->canAcceptWritesFor(opCtx, collectionName);    if (userInitiatedWritesAndNotPrimary) {        return Status(ErrorCodes::NotMaster,                      str::stream() << "Not primary while truncating collection: "                                    << collectionName.ns());    }    Database* db = autoDb.getDb();    uassert(ErrorCodes::NamespaceNotFound, "no such database", db);    Collection* collection = db->getCollection(opCtx, collectionName);    uassert(ErrorCodes::CommandNotSupportedOnView,            str::stream() << "emptycapped not supported on view: " << collectionName.ns(),            collection || !db->getViewCatalog()->lookup(opCtx, collectionName.ns()));    uassert(ErrorCodes::NamespaceNotFound, "no such collection", collection);    if (collectionName.isSystem() && !collectionName.isSystemDotProfile()) {        return Status(ErrorCodes::IllegalOperation,                      str::stream() << "Cannot truncate a system collection: "                                    << collectionName.ns());    }    if (collectionName.isVirtualized()) {        return Status(ErrorCodes::IllegalOperation,                      str::stream() << "Cannot truncate a virtual collection: "                                    << collectionName.ns());    }    if ((repl::ReplicationCoordinator::get(opCtx)->getReplicationMode() !=         repl::ReplicationCoordinator::modeNone) &&        collectionName.isOplog()) {        return Status(ErrorCodes::OplogOperationUnsupported,                      str::stream() << "Cannot truncate a live oplog while replicating: "                                    << collectionName.ns());    }    BackgroundOperation::assertNoBgOpInProgForNs(collectionName.ns());    WriteUnitOfWork wuow(opCtx);    Status status = collection->truncate(opCtx);    if (!status.isOK()) {        return status;    }    getGlobalServiceContext()->getOpObserver()->onEmptyCapped(        opCtx, collection->ns(), collection->uuid());    wuow.commit();    return Status::OK();}
开发者ID:RyanBard,项目名称:mongo,代码行数:57,


示例3: run

        void run() {            ScopedTransaction transaction(&_txn, MODE_IX);            Lock::DBLock lk(_txn.lockState(), nsToDatabaseSubstring(ns()), MODE_X);            Client::Context ctx(&_txn, ns());            Database* db = ctx.db();            Collection* coll = db->getCollection(&_txn, ns());            if (!coll) {                WriteUnitOfWork wuow(&_txn);                coll = db->createCollection(&_txn, ns());                wuow.commit();            }            WorkingSet ws;            // Add an object to the DB.            insert(BSON("foo" << 5));            set<DiskLoc> locs;            getLocs(&locs, coll);            ASSERT_EQUALS(size_t(1), locs.size());            // Create a mock stage that returns the WSM.            auto_ptr<MockStage> mockStage(new MockStage(&ws));            // Mock data.            {                WorkingSetMember mockMember;                mockMember.state = WorkingSetMember::LOC_AND_IDX;                mockMember.loc = *locs.begin();                // State is loc and index, shouldn't be able to get the foo data inside.                BSONElement elt;                ASSERT_FALSE(mockMember.getFieldDotted("foo", &elt));                mockStage->pushBack(mockMember);            }            // Make the filter.            BSONObj filterObj = BSON("foo" << 6);            StatusWithMatchExpression swme = MatchExpressionParser::parse(filterObj);            verify(swme.isOK());            auto_ptr<MatchExpression> filterExpr(swme.getValue());            // Matcher requires that foo==6 but we only have data with foo==5.            auto_ptr<FetchStage> fetchStage(                     new FetchStage(&_txn, &ws, mockStage.release(), filterExpr.get(), coll));            // First call should return a fetch request as it's not in memory.            WorkingSetID id = WorkingSet::INVALID_ID;            PlanStage::StageState state;            // Normally we'd return the object but we have a filter that prevents it.            state = fetchStage->work(&id);            ASSERT_EQUALS(PlanStage::NEED_TIME, state);            // No more data to fetch, so, EOF.            state = fetchStage->work(&id);            ASSERT_EQUALS(PlanStage::IS_EOF, state);        }
开发者ID:CodeHub2,项目名称:mongo,代码行数:57,


示例4: lk

        ~IndexIteratorTests() {            OperationContextImpl txn;            Lock::DBLock lk(txn.lockState(), nsToDatabaseSubstring(_ns), MODE_X);            Client::Context ctx(&txn, _ns);            WriteUnitOfWork wuow(&txn);            _db->dropCollection(&txn, _ns);            wuow.commit();        }
开发者ID:Karl-Wu,项目名称:mongo,代码行数:9,


示例5: insertDocument

    void insertDocument(Collection* collection, BSONObj obj) {        WriteUnitOfWork wuow(&_opCtx);        const bool enforceQuota = false;        OpDebug* const nullOpDebug = nullptr;        ASSERT_OK(            collection->insertDocument(&_opCtx, InsertStatement(obj), nullOpDebug, enforceQuota));        wuow.commit();    }
开发者ID:louiswilliams,项目名称:mongo,代码行数:9,


示例6: run

        void run() {            Client::WriteContext ctx(&_txn, ns());            Database* db = ctx.ctx().db();            Collection* coll = db->getCollection(&_txn, ns());            if (!coll) {                WriteUnitOfWork wuow(&_txn);                coll = db->createCollection(&_txn, ns());                wuow.commit();            }            WorkingSet ws;            // Add 10 objects to the collection.            for (size_t i = 0; i < 10; ++i) {                insert(BSON("x" << 1));            }            // Create 10 objects that are flagged.            for (size_t i = 0; i < 10; ++i) {                WorkingSetID id = ws.allocate();                WorkingSetMember* member = ws.get(id);                member->state = WorkingSetMember::OWNED_OBJ;                member->obj = BSON("x" << 2);                ws.flagForReview(id);            }            // Create a collscan to provide the 10 objects in the collection.            CollectionScanParams params;            params.collection = coll;            params.direction = CollectionScanParams::FORWARD;            params.tailable = false;            params.start = RecordId();            CollectionScan* cs = new CollectionScan(&_txn, params, &ws, NULL);            // Create a KeepMutations stage to merge in the 10 flagged objects.            // Takes ownership of 'cs'            MatchExpression* nullFilter = NULL;            std::auto_ptr<KeepMutationsStage> keep(new KeepMutationsStage(nullFilter, &ws, cs));            for (size_t i = 0; i < 10; ++i) {                WorkingSetID id = getNextResult(keep.get());                WorkingSetMember* member = ws.get(id);                ASSERT_FALSE(ws.isFlagged(id));                ASSERT_EQUALS(member->obj["x"].numberInt(), 1);            }            ASSERT(cs->isEOF());            // Flagged results *must* be at the end.            for (size_t i = 0; i < 10; ++i) {                WorkingSetID id = getNextResult(keep.get());                WorkingSetMember* member = ws.get(id);                ASSERT(ws.isFlagged(id));                ASSERT_EQUALS(member->obj["x"].numberInt(), 2);            }        }
开发者ID:3rf,项目名称:mongo,代码行数:56,


示例7: uassert

void FeatureCompatibilityVersion::set(OperationContext* txn, StringData version) {    uassert(40284,            "featureCompatibilityVersion must be '3.4' or '3.2'. See "            "http://dochub.mongodb.org/core/3.4-feature-compatibility.",            version == FeatureCompatibilityVersionCommandParser::kVersion34 ||                version == FeatureCompatibilityVersionCommandParser::kVersion32);    DBDirectClient client(txn);    NamespaceString nss(FeatureCompatibilityVersion::kCollection);    if (version == FeatureCompatibilityVersionCommandParser::kVersion34) {        // We build a v=2 index on the "admin.system.version" collection as part of setting the        // featureCompatibilityVersion to 3.4. This is a new index version that isn't supported by        // versions of MongoDB earlier than 3.4 that will cause 3.2 secondaries to crash when it is        // replicated.        std::vector<BSONObj> indexSpecs{k32IncompatibleIndexSpec};        {            ScopedTransaction transaction(txn, MODE_IX);            AutoGetOrCreateDb autoDB(txn, nss.db(), MODE_X);            uassert(ErrorCodes::NotMaster,                    str::stream() << "Cannot set featureCompatibilityVersion to '" << version                                  << "'. Not primary while attempting to create index on: "                                  << nss.ns(),                    repl::ReplicationCoordinator::get(txn->getServiceContext())                        ->canAcceptWritesFor(nss));            IndexBuilder builder(k32IncompatibleIndexSpec, false);            auto status = builder.buildInForeground(txn, autoDB.getDb());            uassertStatusOK(status);            MONGO_WRITE_CONFLICT_RETRY_LOOP_BEGIN {                WriteUnitOfWork wuow(txn);                getGlobalServiceContext()->getOpObserver()->onCreateIndex(                    txn, autoDB.getDb()->getSystemIndexesName(), k32IncompatibleIndexSpec, false);                wuow.commit();            }            MONGO_WRITE_CONFLICT_RETRY_LOOP_END(txn, "FeatureCompatibilityVersion::set", nss.ns());        }        // We then update the featureCompatibilityVersion document stored in the        // "admin.system.version" collection. We do this after creating the v=2 index in order to        // maintain the invariant that if the featureCompatibilityVersion is 3.4, then        // 'k32IncompatibleIndexSpec' index exists on the "admin.system.version" collection.        BSONObj updateResult;        client.runCommand(nss.db().toString(),                          makeUpdateCommand(version, WriteConcernOptions::Majority),                          updateResult);        uassertStatusOK(getStatusFromCommandResult(updateResult));        uassertStatusOK(getWriteConcernStatusFromCommandResult(updateResult));        // We then update the value of the featureCompatibilityVersion server parameter.        serverGlobalParams.featureCompatibility.version.store(            ServerGlobalParams::FeatureCompatibility::Version::k34);    } else if (version == FeatureCompatibilityVersionCommandParser::kVersion32) {
开发者ID:ksuarz,项目名称:mongo,代码行数:56,


示例8: cc

    ~IndexIteratorTests() {        const ServiceContext::UniqueOperationContext opCtxPtr = cc().makeOperationContext();        OperationContext& opCtx = *opCtxPtr;        Lock::DBLock lk(&opCtx, _nss.db(), MODE_X);        OldClientContext ctx(&opCtx, _nss.ns());        WriteUnitOfWork wuow(&opCtx);        _db->dropCollection(&opCtx, _nss).transitional_ignore();        wuow.commit();    }
开发者ID:guoyr,项目名称:mongo,代码行数:10,


示例9: TEST_F

TEST_F(WiredTigerRecoveryUnitTestFixture, CommitWithoutDurableTimestamp) {    auto opCtx = clientAndCtx1.second.get();    Timestamp ts1(5, 5);    opCtx->recoveryUnit()->setCommitTimestamp(ts1);    {        WriteUnitOfWork wuow(opCtx);        wuow.commit();    }}
开发者ID:ShaneHarvey,项目名称:mongo,代码行数:10,


示例10: createOplog

    void ReplicationCoordinatorExternalStateImpl::initiateOplog(OperationContext* txn) {        createOplog(txn);        ScopedTransaction scopedXact(txn, MODE_X);        Lock::GlobalWrite globalWrite(txn->lockState());        WriteUnitOfWork wuow(txn);        getGlobalServiceContext()->getOpObserver()->onOpMessage(txn, BSON("msg" << "initiating set"));        wuow.commit();    }
开发者ID:ForNowForever,项目名称:mongo,代码行数:10,


示例11: createOplog

Status ReplicationCoordinatorExternalStateImpl::initializeReplSetStorage(OperationContext* opCtx,                                                                         const BSONObj& config) {    try {        createOplog(opCtx);        writeConflictRetry(opCtx,                           "initiate oplog entry",                           NamespaceString::kRsOplogNamespace.toString(),                           [this, &opCtx, &config] {                               Lock::GlobalWrite globalWrite(opCtx);                               WriteUnitOfWork wuow(opCtx);                               Helpers::putSingleton(opCtx, configCollectionName, config);                               const auto msgObj = BSON("msg"                                                        << "initiating set");                               _service->getOpObserver()->onOpMessage(opCtx, msgObj);                               wuow.commit();                               // ReplSetTest assumes that immediately after the replSetInitiate                               // command returns, it can allow other nodes to initial sync with no                               // retries and they will succeed.  Unfortunately, initial sync will                               // fail if it finds its sync source has an empty oplog.  Thus, we                               // need to wait here until the seed document is visible in our oplog.                               AutoGetCollection oplog(                                   opCtx, NamespaceString::kRsOplogNamespace, MODE_IS);                               waitForAllEarlierOplogWritesToBeVisible(opCtx);                           });        // Set UUIDs for all non-replicated collections. This is necessary for independent replica        // sets and config server replica sets started with no data files because collections in        // local are created prior to the featureCompatibilityVersion being set to 3.6, so the        // collections are not created with UUIDs. We exclude ShardServers when adding UUIDs to        // non-replicated collections on the primary because ShardServers are started up by default        // with featureCompatibilityVersion 3.4, so we don't want to assign UUIDs to them until the        // cluster's featureCompatibilityVersion is explicitly set to 3.6 by the config server. The        // below UUID addition for non-replicated collections only occurs on the primary; UUIDs are        // added to non-replicated collections on secondaries during InitialSync. When the config        // server sets the featureCompatibilityVersion to 3.6, the shard primary will add UUIDs to        // all the collections that need them. One special case here is if a shard is already in        // featureCompatibilityVersion 3.6 and a new node is started up with --shardsvr and added to        // that shard, the new node will still start up with featureCompatibilityVersion 3.4 and        // need to have UUIDs added to each collection. These UUIDs are added during InitialSync,        // because the new node is a secondary.        if (serverGlobalParams.clusterRole != ClusterRole::ShardServer &&            FeatureCompatibilityVersion::isCleanStartUp()) {            auto schemaStatus = updateUUIDSchemaVersionNonReplicated(opCtx, true);            if (!schemaStatus.isOK()) {                return schemaStatus;            }        }        FeatureCompatibilityVersion::setIfCleanStartup(opCtx, _storageInterface);    } catch (const DBException& ex) {        return ex.toStatus();    }    return Status::OK();}
开发者ID:i80and,项目名称:mongo,代码行数:55,


示例12: IndexIteratorTests

        IndexIteratorTests() {            OperationContextImpl txn;            Lock::DBLock lk(txn.lockState(), nsToDatabaseSubstring(_ns), MODE_X);            Client::Context ctx(&txn, _ns);            WriteUnitOfWork wuow(&txn);            _db = ctx.db();            _coll = _db->createCollection(&txn, _ns);            _catalog = _coll->getIndexCatalog();            wuow.commit();        }
开发者ID:Karl-Wu,项目名称:mongo,代码行数:11,


示例13: dropCollection

    void dropCollection() {        Lock::DBLock dbLock(&_opCtx, nss.db(), MODE_X);        Database* database = DatabaseHolder::getDatabaseHolder().get(&_opCtx, nss.db());        if (!database) {            return;        }        WriteUnitOfWork wuow(&_opCtx);        database->dropCollection(&_opCtx, nss.ns()).transitional_ignore();        wuow.commit();    }
开发者ID:louiswilliams,项目名称:mongo,代码行数:11,


示例14: run

        void run() {            Client::WriteContext ctx(&_txn, ns());            Database* db = ctx.ctx().db();            Collection* coll = db->getCollection(&_txn, ns());            if (!coll) {                WriteUnitOfWork wuow(&_txn);                coll = db->createCollection(&_txn, ns());                wuow.commit();            }            WorkingSet ws;            // Add an object to the DB.            insert(BSON("foo" << 5));            set<DiskLoc> locs;            getLocs(&locs, coll);            ASSERT_EQUALS(size_t(1), locs.size());            // Create a mock stage that returns the WSM.            auto_ptr<MockStage> mockStage(new MockStage(&ws));            // Mock data.            {                WorkingSetMember mockMember;                mockMember.state = WorkingSetMember::LOC_AND_UNOWNED_OBJ;                mockMember.loc = *locs.begin();                mockMember.obj = coll->docFor(&_txn, mockMember.loc);                // Points into our DB.                mockStage->pushBack(mockMember);                mockMember.state = WorkingSetMember::OWNED_OBJ;                mockMember.loc = DiskLoc();                mockMember.obj = BSON("foo" << 6);                ASSERT_TRUE(mockMember.obj.isOwned());                mockStage->pushBack(mockMember);            }            auto_ptr<FetchStage> fetchStage(new FetchStage(&_txn, &ws, mockStage.release(),                                                           NULL, coll));            WorkingSetID id = WorkingSet::INVALID_ID;            PlanStage::StageState state;            // Don't bother doing any fetching if an obj exists already.            state = fetchStage->work(&id);            ASSERT_EQUALS(PlanStage::ADVANCED, state);            state = fetchStage->work(&id);            ASSERT_EQUALS(PlanStage::ADVANCED, state);            // No more data to fetch, so, EOF.            state = fetchStage->work(&id);            ASSERT_EQUALS(PlanStage::IS_EOF, state);        }
开发者ID:FranckBel,项目名称:mongo,代码行数:53,


示例15: createOplog

    void ReplicationCoordinatorExternalStateImpl::initiateOplog(OperationContext* txn) {        createOplog(txn);        MONGO_WRITE_CONFLICT_RETRY_LOOP_BEGIN {            ScopedTransaction scopedXact(txn, MODE_X);            Lock::GlobalWrite globalWrite(txn->lockState());            WriteUnitOfWork wuow(txn);            getGlobalServiceContext()->getOpObserver()->onOpMessage(txn, BSON("msg" << "initiating set"));            wuow.commit();        } MONGO_WRITE_CONFLICT_RETRY_LOOP_END(txn, "initiate oplog entry", "local.oplog.rs");    }
开发者ID:Amosvista,项目名称:mongo,代码行数:12,


示例16: IndexIteratorTests

    IndexIteratorTests() {        const ServiceContext::UniqueOperationContext opCtxPtr = cc().makeOperationContext();        OperationContext& opCtx = *opCtxPtr;        Lock::DBLock lk(&opCtx, _nss.db(), MODE_X);        OldClientContext ctx(&opCtx, _nss.ns());        WriteUnitOfWork wuow(&opCtx);        _db = ctx.db();        _coll = _db->createCollection(&opCtx, _nss);        _catalog = _coll->getIndexCatalog();        wuow.commit();    }
开发者ID:guoyr,项目名称:mongo,代码行数:12,


示例17: run

        void run() {            Client::WriteContext ctx(&_txn, ns());            Database* db = ctx.ctx().db();            Collection* coll = db->getCollection(&_txn, ns());            if (!coll) {                WriteUnitOfWork wuow(&_txn);                coll = db->createCollection(&_txn, ns());                wuow.commit();            }            WorkingSet* ws = new WorkingSet();            // Sort by foo:1            MergeSortStageParams msparams;            msparams.pattern = BSON("foo" << 1);            MergeSortStage* ms = new MergeSortStage(msparams, ws, coll);            IndexScanParams params;            params.bounds.isSimpleRange = true;            params.bounds.startKey = objWithMinKey(1);            params.bounds.endKey = objWithMaxKey(1);            params.bounds.endKeyInclusive = true;            params.direction = 1;            int numIndices = 20;            for (int i = 0; i < numIndices; ++i) {                // 'a', 'b', ...                string index(1, 'a' + i);                insert(BSON(index << 1 << "foo" << i));                BSONObj indexSpec = BSON(index << 1 << "foo" << 1);                addIndex(indexSpec);                params.descriptor = getIndex(indexSpec, coll);                ms->addChild(new IndexScan(&_txn, params, ws, NULL));            }            PlanExecutor* rawExec;            Status status = PlanExecutor::make(&_txn, ws, new FetchStage(&_txn, ws, ms, NULL, coll),                                               coll, PlanExecutor::YIELD_MANUAL, &rawExec);            ASSERT_OK(status);            boost::scoped_ptr<PlanExecutor> exec(rawExec);            for (int i = 0; i < numIndices; ++i) {                BSONObj obj;                ASSERT_EQUALS(PlanExecutor::ADVANCED, exec->getNext(&obj, NULL));                ASSERT_EQUALS(i, obj["foo"].numberInt());                string index(1, 'a' + i);                ASSERT_EQUALS(1, obj[index].numberInt());            }            // Should be done now.            BSONObj foo;            ASSERT_EQUALS(PlanExecutor::IS_EOF, exec->getNext(&foo, NULL));        }
开发者ID:3rf,项目名称:mongo,代码行数:53,


示例18: dropCollection

    void dropCollection() {        ScopedTransaction transaction(&_txn, MODE_X);        Lock::DBLock dbLock(_txn.lockState(), nss.db(), MODE_X);        Database* database = dbHolder().get(&_txn, nss.db());        if (!database) {            return;        }        WriteUnitOfWork wuow(&_txn);        database->dropCollection(&_txn, nss.ns());        wuow.commit();    }
开发者ID:alabid,项目名称:mongo,代码行数:12,


示例19: update

    UpdateResult update(OperationContext* txn,                        Database* db,                        const UpdateRequest& request,                        OpDebug* opDebug) {        invariant(db);        // Explain should never use this helper.        invariant(!request.isExplain());        const NamespaceString& nsString = request.getNamespaceString();        Collection* collection = db->getCollection(nsString.ns());        // The update stage does not create its own collection.  As such, if the update is        // an upsert, create the collection that the update stage inserts into beforehand.        if (!collection && request.isUpsert()) {            // We have to have an exclusive lock on the db to be allowed to create the collection.            // Callers should either get an X or create the collection.            const Locker* locker = txn->lockState();            invariant(locker->isW() ||                      locker->isLockHeldForMode(ResourceId(RESOURCE_DATABASE, nsString.db()),                                                MODE_X));            ScopedTransaction transaction(txn, MODE_IX);            Lock::DBLock lk(txn->lockState(), nsString.db(), MODE_X);            bool userInitiatedWritesAndNotPrimary = txn->writesAreReplicated() &&                !repl::getGlobalReplicationCoordinator()->canAcceptWritesForDatabase(nsString.db());            if (userInitiatedWritesAndNotPrimary) {                uassertStatusOK(Status(ErrorCodes::NotMaster, str::stream()                    << "Not primary while creating collection " << nsString.ns()                    << " during upsert"));            }            WriteUnitOfWork wuow(txn);            collection = db->createCollection(txn, nsString.ns(), CollectionOptions());            invariant(collection);            wuow.commit();        }        // Parse the update, get an executor for it, run the executor, get stats out.        ParsedUpdate parsedUpdate(txn, &request);        uassertStatusOK(parsedUpdate.parseRequest());        PlanExecutor* rawExec;        uassertStatusOK(getExecutorUpdate(txn, collection, &parsedUpdate, opDebug, &rawExec));        boost::scoped_ptr<PlanExecutor> exec(rawExec);        uassertStatusOK(exec->executePlan());        return UpdateStage::makeUpdateResult(exec.get(), opDebug);    }
开发者ID:LatticeWu,项目名称:mongo,代码行数:52,


示例20: run

    void run() {        const ServiceContext::UniqueOperationContext opCtxPtr = cc().makeOperationContext();        OperationContext& opCtx = *opCtxPtr;        dbtests::WriteContextForTests ctx(&opCtx, _nss.ns());        const std::string indexName = "x_1";        ASSERT_OK(dbtests::createIndexFromSpec(            &opCtx,            _nss.ns(),            BSON("name" << indexName << "ns" << _nss.ns() << "key" << BSON("x" << 1) << "v"                        << static_cast<int>(kIndexVersion)                        << "expireAfterSeconds"                        << 5)));        const IndexDescriptor* desc = _catalog->findIndexByName(&opCtx, indexName);        ASSERT(desc);        ASSERT_EQUALS(5, desc->infoObj()["expireAfterSeconds"].numberLong());        // Change value of "expireAfterSeconds" on disk.        {            WriteUnitOfWork wuow(&opCtx);            _coll->getCatalogEntry()->updateTTLSetting(&opCtx, "x_1", 10);            wuow.commit();        }        // Verify that the catalog does not yet know of the change.        desc = _catalog->findIndexByName(&opCtx, indexName);        ASSERT_EQUALS(5, desc->infoObj()["expireAfterSeconds"].numberLong());        {            // Notify the catalog of the change.            WriteUnitOfWork wuow(&opCtx);            desc = _catalog->refreshEntry(&opCtx, desc);            wuow.commit();        }        // Test that the catalog reflects the change.        ASSERT_EQUALS(10, desc->infoObj()["expireAfterSeconds"].numberLong());    }
开发者ID:guoyr,项目名称:mongo,代码行数:39,


示例21: dbLock

Collection* RollbackTest::_createCollection(OperationContext* opCtx,                                            const NamespaceString& nss,                                            const CollectionOptions& options) {    Lock::DBLock dbLock(opCtx, nss.db(), MODE_X);    mongo::WriteUnitOfWork wuow(opCtx);    auto databaseHolder = DatabaseHolder::get(opCtx);    auto db = databaseHolder->openDb(opCtx, nss.db());    ASSERT_TRUE(db);    db->dropCollection(opCtx, nss.ns()).transitional_ignore();    auto coll = db->createCollection(opCtx, nss.ns(), options);    ASSERT_TRUE(coll);    wuow.commit();    return coll;}
开发者ID:hanumantmk,项目名称:mongo,代码行数:14,


示例22: update

    UpdateResult update(OperationContext* txn,                        Database* db,                        const UpdateRequest& request,                        OpDebug* opDebug) {        invariant(db);        // Explain should never use this helper.        invariant(!request.isExplain());        const NamespaceString& nsString = request.getNamespaceString();        Collection* collection = db->getCollection(txn, nsString.ns());        // The update stage does not create its own collection.  As such, if the update is        // an upsert, create the collection that the update stage inserts into beforehand.        if (!collection && request.isUpsert()) {            // We have to have an exclusive lock on the db to be allowed to create the collection.            // Callers should either get an X or create the collection.            const Locker* locker = txn->lockState();            invariant(locker->isW() ||                      locker->isLockHeldForMode(ResourceId(RESOURCE_DATABASE, nsString.db()),                                                MODE_X));            ScopedTransaction transaction(txn, MODE_IX);            Lock::DBLock lk(txn->lockState(), nsString.db(), MODE_X);            WriteUnitOfWork wuow(txn);            collection = db->createCollection(txn, nsString.ns());            invariant(collection);            if (!request.isFromReplication()) {                repl::logOp(txn,                            "c",                            (db->name() + ".$cmd").c_str(),                            BSON("create" << (nsString.coll())));            }            wuow.commit();        }        // Parse the update, get an executor for it, run the executor, get stats out.        ParsedUpdate parsedUpdate(txn, &request);        uassertStatusOK(parsedUpdate.parseRequest());        PlanExecutor* rawExec;        uassertStatusOK(getExecutorUpdate(txn, collection, &parsedUpdate, opDebug, &rawExec));        boost::scoped_ptr<PlanExecutor> exec(rawExec);        uassertStatusOK(exec->executePlan());        return UpdateStage::makeUpdateResult(exec.get(), opDebug);    }
开发者ID:3rf,项目名称:mongo,代码行数:49,


示例23: wuow

void WiredTigerRecordStore::temp_cappedTruncateAfter(OperationContext* txn,                                                     RecordId end,                                                     bool inclusive) {    WriteUnitOfWork wuow(txn);    Cursor cursor(txn, *this);    while (auto record = cursor.next()) {        RecordId loc = record->id;        if (end < loc || (inclusive && end == loc)) {            if (_cappedDeleteCallback)                uassertStatusOK(_cappedDeleteCallback->aboutToDeleteCapped(txn, loc, record->data));            deleteRecord(txn, loc);        }    }    wuow.commit();}
开发者ID:MrChen2015,项目名称:mongo,代码行数:15,


示例24: _ns

SessionCatalogMigrationSource::SessionCatalogMigrationSource(OperationContext* opCtx,                                                             NamespaceString ns)    : _ns(std::move(ns)), _rollbackIdAtInit(repl::ReplicationProcess::get(opCtx)->getRollbackID()) {    // Exclude entries for transaction.    Query query;    // Sort is not needed for correctness. This is just for making it easier to write deterministic    // tests.    query.sort(BSON("_id" << 1));    DBDirectClient client(opCtx);    auto cursor = client.query(NamespaceString::kSessionTransactionsTableNamespace, query);    while (cursor->more()) {        auto nextSession = SessionTxnRecord::parse(            IDLParserErrorContext("Session migration cloning"), cursor->next());        if (!nextSession.getLastWriteOpTime().isNull()) {            _sessionOplogIterators.push_back(                stdx::make_unique<SessionOplogIterator>(std::move(nextSession), _rollbackIdAtInit));        }    }    {        AutoGetCollection autoColl(opCtx, NamespaceString::kRsOplogNamespace, MODE_IX);        writeConflictRetry(            opCtx,            "session migration initialization majority commit barrier",            NamespaceString::kRsOplogNamespace.ns(),            [&] {                const auto message = BSON("sessionMigrateCloneStart" << _ns.ns());                WriteUnitOfWork wuow(opCtx);                opCtx->getClient()->getServiceContext()->getOpObserver()->onInternalOpMessage(                    opCtx, _ns, {}, {}, message);                wuow.commit();            });    }    auto opTimeToWait = repl::ReplClientInfo::forClient(opCtx->getClient()).getLastOp();    WriteConcernResult result;    WriteConcernOptions majority(        WriteConcernOptions::kMajority, WriteConcernOptions::SyncMode::UNSET, 0);    uassertStatusOK(waitForWriteConcern(opCtx, opTimeToWait, majority, &result));}
开发者ID:mongodb,项目名称:mongo,代码行数:43,


示例25: createOplog

Status ReplicationCoordinatorExternalStateImpl::initializeReplSetStorage(OperationContext* txn,                                                                         const BSONObj& config,                                                                         bool updateReplOpTime) {    try {        createOplog(txn, rsOplogName, true);        MONGO_WRITE_CONFLICT_RETRY_LOOP_BEGIN {            ScopedTransaction scopedXact(txn, MODE_X);            Lock::GlobalWrite globalWrite(txn->lockState());            WriteUnitOfWork wuow(txn);            Helpers::putSingleton(txn, configCollectionName, config);            const auto msgObj = BSON("msg"                                     << "initiating set");            if (updateReplOpTime) {                getGlobalServiceContext()->getOpObserver()->onOpMessage(txn, msgObj);            } else {                // 'updateReplOpTime' is false when called from the replSetInitiate command when the                // server is running with replication disabled. We bypass onOpMessage to invoke                // _logOp directly so that we can override the replication mode and keep _logO from                // updating the replication coordinator's op time (illegal operation when                // replication is not enabled).                repl::oplogCheckCloseDatabase(txn, nullptr);                repl::_logOp(txn,                             "n",                             "",                             msgObj,                             nullptr,                             false,                             rsOplogName,                             ReplicationCoordinator::modeReplSet,                             updateReplOpTime);                repl::oplogCheckCloseDatabase(txn, nullptr);            }            wuow.commit();        }        MONGO_WRITE_CONFLICT_RETRY_LOOP_END(txn, "initiate oplog entry", "local.oplog.rs");    } catch (const DBException& ex) {        return ex.toStatus();    }    return Status::OK();}
开发者ID:DCEngines,项目名称:mongo,代码行数:42,


示例26: handleSERVER23299ForDb

void handleSERVER23299ForDb(OperationContext* txn, Database* db) {    log() << "Scanning " << db->name() << " db for SERVER-23299 eligibility";    const auto dbEntry = db->getDatabaseCatalogEntry();    list<string> collNames;    dbEntry->getCollectionNamespaces(&collNames);    for (const auto& collName : collNames) {        const auto collEntry = dbEntry->getCollectionCatalogEntry(collName);        const auto collOptions = collEntry->getCollectionOptions(txn);        if (!collOptions.temp)            continue;        log() << "Marking collection " << collName << " as permanent per SERVER-23299";        MONGO_WRITE_CONFLICT_RETRY_LOOP_BEGIN {            WriteUnitOfWork wuow(txn);            collEntry->clearTempFlag(txn);            wuow.commit();        }        MONGO_WRITE_CONFLICT_RETRY_LOOP_END(txn, "repair SERVER-23299", collEntry->ns().ns());    }    log() << "Done scanning " << db->name() << " for SERVER-23299 eligibility";}
开发者ID:judahschvimer,项目名称:mongo,代码行数:20,



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


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