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


C++ BSONObjSet::count方法代码示例

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


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

示例1: fetch

// static
bool WorkingSetCommon::fetch(OperationContext* txn,
                             WorkingSet* workingSet,
                             WorkingSetID id,
                             unowned_ptr<SeekableRecordCursor> cursor) {
    WorkingSetMember* member = workingSet->get(id);

    // The RecordFetcher should already have been transferred out of the WSM and used.
    invariant(!member->hasFetcher());

    // We should have a RecordId but need to retrieve the obj. Get the obj now and reset all WSM
    // state appropriately.
    invariant(member->hasRecordId());

    member->obj.reset();
    auto record = cursor->seekExact(member->recordId);
    if (!record) {
        return false;
    }

    member->obj = {txn->recoveryUnit()->getSnapshotId(), record->data.releaseToBson()};

    if (member->isSuspicious) {
        // Make sure that all of the keyData is still valid for this copy of the document.
        // This ensures both that index-provided filters and sort orders still hold.
        // TODO provide a way for the query planner to opt out of this checking if it is
        // unneeded due to the structure of the plan.
        invariant(!member->keyData.empty());
        for (size_t i = 0; i < member->keyData.size(); i++) {
            BSONObjSet keys;
            // There's no need to compute the prefixes of the indexed fields that cause the index to
            // be multikey when ensuring the keyData is still valid.
            MultikeyPaths* multikeyPaths = nullptr;
            member->keyData[i].index->getKeys(member->obj.value(), &keys, multikeyPaths);
            if (!keys.count(member->keyData[i].keyData)) {
                // document would no longer be at this position in the index.
                return false;
            }
        }

        member->isSuspicious = false;
    }

    member->keyData.clear();
    workingSet->transitionToRecordIdAndObj(id);
    return true;
}
开发者ID:AshishSanju,项目名称:mongo,代码行数:47,代码来源:working_set_common.cpp

示例2: fetch

    // static
    bool WorkingSetCommon::fetch(OperationContext* txn,
                                 WorkingSetMember* member,
                                 unowned_ptr<RecordCursor> cursor) {
        // The RecordFetcher should already have been transferred out of the WSM and used.
        invariant(!member->hasFetcher());

        // We should have a RecordId but need to retrieve the obj. Get the obj now and reset all WSM
        // state appropriately.
        invariant(member->hasLoc());

        member->obj.reset();
        auto record = cursor->seekExact(member->loc);
        if (!record) {
            return false;
        }

        member->obj = {txn->recoveryUnit()->getSnapshotId(), record->data.releaseToBson()};

        if (member->isSuspicious) {
            // Make sure that all of the keyData is still valid for this copy of the document.
            // This ensures both that index-provided filters and sort orders still hold.
            // TODO provide a way for the query planner to opt out of this checking if it is
            // unneeded due to the structure of the plan.
            invariant(!member->keyData.empty());
            for (size_t i = 0; i < member->keyData.size(); i++) {
                BSONObjSet keys;
                member->keyData[i].index->getKeys(member->obj.value(), &keys);
                if (!keys.count(member->keyData[i].keyData)) {
                    // document would no longer be at this position in the index.
                    return false;
                }
            }

            member->isSuspicious = false;
        }

        member->keyData.clear();
        member->state = WorkingSetMember::LOC_AND_UNOWNED_OBJ;
        return true;
    }
开发者ID:Amosvista,项目名称:mongo,代码行数:41,代码来源:working_set_common.cpp


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