diff options
author | Eric Cox <eric.cox@mongodb.com> | 2020-05-06 15:26:02 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-06-01 20:27:40 +0000 |
commit | cc318e18f225ccaae25b0e0c4c87d8ea91b59ba8 (patch) | |
tree | fd41fe5f08d3dc237dcadc762608b06e2775c032 /src/mongo/s/cluster_commands_helpers.cpp | |
parent | 8bf94a6b123c4a8d60f7b7fd8fd860976a726fbf (diff) | |
download | mongo-cc318e18f225ccaae25b0e0c4c87d8ea91b59ba8.tar.gz |
SERVER-47740 Plumbing for construction of a full ExpressionContext in the sharded case
Diffstat (limited to 'src/mongo/s/cluster_commands_helpers.cpp')
-rw-r--r-- | src/mongo/s/cluster_commands_helpers.cpp | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/mongo/s/cluster_commands_helpers.cpp b/src/mongo/s/cluster_commands_helpers.cpp index f7f24aa31c2..881542a5730 100644 --- a/src/mongo/s/cluster_commands_helpers.cpp +++ b/src/mongo/s/cluster_commands_helpers.cpp @@ -41,6 +41,8 @@ #include "mongo/db/error_labels.h" #include "mongo/db/logical_clock.h" #include "mongo/db/namespace_string.h" +#include "mongo/db/pipeline/expression_context.h" +#include "mongo/db/query/collation/collator_factory_interface.h" #include "mongo/db/query/cursor_response.h" #include "mongo/db/repl/read_concern_args.h" #include "mongo/executor/task_executor_pool.h" @@ -365,7 +367,14 @@ std::vector<AsyncRequestsSender::Request> buildVersionedRequestsForTargetedShard // The collection is sharded. Target all shards that own chunks that match the query. std::set<ShardId> shardIds; - routingInfo.cm()->getShardIdsForQuery(opCtx, query, collation, &shardIds); + std::unique_ptr<CollatorInterface> collator; + if (!collation.isEmpty()) { + collator = uassertStatusOK( + CollatorFactoryInterface::get(opCtx->getServiceContext())->makeFromBSON(collation)); + } + + auto expCtx = make_intrusive<ExpressionContext>(opCtx, std::move(collator), nss); + routingInfo.cm()->getShardIdsForQuery(expCtx, query, collation, &shardIds); for (const ShardId& shardId : shardIds) { if (shardsToSkip.find(shardId) == shardsToSkip.end()) { @@ -694,7 +703,16 @@ std::set<ShardId> getTargetedShardsForQuery(OperationContext* opCtx, // The collection is sharded. Use the routing table to decide which shards to target // based on the query and collation. std::set<ShardId> shardIds; - routingInfo.cm()->getShardIdsForQuery(opCtx, query, collation, &shardIds); + auto&& cif = [&]() { + if (collation.isEmpty()) { + return std::unique_ptr<CollatorInterface>{}; + } else { + return uassertStatusOK(CollatorFactoryInterface::get(opCtx->getServiceContext()) + ->makeFromBSON(collation)); + } + }(); + auto expCtx = make_intrusive<ExpressionContext>(opCtx, std::move(cif), NamespaceString()); + routingInfo.cm()->getShardIdsForQuery(expCtx, query, collation, &shardIds); return shardIds; } |