diff options
Diffstat (limited to 'src/mongo/db/matcher/expression_parser.cpp')
-rw-r--r-- | src/mongo/db/matcher/expression_parser.cpp | 114 |
1 files changed, 57 insertions, 57 deletions
diff --git a/src/mongo/db/matcher/expression_parser.cpp b/src/mongo/db/matcher/expression_parser.cpp index e65d6885227..c92ae07f18a 100644 --- a/src/mongo/db/matcher/expression_parser.cpp +++ b/src/mongo/db/matcher/expression_parser.cpp @@ -31,6 +31,7 @@ #include "mongo/db/matcher/expression_parser.h" +#include <memory> #include <pcrecpp.h> #include "mongo/base/init.h" @@ -65,7 +66,6 @@ #include "mongo/db/matcher/schema/json_schema_parser.h" #include "mongo/db/namespace_string.h" #include "mongo/db/query/query_knobs_gen.h" -#include "mongo/stdx/memory.h" #include "mongo/util/str.h" #include "mongo/util/string_map.h" @@ -139,7 +139,7 @@ StatusWithMatchExpression parseRegexElement(StringData name, BSONElement e) { if (e.type() != BSONType::RegEx) return {Status(ErrorCodes::BadValue, "not a regex")}; - return {stdx::make_unique<RegexMatchExpression>(name, e.regex(), e.regexFlags())}; + return {std::make_unique<RegexMatchExpression>(name, e.regex(), e.regexFlags())}; } StatusWithMatchExpression parseComparison( @@ -242,7 +242,7 @@ StatusWithMatchExpression parse(const BSONObj& obj, const ExtensionsCallback* extensionsCallback, MatchExpressionParser::AllowedFeatureSet allowedFeatures, DocumentParseLevel currentLevel) { - auto root = stdx::make_unique<AndMatchExpression>(); + auto root = std::make_unique<AndMatchExpression>(); const DocumentParseLevel nextLevel = (currentLevel == DocumentParseLevel::kPredicateTopLevel) ? DocumentParseLevel::kUserDocumentTopLevel @@ -300,7 +300,7 @@ StatusWithMatchExpression parse(const BSONObj& obj, auto eq = parseComparison(e.fieldNameStringData(), - stdx::make_unique<EqualityMatchExpression>(e.fieldNameStringData(), e), + std::make_unique<EqualityMatchExpression>(e.fieldNameStringData(), e), e, expCtx, allowedFeatures); @@ -365,7 +365,7 @@ StatusWithMatchExpression parseDBRef(StringData name, const ExtensionsCallback* extensionsCallback, MatchExpressionParser::AllowedFeatureSet allowedFeatures, DocumentParseLevel currentLevel) { - auto eq = stdx::make_unique<EqualityMatchExpression>(elem.fieldName(), elem); + auto eq = std::make_unique<EqualityMatchExpression>(elem.fieldName(), elem); // 'id' is collation-aware. 'ref' and 'db' are compared using binary comparison. eq->setCollator("id"_sd == name ? expCtx->getCollator() : nullptr); @@ -410,7 +410,7 @@ StatusWithMatchExpression parseAlwaysBoolean( str::stream() << T::kName << " must be an integer value of 1")}; } - return {stdx::make_unique<T>()}; + return {std::make_unique<T>()}; } StatusWithMatchExpression parseExpr(StringData name, @@ -428,7 +428,7 @@ StatusWithMatchExpression parseExpr(StringData name, return {Status(ErrorCodes::QueryFeatureNotAllowed, "$expr is not allowed in this context")}; } - return {stdx::make_unique<ExprMatchExpression>(std::move(elem), expCtx)}; + return {std::make_unique<ExprMatchExpression>(std::move(elem), expCtx)}; } StatusWithMatchExpression parseMOD(StringData name, BSONElement e) { @@ -452,7 +452,7 @@ StatusWithMatchExpression parseMOD(StringData name, BSONElement e) { if (i.more()) return {Status(ErrorCodes::BadValue, "malformed mod, too many elements")}; - return {stdx::make_unique<ModMatchExpression>(name, d.numberInt(), r.numberInt())}; + return {std::make_unique<ModMatchExpression>(name, d.numberInt(), r.numberInt())}; } StatusWithMatchExpression parseRegexDocument(StringData name, const BSONObj& doc) { @@ -500,7 +500,7 @@ StatusWithMatchExpression parseRegexDocument(StringData name, const BSONObj& doc } } - return {stdx::make_unique<RegexMatchExpression>(name, regex, regexOptions)}; + return {std::make_unique<RegexMatchExpression>(name, regex, regexOptions)}; } Status parseInExpression(InMatchExpression* inExpression, @@ -515,7 +515,7 @@ Status parseInExpression(InMatchExpression* inExpression, } if (e.type() == BSONType::RegEx) { - auto status = inExpression->addRegex(stdx::make_unique<RegexMatchExpression>(""_sd, e)); + auto status = inExpression->addRegex(std::make_unique<RegexMatchExpression>(""_sd, e)); if (!status.isOK()) { return status; } @@ -538,7 +538,7 @@ StatusWithMatchExpression parseType(StringData name, BSONElement elt) { str::stream() << name << " must match at least one type")}; } - return {stdx::make_unique<T>(name, std::move(typeSet.getValue()))}; + return {std::make_unique<T>(name, std::move(typeSet.getValue()))}; } /** @@ -621,19 +621,19 @@ StatusWithMatchExpression parseBitTest(StringData name, BSONElement e) { if (!bitPositions.isOK()) { return bitPositions.getStatus(); } - bitTestMatchExpression = stdx::make_unique<T>(name, std::move(bitPositions.getValue())); + bitTestMatchExpression = std::make_unique<T>(name, std::move(bitPositions.getValue())); } else if (e.isNumber()) { // Integer bitmask provided as value. auto bitMask = e.parseIntegerElementToNonNegativeLong(); if (!bitMask.isOK()) { return bitMask.getStatus(); } - bitTestMatchExpression = stdx::make_unique<T>(name, bitMask.getValue()); + bitTestMatchExpression = std::make_unique<T>(name, bitMask.getValue()); } else if (e.type() == BSONType::BinData) { // Binary bitmask provided as value. int eBinaryLen; auto eBinary = e.binData(eBinaryLen); - bitTestMatchExpression = stdx::make_unique<T>(name, eBinary, eBinaryLen); + bitTestMatchExpression = std::make_unique<T>(name, eBinary, eBinaryLen); } else { return Status( ErrorCodes::BadValue, @@ -672,7 +672,7 @@ StatusWithMatchExpression parseInternalSchemaFmod(StringData name, BSONElement e return {ErrorCodes::BadValue, str::stream() << path << " has too many elements"}; } - return {stdx::make_unique<InternalSchemaFmodMatchExpression>( + return {std::make_unique<InternalSchemaFmodMatchExpression>( name, d.numberDecimal(), r.numberDecimal())}; } @@ -696,7 +696,7 @@ StatusWithMatchExpression parseInternalSchemaRootDocEq( << elem.type())}; } auto rootDocEq = - stdx::make_unique<InternalSchemaRootDocEqMatchExpression>(elem.embeddedObject()); + std::make_unique<InternalSchemaRootDocEqMatchExpression>(elem.embeddedObject()); return {std::move(rootDocEq)}; } @@ -712,7 +712,7 @@ StatusWithMatchExpression parseInternalSchemaSingleIntegerArgument(StringData na return parsedInt.getStatus(); } - return {stdx::make_unique<T>(name, parsedInt.getValue())}; + return {std::make_unique<T>(name, parsedInt.getValue())}; } /** @@ -731,7 +731,7 @@ StatusWithMatchExpression parseTopLevelInternalSchemaSingleIntegerArgument( if (!parsedInt.isOK()) { return parsedInt.getStatus(); } - return {stdx::make_unique<T>(parsedInt.getValue())}; + return {std::make_unique<T>(parsedInt.getValue())}; } /** @@ -969,7 +969,7 @@ StatusWithMatchExpression parseInternalSchemaAllowedProperties( return properties.getStatus(); } - return {stdx::make_unique<InternalSchemaAllowedPropertiesMatchExpression>( + return {std::make_unique<InternalSchemaAllowedPropertiesMatchExpression>( std::move(properties.getValue()), namePlaceholder.getValue(), std::move(patternProperties.getValue()), @@ -1024,7 +1024,7 @@ StatusWithMatchExpression parseInternalSchemaMatchArrayIndex( return expressionWithPlaceholder.getStatus(); } - return {stdx::make_unique<InternalSchemaMatchArrayIndexMatchExpression>( + return {std::make_unique<InternalSchemaMatchArrayIndexMatchExpression>( path, index.getValue(), std::move(expressionWithPlaceholder.getValue()))}; } @@ -1033,12 +1033,12 @@ StatusWithMatchExpression parseGeo(StringData name, const BSONObj& section, MatchExpressionParser::AllowedFeatureSet allowedFeatures) { if (PathAcceptingKeyword::WITHIN == type || PathAcceptingKeyword::GEO_INTERSECTS == type) { - auto gq = stdx::make_unique<GeoExpression>(name.toString()); + auto gq = std::make_unique<GeoExpression>(name.toString()); auto parseStatus = gq->parseFrom(section); if (!parseStatus.isOK()) { return parseStatus; } - return {stdx::make_unique<GeoMatchExpression>(name, gq.release(), section)}; + return {std::make_unique<GeoMatchExpression>(name, gq.release(), section)}; } else { invariant(PathAcceptingKeyword::GEO_NEAR == type); @@ -1047,12 +1047,12 @@ StatusWithMatchExpression parseGeo(StringData name, "$geoNear, $near, and $nearSphere are not allowed in this context")}; } - auto nq = stdx::make_unique<GeoNearExpression>(name.toString()); + auto nq = std::make_unique<GeoNearExpression>(name.toString()); auto status = nq->parseFrom(section); if (!status.isOK()) { return status; } - return {stdx::make_unique<GeoNearMatchExpression>(name, nq.release(), section)}; + return {std::make_unique<GeoNearMatchExpression>(name, nq.release(), section)}; } } @@ -1068,7 +1068,7 @@ StatusWithMatchExpression parseTreeTopLevel( return {Status(ErrorCodes::BadValue, str::stream() << T::kName << " must be an array")}; } - auto temp = stdx::make_unique<T>(); + auto temp = std::make_unique<T>(); auto arr = elem.Obj(); if (arr.isEmpty()) { @@ -1129,7 +1129,7 @@ StatusWithMatchExpression parseElemMatch(StringData name, if (!s.isOK()) return s; - auto temp = stdx::make_unique<ElemMatchValueMatchExpression>(name); + auto temp = std::make_unique<ElemMatchValueMatchExpression>(name); for (size_t i = 0; i < theAnd.numChildren(); i++) { temp->add(theAnd.getChild(i)); @@ -1157,7 +1157,7 @@ StatusWithMatchExpression parseElemMatch(StringData name, return {Status(ErrorCodes::BadValue, "$elemMatch cannot contain $where expression")}; } - return {stdx::make_unique<ElemMatchObjectMatchExpression>(name, sub.release())}; + return {std::make_unique<ElemMatchObjectMatchExpression>(name, sub.release())}; } StatusWithMatchExpression parseAll(StringData name, @@ -1169,7 +1169,7 @@ StatusWithMatchExpression parseAll(StringData name, return {Status(ErrorCodes::BadValue, "$all needs an array")}; auto arr = e.Obj(); - auto myAnd = stdx::make_unique<AndMatchExpression>(); + auto myAnd = std::make_unique<AndMatchExpression>(); BSONObjIterator i(arr); if (arr.firstElement().type() == BSONType::Object && @@ -1207,20 +1207,20 @@ StatusWithMatchExpression parseAll(StringData name, auto e = i.next(); if (e.type() == BSONType::RegEx) { - auto expr = stdx::make_unique<RegexMatchExpression>(name, e); + auto expr = std::make_unique<RegexMatchExpression>(name, e); myAnd->add(expr.release()); } else if (e.type() == BSONType::Object && MatchExpressionParser::parsePathAcceptingKeyword(e.Obj().firstElement())) { return {Status(ErrorCodes::BadValue, "no $ expressions in $all")}; } else { - auto expr = stdx::make_unique<EqualityMatchExpression>(name, e); + auto expr = std::make_unique<EqualityMatchExpression>(name, e); expr->setCollator(expCtx->getCollator()); myAnd->add(expr.release()); } } if (myAnd->numChildren() == 0) { - return {stdx::make_unique<AlwaysFalseMatchExpression>()}; + return {std::make_unique<AlwaysFalseMatchExpression>()}; } return {std::move(myAnd)}; @@ -1274,7 +1274,7 @@ StatusWithMatchExpression parseInternalSchemaFixedArityArgument( ++position; } - return {stdx::make_unique<T>(std::move(expressions))}; + return {std::make_unique<T>(std::move(expressions))}; } StatusWithMatchExpression parseNot(StringData name, @@ -1288,7 +1288,7 @@ StatusWithMatchExpression parseNot(StringData name, if (!regex.isOK()) { return regex; } - return {stdx::make_unique<NotMatchExpression>(regex.getValue().release())}; + return {std::make_unique<NotMatchExpression>(regex.getValue().release())}; } if (elem.type() != BSONType::Object) { @@ -1300,14 +1300,14 @@ StatusWithMatchExpression parseNot(StringData name, return {ErrorCodes::BadValue, "$not cannot be empty"}; } - auto theAnd = stdx::make_unique<AndMatchExpression>(); + auto theAnd = std::make_unique<AndMatchExpression>(); auto parseStatus = parseSub( name, notObject, theAnd.get(), expCtx, extensionsCallback, allowedFeatures, currentLevel); if (!parseStatus.isOK()) { return parseStatus; } - return {stdx::make_unique<NotMatchExpression>(theAnd.release())}; + return {std::make_unique<NotMatchExpression>(theAnd.release())}; } StatusWithMatchExpression parseInternalSchemaBinDataSubType(StringData name, BSONElement e) { @@ -1333,7 +1333,7 @@ StatusWithMatchExpression parseInternalSchemaBinDataSubType(StringData name, BSO << valueAsInt.getValue()); } - return {stdx::make_unique<InternalSchemaBinDataSubTypeExpression>( + return {std::make_unique<InternalSchemaBinDataSubTypeExpression>( name, static_cast<BinDataType>(valueAsInt.getValue()))}; } @@ -1354,7 +1354,7 @@ StatusWithMatchExpression parseSubField(const BSONObj& context, if ("$eq"_sd == e.fieldNameStringData()) { return parseComparison( - name, stdx::make_unique<EqualityMatchExpression>(name, e), e, expCtx, allowedFeatures); + name, std::make_unique<EqualityMatchExpression>(name, e), e, expCtx, allowedFeatures); } if ("$not"_sd == e.fieldNameStringData()) { @@ -1375,16 +1375,16 @@ StatusWithMatchExpression parseSubField(const BSONObj& context, switch (*parseExpMatchType) { case PathAcceptingKeyword::LESS_THAN: return parseComparison( - name, stdx::make_unique<LTMatchExpression>(name, e), e, expCtx, allowedFeatures); + name, std::make_unique<LTMatchExpression>(name, e), e, expCtx, allowedFeatures); case PathAcceptingKeyword::LESS_THAN_OR_EQUAL: return parseComparison( - name, stdx::make_unique<LTEMatchExpression>(name, e), e, expCtx, allowedFeatures); + name, std::make_unique<LTEMatchExpression>(name, e), e, expCtx, allowedFeatures); case PathAcceptingKeyword::GREATER_THAN: return parseComparison( - name, stdx::make_unique<GTMatchExpression>(name, e), e, expCtx, allowedFeatures); + name, std::make_unique<GTMatchExpression>(name, e), e, expCtx, allowedFeatures); case PathAcceptingKeyword::GREATER_THAN_OR_EQUAL: return parseComparison( - name, stdx::make_unique<GTEMatchExpression>(name, e), e, expCtx, allowedFeatures); + name, std::make_unique<GTEMatchExpression>(name, e), e, expCtx, allowedFeatures); case PathAcceptingKeyword::NOT_EQUAL: { if (BSONType::RegEx == e.type()) { // Just because $ne can be rewritten as the negation of an equality does not mean @@ -1393,15 +1393,15 @@ StatusWithMatchExpression parseSubField(const BSONObj& context, } StatusWithMatchExpression s = parseComparison(name, - stdx::make_unique<EqualityMatchExpression>(name, e), + std::make_unique<EqualityMatchExpression>(name, e), e, expCtx, allowedFeatures); - return {stdx::make_unique<NotMatchExpression>(s.getValue().release())}; + return {std::make_unique<NotMatchExpression>(s.getValue().release())}; } case PathAcceptingKeyword::EQUALITY: return parseComparison(name, - stdx::make_unique<EqualityMatchExpression>(name, e), + std::make_unique<EqualityMatchExpression>(name, e), e, expCtx, allowedFeatures); @@ -1410,7 +1410,7 @@ StatusWithMatchExpression parseSubField(const BSONObj& context, if (e.type() != BSONType::Array) { return {Status(ErrorCodes::BadValue, "$in needs an array")}; } - auto temp = stdx::make_unique<InMatchExpression>(name); + auto temp = std::make_unique<InMatchExpression>(name); auto parseStatus = parseInExpression(temp.get(), e.Obj(), expCtx); if (!parseStatus.isOK()) { return parseStatus; @@ -1422,12 +1422,12 @@ StatusWithMatchExpression parseSubField(const BSONObj& context, if (e.type() != Array) { return {Status(ErrorCodes::BadValue, "$nin needs an array")}; } - auto temp = stdx::make_unique<InMatchExpression>(name); + auto temp = std::make_unique<InMatchExpression>(name); auto parseStatus = parseInExpression(temp.get(), e.Obj(), expCtx); if (!parseStatus.isOK()) { return parseStatus; } - return {stdx::make_unique<NotMatchExpression>(temp.release())}; + return {std::make_unique<NotMatchExpression>(temp.release())}; } case PathAcceptingKeyword::SIZE: { @@ -1454,7 +1454,7 @@ StatusWithMatchExpression parseSubField(const BSONObj& context, if (size < 0) { return {Status(ErrorCodes::BadValue, "$size may not be negative")}; } - return {stdx::make_unique<SizeMatchExpression>(name, size)}; + return {std::make_unique<SizeMatchExpression>(name, size)}; } case PathAcceptingKeyword::EXISTS: { @@ -1462,12 +1462,12 @@ StatusWithMatchExpression parseSubField(const BSONObj& context, return {Status(ErrorCodes::BadValue, "$exists can't be eoo")}; } - auto existsExpr = stdx::make_unique<ExistsMatchExpression>(name); + auto existsExpr = std::make_unique<ExistsMatchExpression>(name); if (e.trueValue()) { return {std::move(existsExpr)}; } - return {stdx::make_unique<NotMatchExpression>(existsExpr.release())}; + return {std::make_unique<NotMatchExpression>(existsExpr.release())}; } case PathAcceptingKeyword::TYPE: @@ -1515,7 +1515,7 @@ StatusWithMatchExpression parseSubField(const BSONObj& context, << typeName(e.type()))}; } - auto exprEqExpr = stdx::make_unique<InternalExprEqMatchExpression>(name, e); + auto exprEqExpr = std::make_unique<InternalExprEqMatchExpression>(name, e); exprEqExpr->setCollator(expCtx->getCollator()); return {std::move(exprEqExpr)}; } @@ -1565,7 +1565,7 @@ StatusWithMatchExpression parseSubField(const BSONObj& context, return parsedSubObjExpr; } - return {stdx::make_unique<InternalSchemaObjectMatchExpression>( + return {std::make_unique<InternalSchemaObjectMatchExpression>( name, std::move(parsedSubObjExpr.getValue()))}; } @@ -1575,7 +1575,7 @@ StatusWithMatchExpression parseSubField(const BSONObj& context, str::stream() << name << " must be a boolean of value true"}; } - return {stdx::make_unique<InternalSchemaUniqueItemsMatchExpression>(name)}; + return {std::make_unique<InternalSchemaUniqueItemsMatchExpression>(name)}; } case PathAcceptingKeyword::INTERNAL_SCHEMA_MIN_LENGTH: { @@ -1653,7 +1653,7 @@ StatusWithMatchExpression parseSubField(const BSONObj& context, if (!exprWithPlaceholder.isOK()) { return exprWithPlaceholder.getStatus(); } - return {stdx::make_unique<InternalSchemaAllElemMatchFromIndexMatchExpression>( + return {std::make_unique<InternalSchemaAllElemMatchFromIndexMatchExpression>( name, parsedIndex.getValue(), std::move(exprWithPlaceholder.getValue()))}; } @@ -1662,7 +1662,7 @@ StatusWithMatchExpression parseSubField(const BSONObj& context, } case PathAcceptingKeyword::INTERNAL_SCHEMA_EQ: { - return {stdx::make_unique<InternalSchemaEqMatchExpression>(name, e)}; + return {std::make_unique<InternalSchemaEqMatchExpression>(name, e)}; } case PathAcceptingKeyword::INTERNAL_SCHEMA_BIN_DATA_ENCRYPTED_TYPE: { @@ -1757,7 +1757,7 @@ std::unique_ptr<StringMap< pathlessOperatorMap; MONGO_INITIALIZER(PathlessOperatorMap)(InitializerContext* context) { - pathlessOperatorMap = stdx::make_unique<StringMap< + pathlessOperatorMap = std::make_unique<StringMap< std::function<StatusWithMatchExpression(StringData, BSONElement, const boost::intrusive_ptr<ExpressionContext>&, @@ -1804,7 +1804,7 @@ std::unique_ptr<StringMap<PathAcceptingKeyword>> queryOperatorMap; MONGO_INITIALIZER(MatchExpressionParser)(InitializerContext* context) { queryOperatorMap = - stdx::make_unique<StringMap<PathAcceptingKeyword>>(StringMap<PathAcceptingKeyword>{ + std::make_unique<StringMap<PathAcceptingKeyword>>(StringMap<PathAcceptingKeyword>{ // TODO: SERVER-19565 Add $eq after auditing callers. {"_internalExprEq", PathAcceptingKeyword::INTERNAL_EXPR_EQ}, {"_internalSchemaAllElemMatchFromIndex", |