diff options
author | Ruoxin Xu <ruoxin.xu@mongodb.com> | 2020-10-29 12:14:01 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-01-07 11:20:50 +0000 |
commit | 90c89d33c400d2f1eb8972170b7a17e3315c4198 (patch) | |
tree | 2aaee3468e4350950b546b2b24783d9ddc2d8e2e /src/mongo/s/query | |
parent | 66cdb6d0fccf3b65c61a1bea5d6171591d21c9da (diff) | |
download | mongo-90c89d33c400d2f1eb8972170b7a17e3315c4198.tar.gz |
SERVER-51649 Convert aggregate command input to IDL
Diffstat (limited to 'src/mongo/s/query')
-rw-r--r-- | src/mongo/s/query/cluster_aggregate.cpp | 30 | ||||
-rw-r--r-- | src/mongo/s/query/cluster_aggregate.h | 9 | ||||
-rw-r--r-- | src/mongo/s/query/cluster_aggregation_planner.cpp | 4 |
3 files changed, 22 insertions, 21 deletions
diff --git a/src/mongo/s/query/cluster_aggregate.cpp b/src/mongo/s/query/cluster_aggregate.cpp index e266f40fb5e..4c80fb988d0 100644 --- a/src/mongo/s/query/cluster_aggregate.cpp +++ b/src/mongo/s/query/cluster_aggregate.cpp @@ -101,7 +101,7 @@ auto resolveInvolvedNamespaces(stdx::unordered_set<NamespaceString> involvedName // collection UUID if provided. boost::intrusive_ptr<ExpressionContext> makeExpressionContext( OperationContext* opCtx, - const AggregationRequest& request, + const AggregateCommand& request, BSONObj collationObj, boost::optional<UUID> uuid, StringMap<ExpressionContext::ResolvedNamespace> resolvedNamespaces) { @@ -191,7 +191,7 @@ void updateHostsTargetedMetrics(OperationContext* opCtx, Status ClusterAggregate::runAggregate(OperationContext* opCtx, const Namespaces& namespaces, - const AggregationRequest& request, + const AggregateCommand& request, const PrivilegeVector& privileges, BSONObjBuilder* result) { return runAggregate(opCtx, namespaces, request, {request}, privileges, result); @@ -199,21 +199,21 @@ Status ClusterAggregate::runAggregate(OperationContext* opCtx, Status ClusterAggregate::runAggregate(OperationContext* opCtx, const Namespaces& namespaces, - const AggregationRequest& request, + const AggregateCommand& request, const LiteParsedPipeline& liteParsedPipeline, const PrivilegeVector& privileges, BSONObjBuilder* result) { - uassert(51028, "Cannot specify exchange option to a mongos", !request.getExchangeSpec()); + uassert(51028, "Cannot specify exchange option to a mongos", !request.getExchange()); uassert(51143, "Cannot specify runtime constants option to a mongos", !request.getLegacyRuntimeConstants()); uassert(51089, - str::stream() << "Internal parameter(s) [" << AggregationRequest::kNeedsMergeName - << ", " << AggregationRequest::kFromMongosName + str::stream() << "Internal parameter(s) [" << AggregateCommand::kNeedsMergeFieldName + << ", " << AggregateCommand::kFromMongosFieldName << "] cannot be set to 'true' when sent to mongos", - !request.needsMerge() && !request.isFromMongos()); + !request.getNeedsMerge() && !request.getFromMongos()); uassert(4928902, - str::stream() << AggregationRequest::kCollectionUUIDName + str::stream() << AggregateCommand::kCollectionUUIDFieldName << " is not supported on a mongos", !request.getCollectionUUID()); @@ -263,11 +263,11 @@ Status ClusterAggregate::runAggregate(OperationContext* opCtx, // database, the standard logic would attempt to resolve its non-existent UUID and // collation by sending a specious 'listCollections' command to the config servers. if (hasChangeStream) { - return {request.getCollation(), boost::none}; + return {request.getCollation().value_or(BSONObj()), boost::none}; } return cluster_aggregation_planner::getCollationAndUUID( - opCtx, cm, namespaces.executionNss, request.getCollation()); + opCtx, cm, namespaces.executionNss, request.getCollation().value_or(BSONObj())); }(); // Build an ExpressionContext for the pipeline. This instantiates an appropriate collator, @@ -298,7 +298,7 @@ Status ClusterAggregate::runAggregate(OperationContext* opCtx, invariant(targeter.policy == cluster_aggregation_planner::AggregationTargeter::kPassthrough); expCtx = make_intrusive<ExpressionContext>( - opCtx, nullptr, namespaces.executionNss, boost::none, request.getLetParameters()); + opCtx, nullptr, namespaces.executionNss, boost::none, request.getLet()); } if (request.getExplain()) { @@ -315,7 +315,7 @@ Status ClusterAggregate::runAggregate(OperationContext* opCtx, namespaces, *targeter.cm, request.getExplain(), - request.serializeToCommandObj(), + aggregation_request_helper::serializeToCommandDoc(request), privileges, result); } @@ -344,7 +344,7 @@ Status ClusterAggregate::runAggregate(OperationContext* opCtx, return cluster_aggregation_planner::dispatchPipelineAndMerge( opCtx, std::move(targeter), - request.serializeToCommandObj(), + aggregation_request_helper::serializeToCommandDoc(request), request.getBatchSize(), namespaces, privileges, @@ -365,14 +365,14 @@ Status ClusterAggregate::runAggregate(OperationContext* opCtx, // Add 'command' object to explain output. if (expCtx->explain) { explain_common::appendIfRoom( - request.serializeToCommandObj().toBson(), "command", result); + aggregation_request_helper::serializeToCommandObj(request), "command", result); } } return status; } Status ClusterAggregate::retryOnViewError(OperationContext* opCtx, - const AggregationRequest& request, + const AggregateCommand& request, const ResolvedView& resolvedView, const NamespaceString& requestedNss, const PrivilegeVector& privileges, diff --git a/src/mongo/s/query/cluster_aggregate.h b/src/mongo/s/query/cluster_aggregate.h index 2c74736235a..b4239e47891 100644 --- a/src/mongo/s/query/cluster_aggregate.h +++ b/src/mongo/s/query/cluster_aggregate.h @@ -32,7 +32,8 @@ #include "mongo/base/status.h" #include "mongo/bson/bsonobj.h" #include "mongo/db/namespace_string.h" -#include "mongo/db/pipeline/aggregation_request.h" +#include "mongo/db/pipeline/aggregate_command_gen.h" +#include "mongo/db/pipeline/aggregation_request_helper.h" #include "mongo/db/pipeline/document_source.h" #include "mongo/db/pipeline/lite_parsed_pipeline.h" #include "mongo/s/query/cluster_client_cursor_params.h" @@ -78,7 +79,7 @@ public: */ static Status runAggregate(OperationContext* opCtx, const Namespaces& namespaces, - const AggregationRequest& request, + const AggregateCommand& request, const LiteParsedPipeline& liteParsedPipeline, const PrivilegeVector& privileges, BSONObjBuilder* result); @@ -88,7 +89,7 @@ public: */ static Status runAggregate(OperationContext* opCtx, const Namespaces& namespaces, - const AggregationRequest& request, + const AggregateCommand& request, const PrivilegeVector& privileges, BSONObjBuilder* result); @@ -102,7 +103,7 @@ public: * On success, populates 'result' with the command response. */ static Status retryOnViewError(OperationContext* opCtx, - const AggregationRequest& request, + const AggregateCommand& request, const ResolvedView& resolvedView, const NamespaceString& requestedNss, const PrivilegeVector& privileges, diff --git a/src/mongo/s/query/cluster_aggregation_planner.cpp b/src/mongo/s/query/cluster_aggregation_planner.cpp index 75c8f142b68..272d13aa6c2 100644 --- a/src/mongo/s/query/cluster_aggregation_planner.cpp +++ b/src/mongo/s/query/cluster_aggregation_planner.cpp @@ -124,9 +124,9 @@ BSONObj createCommandForMergingShard(Document serializedCommand, MutableDocument mergeCmd(serializedCommand); mergeCmd["pipeline"] = Value(pipelineForMerging->serialize()); - mergeCmd[AggregationRequest::kFromMongosName] = Value(true); + mergeCmd[AggregateCommand::kFromMongosFieldName] = Value(true); - mergeCmd[AggregationRequest::kLetName] = + mergeCmd[AggregateCommand::kLetFieldName] = Value(mergeCtx->variablesParseState.serialize(mergeCtx->variables)); // If the user didn't specify a collation already, make sure there's a collation attached to |