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


C++ StatusWithMatchExpression::getStatus方法代码示例

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


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

示例1: run

    void run() {
        // Rewrite (AND (OR a b) e) => (OR (AND a e) (AND b e))
        {
            BSONObj queryObj = fromjson("{$or:[{a:1}, {b:1}], e:1}");
            const CollatorInterface* collator = nullptr;
            StatusWithMatchExpression expr = MatchExpressionParser::parse(
                queryObj, ExtensionsCallbackDisallowExtensions(), collator);
            ASSERT_OK(expr.getStatus());
            std::unique_ptr<MatchExpression> rewrittenExpr =
                SubplanStage::rewriteToRootedOr(std::move(expr.getValue()));

            std::string findCmdRewritten =
                "{find: 'testns',"
                "filter: {$or:[{a:1,e:1}, {b:1,e:1}]}}";
            std::unique_ptr<CanonicalQuery> cqRewritten = cqFromFindCommand(findCmdRewritten);

            ASSERT(rewrittenExpr->equivalent(cqRewritten->root()));
        }

        // Rewrite (AND (OR a b) e f) => (OR (AND a e f) (AND b e f))
        {
            BSONObj queryObj = fromjson("{$or:[{a:1}, {b:1}], e:1, f:1}");
            const CollatorInterface* collator = nullptr;
            StatusWithMatchExpression expr = MatchExpressionParser::parse(
                queryObj, ExtensionsCallbackDisallowExtensions(), collator);
            ASSERT_OK(expr.getStatus());
            std::unique_ptr<MatchExpression> rewrittenExpr =
                SubplanStage::rewriteToRootedOr(std::move(expr.getValue()));

            std::string findCmdRewritten =
                "{find: 'testns',"
                "filter: {$or:[{a:1,e:1,f:1}, {b:1,e:1,f:1}]}}";
            std::unique_ptr<CanonicalQuery> cqRewritten = cqFromFindCommand(findCmdRewritten);

            ASSERT(rewrittenExpr->equivalent(cqRewritten->root()));
        }

        // Rewrite (AND (OR (AND a b) (AND c d) e f) => (OR (AND a b e f) (AND c d e f))
        {
            BSONObj queryObj = fromjson("{$or:[{a:1,b:1}, {c:1,d:1}], e:1,f:1}");
            const CollatorInterface* collator = nullptr;
            StatusWithMatchExpression expr = MatchExpressionParser::parse(
                queryObj, ExtensionsCallbackDisallowExtensions(), collator);
            ASSERT_OK(expr.getStatus());
            std::unique_ptr<MatchExpression> rewrittenExpr =
                SubplanStage::rewriteToRootedOr(std::move(expr.getValue()));

            std::string findCmdRewritten =
                "{find: 'testns',"
                "filter: {$or:[{a:1,b:1,e:1,f:1},"
                "{c:1,d:1,e:1,f:1}]}}";
            std::unique_ptr<CanonicalQuery> cqRewritten = cqFromFindCommand(findCmdRewritten);

            ASSERT(rewrittenExpr->equivalent(cqRewritten->root()));
        }
    }
开发者ID:AshishSanju,项目名称:mongo,代码行数:56,代码来源:query_stage_subplan.cpp

示例2: init

void IndexCatalogEntry::init(OperationContext* txn, IndexAccessMethod* accessMethod) {
    verify(_accessMethod == NULL);
    _accessMethod = accessMethod;

    _isReady = _catalogIsReady(txn);
    _head = _catalogHead(txn);
    _isMultikey = _catalogIsMultikey(txn);

    if (BSONElement filterElement = _descriptor->getInfoElement("partialFilterExpression")) {
        invariant(filterElement.isABSONObj());
        BSONObj filter = filterElement.Obj();
        // TODO SERVER-23618: pass the appropriate CollatorInterface* instead of nullptr.
        StatusWithMatchExpression statusWithMatcher =
            MatchExpressionParser::parse(filter, ExtensionsCallbackDisallowExtensions(), nullptr);
        // this should be checked in create, so can blow up here
        invariantOK(statusWithMatcher.getStatus());
        _filterExpression = std::move(statusWithMatcher.getValue());
        LOG(2) << "have filter expression for " << _ns << " " << _descriptor->indexName() << " "
               << filter;
    }

    if (BSONElement collationElement = _descriptor->getInfoElement("collation")) {
        invariant(collationElement.isABSONObj());
        BSONObj collation = collationElement.Obj();
        auto statusWithCollator =
            CollatorFactoryInterface::get(txn->getServiceContext())->makeFromBSON(collation);
        invariantOK(statusWithCollator.getStatus());
        _collator = std::move(statusWithCollator.getValue());
    }
}
开发者ID:GodotGo,项目名称:mongo,代码行数:30,代码来源:index_catalog_entry.cpp

示例3: _queryVector

    Status AuthzManagerExternalStateMock::_queryVector(
            const NamespaceString& collectionName,
            const BSONObj& query,
            std::vector<BSONObjCollection::iterator>* result) {

        StatusWithMatchExpression parseResult = MatchExpressionParser::parse(query);
        if (!parseResult.isOK()) {
            return parseResult.getStatus();
        }
        MatchExpression* matcher = parseResult.getValue();

        NamespaceDocumentMap::iterator mapIt = _documents.find(collectionName);
        if (mapIt == _documents.end())
            return Status(ErrorCodes::NoMatchingDocument,
                          "No collection named " + collectionName.ns());

        for (BSONObjCollection::iterator vecIt = mapIt->second.begin();
             vecIt != mapIt->second.end();
             ++vecIt) {

            if (matcher->matchesBSON(*vecIt)) {
                result->push_back(vecIt);
            }
        }
        return Status::OK();
    }
开发者ID:bladepan,项目名称:mongo,代码行数:26,代码来源:authz_manager_external_state_mock.cpp

示例4: init

    Status CanonicalQuery::init(LiteParsedQuery* lpq) {
        _pq.reset(lpq);

        // Build a parse tree from the BSONObj in the parsed query.
        StatusWithMatchExpression swme = MatchExpressionParser::parse(_pq->getFilter());
        if (!swme.isOK()) { return swme.getStatus(); }

        MatchExpression* root = swme.getValue();
        root = normalizeTree(root);
        Status validStatus = isValid(root);
        if (!validStatus.isOK()) {
            return validStatus;
        }

        _root.reset(root);

        if (!_pq->getProj().isEmpty()) {
            LiteProjection* liteProj = NULL;
            Status liteProjStatus = LiteProjection::make(_pq->getFilter(), _pq->getProj(), &liteProj);
            if (!liteProjStatus.isOK()) {
                return liteProjStatus;
            }
            _liteProj.reset(liteProj);
        }

        return Status::OK();
    }
开发者ID:Convey-Compliance,项目名称:mongo,代码行数:27,代码来源:canonical_query.cpp

示例5: init

Status ModifierPull::init(const BSONElement& modExpr, const Options& opts, bool* positional) {
    // Perform standard field name and updateable checks.
    _fieldRef.parse(modExpr.fieldName());
    Status status = fieldchecker::isUpdatable(_fieldRef);
    if (!status.isOK()) {
        return status;
    }

    // If a $-positional operator was used, get the index in which it occurred
    // and ensure only one occurrence.
    size_t foundCount;
    bool foundDollar = fieldchecker::isPositional(_fieldRef, &_posDollar, &foundCount);

    if (positional)
        *positional = foundDollar;

    if (foundDollar && foundCount > 1) {
        return Status(ErrorCodes::BadValue,
                      str::stream() << "Too many positional (i.e. '$') elements found in path '"
                                    << _fieldRef.dottedField()
                                    << "'");
    }

    _exprElt = modExpr;

    _collator = opts.collator;

    // If the element in the mod is actually an object or a regular expression, we need to
    // build a matcher, instead of just doing an equality comparision.
    if ((_exprElt.type() == mongo::Object) || (_exprElt.type() == mongo::RegEx)) {
        if (_exprElt.type() == Object) {
            _exprObj = _exprElt.embeddedObject();

            // If not is not a query operator, then it is a primitive.
            _matcherOnPrimitive = (MatchExpressionParser::parsePathAcceptingKeyword(
                                       _exprObj.firstElement(), PathAcceptingKeyword::EQUALITY) !=
                                   PathAcceptingKeyword::EQUALITY);

            // If the object is primitive then wrap it up into an object.
            if (_matcherOnPrimitive)
                _exprObj = BSON("" << _exprObj);
        } else {
            // For a regex, we also need to wrap and treat like a primitive.
            _matcherOnPrimitive = true;
            _exprObj = _exprElt.wrap("");
        }

        // Build the matcher around the object we built above. Currently, we do not allow $pull
        // operations to contain $text/$where clauses, so preserving this behaviour.
        StatusWithMatchExpression parseResult = MatchExpressionParser::parse(
            _exprObj, ExtensionsCallbackDisallowExtensions(), _collator);
        if (!parseResult.isOK()) {
            return parseResult.getStatus();
        }

        _matchExpr = std::move(parseResult.getValue());
    }

    return Status::OK();
}
开发者ID:mpobrien,项目名称:mongo,代码行数:60,代码来源:modifier_pull.cpp

示例6: init

    Status CanonicalQuery::init(LiteParsedQuery* lpq) {
        _pq.reset(lpq);

        // Build a parse tree from the BSONObj in the parsed query.
        StatusWithMatchExpression swme = MatchExpressionParser::parse(_pq->getFilter());
        if (!swme.isOK()) { return swme.getStatus(); }

        MatchExpression* root = swme.getValue();
        Status validStatus = this->normalize(root);
        if (!validStatus.isOK()) {
            return validStatus;
        }
        this->generateCacheKey();

        // Validate the projection if there is one.
        if (!_pq->getProj().isEmpty()) {
            ParsedProjection* pp;
            Status projStatus = ParsedProjection::make(_pq->getProj(), root, &pp);
            if (!projStatus.isOK()) {
                return projStatus;
            }
            _proj.reset(pp);
        }

        return Status::OK();
    }
开发者ID:dreamquster,项目名称:mongo,代码行数:26,代码来源:canonical_query.cpp

示例7: init

    Status ModifierPull::init(const BSONElement& modExpr, const Options& opts) {
        // Perform standard field name and updateable checks.
        _fieldRef.parse(modExpr.fieldName());
        Status status = fieldchecker::isUpdatable(_fieldRef);
        if (! status.isOK()) {
            return status;
        }

        // If a $-positional operator was used, get the index in which it occurred
        // and ensure only one occurrence.
        size_t foundCount;
        bool foundDollar = fieldchecker::isPositional(_fieldRef, &_posDollar, &foundCount);
        if (foundDollar && foundCount > 1) {
            return Status(ErrorCodes::BadValue, "too many positional($) elements found.");
        }

        _exprElt = modExpr;
        if (_exprElt.type() == Object) {

            _exprObj = _exprElt.embeddedObject();
            _matcherOnPrimitive = (_exprObj.firstElement().getGtLtOp() != 0);
            if (_matcherOnPrimitive)
                _exprObj = BSON( "" << _exprObj );

            StatusWithMatchExpression parseResult = MatchExpressionParser::parse(_exprObj);
            if (!parseResult.isOK())
                return parseResult.getStatus();

            _matchExpr.reset(parseResult.getValue());
        }

        return Status::OK();
    }
开发者ID:ChowZenki,项目名称:mongo,代码行数:33,代码来源:modifier_pull.cpp

示例8: _queryVector

Status AuthzManagerExternalStateMock::_queryVector(
    OperationContext* opCtx,
    const NamespaceString& collectionName,
    const BSONObj& query,
    std::vector<BSONObjCollection::iterator>* result) {
    const CollatorInterface* collator = nullptr;
    boost::intrusive_ptr<ExpressionContext> expCtx(new ExpressionContext(opCtx, collator));
    StatusWithMatchExpression parseResult = MatchExpressionParser::parse(query, std::move(expCtx));
    if (!parseResult.isOK()) {
        return parseResult.getStatus();
    }
    const std::unique_ptr<MatchExpression> matcher = std::move(parseResult.getValue());

    NamespaceDocumentMap::iterator mapIt = _documents.find(collectionName);
    if (mapIt == _documents.end())
        return Status::OK();

    for (BSONObjCollection::iterator vecIt = mapIt->second.begin(); vecIt != mapIt->second.end();
         ++vecIt) {
        if (matcher->matchesBSON(*vecIt)) {
            result->push_back(vecIt);
        }
    }
    return Status::OK();
}
开发者ID:ShaneHarvey,项目名称:mongo,代码行数:25,代码来源:authz_manager_external_state_mock.cpp

示例9: _queryVector

    Status AuthzManagerExternalStateMock::_queryVector(
            const NamespaceString& collectionName,
            const BSONObj& query,
            std::vector<BSONObjCollection::iterator>* result) {

        StatusWithMatchExpression parseResult = 
                MatchExpressionParser::parse(query, MatchExpressionParser::WhereCallback());
        if (!parseResult.isOK()) {
            return parseResult.getStatus();
        }
        const boost::scoped_ptr<MatchExpression> matcher(parseResult.getValue());

        NamespaceDocumentMap::iterator mapIt = _documents.find(collectionName);
        if (mapIt == _documents.end())
            return Status::OK();

        for (BSONObjCollection::iterator vecIt = mapIt->second.begin();
             vecIt != mapIt->second.end();
             ++vecIt) {

            if (matcher->matchesBSON(*vecIt)) {
                result->push_back(vecIt);
            }
        }
        return Status::OK();
    }
开发者ID:ambroff,项目名称:mongo,代码行数:26,代码来源:authz_manager_external_state_mock.cpp

示例10: init

    Status CanonicalQuery::init(LiteParsedQuery* lpq) {
        _pq.reset(lpq);

        // Build a parse tree from the BSONObj in the parsed query.
        StatusWithMatchExpression swme = MatchExpressionParser::parse(_pq->getFilter());
        if (!swme.isOK()) { return swme.getStatus(); }

        MatchExpression* root = swme.getValue();
        root = normalizeTree(root);
        Status validStatus = isValid(root);
        if (!validStatus.isOK()) {
            return validStatus;
        }

        _root.reset(root);

        if (!_pq->getProj().isEmpty()) {
            ParsedProjection* proj;
            Status projStatus = ProjectionParser::parseFindSyntax(_pq->getProj(), &proj);
            if (!projStatus.isOK()) {
                return projStatus;
            }
            _proj.reset(proj);
        }

        return Status::OK();
    }
开发者ID:ashleybrener,项目名称:mongo,代码行数:27,代码来源:canonical_query.cpp

示例11: run

        bool run(OperationContext* txn,
                 const string& dbname,
                 BSONObj& jsobj,
                 int,
                 string& errmsg,
                 BSONObjBuilder& result,
                 bool /*fromRepl*/) {

            ScopedTransaction scopedXact(txn, MODE_IS);
            AutoGetDb autoDb(txn, dbname, MODE_S);

            const Database* d = autoDb.getDb();
            const DatabaseCatalogEntry* dbEntry = NULL;

            list<string> names;
            if ( d ) {
                dbEntry = d->getDatabaseCatalogEntry();
                dbEntry->getCollectionNamespaces( &names );
                names.sort();
            }

            scoped_ptr<MatchExpression> matcher;
            if ( jsobj["filter"].isABSONObj() ) {
                StatusWithMatchExpression parsed =
                    MatchExpressionParser::parse( jsobj["filter"].Obj() );
                if ( !parsed.isOK() ) {
                    return appendCommandStatus( result, parsed.getStatus() );
                }
                matcher.reset( parsed.getValue() );
            }

            BSONArrayBuilder arr;

            for ( list<string>::const_iterator i = names.begin(); i != names.end(); ++i ) {
                string ns = *i;

                StringData collection = nsToCollectionSubstring( ns );
                if ( collection == "system.namespaces" ) {
                    continue;
                }

                BSONObjBuilder b;
                b.append( "name", collection );

                CollectionOptions options =
                    dbEntry->getCollectionCatalogEntry( txn, ns )->getCollectionOptions(txn);
                b.append( "options", options.toBSON() );

                BSONObj maybe = b.obj();
                if ( matcher && !matcher->matchesBSON( maybe ) ) {
                    continue;
                }

                arr.append( maybe );
            }

            result.append( "collections", arr.arr() );

            return true;
        }
开发者ID:Dependencies,项目名称:mongo,代码行数:60,代码来源:list_collections.cpp

示例12: move

std::unique_ptr<MatchExpression> QueryPlannerTest::parseMatchExpression(const BSONObj& obj) {
    StatusWithMatchExpression status =
        MatchExpressionParser::parse(obj, ExtensionsCallbackDisallowExtensions());
    if (!status.isOK()) {
        FAIL(str::stream() << "failed to parse query: " << obj.toString()
                           << ". Reason: " << status.getStatus().toString());
    }
    return std::move(status.getValue());
}
开发者ID:amidvidy,项目名称:mongo,代码行数:9,代码来源:query_planner_test_fixture.cpp

示例13: init

    Status CanonicalQuery::init(LiteParsedQuery* lpq) {
        _pq.reset(lpq);

        // Build a parse tree from the BSONObj in the parsed query.
        StatusWithMatchExpression swme = MatchExpressionParser::parse(_pq->getFilter());
        if (!swme.isOK()) { return swme.getStatus(); }

        _root.reset(swme.getValue());
        return Status::OK();
    }
开发者ID:Axv2,项目名称:mongo,代码行数:10,代码来源:canonical_query.cpp

示例14: move

std::unique_ptr<MatchExpression> QueryPlannerTest::parseMatchExpression(
    const BSONObj& obj, const CollatorInterface* collator) {
    boost::intrusive_ptr<ExpressionContextForTest> expCtx(new ExpressionContextForTest());
    expCtx->setCollator(collator);
    StatusWithMatchExpression status = MatchExpressionParser::parse(obj, std::move(expCtx));
    if (!status.isOK()) {
        FAIL(str::stream() << "failed to parse query: " << obj.toString() << ". Reason: "
                           << status.getStatus().toString());
    }
    return std::move(status.getValue());
}
开发者ID:i80and,项目名称:mongo,代码行数:11,代码来源:query_planner_test_fixture.cpp

示例15: uassert

Matcher::Matcher(const BSONObj& pattern,
                 const boost::intrusive_ptr<ExpressionContext>& expCtx,
                 const ExtensionsCallback& extensionsCallback,
                 const MatchExpressionParser::AllowedFeatureSet allowedFeatures)
    : _pattern(pattern) {
    StatusWithMatchExpression statusWithMatcher =
        MatchExpressionParser::parse(pattern, expCtx, extensionsCallback, allowedFeatures);
    uassert(16810,
            mongoutils::str::stream() << "bad query: " << statusWithMatcher.getStatus().toString(),
            statusWithMatcher.isOK());

    _expression = std::move(statusWithMatcher.getValue());
}
开发者ID:i80and,项目名称:mongo,代码行数:13,代码来源:matcher.cpp


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