summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Hirschhorn <max.hirschhorn@mongodb.com>2021-06-15 22:03:22 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-06-15 22:55:50 +0000
commit6659e192ee5feceda14bebe1cb22f219d5d765fd (patch)
tree5270618121a37fb3141e81489b58a8f2af210e12
parentc940646a2bda05b6e6ba1c84be9d3c52a6426559 (diff)
downloadmongo-6659e192ee5feceda14bebe1cb22f219d5d765fd.tar.gz
SERVER-57668 Cache post-transformed chunk bounds for resharding cloning.
-rw-r--r--src/mongo/db/s/resharding/resharding_collection_cloner.cpp32
1 files changed, 16 insertions, 16 deletions
diff --git a/src/mongo/db/s/resharding/resharding_collection_cloner.cpp b/src/mongo/db/s/resharding/resharding_collection_cloner.cpp
index c91fcdf8ff0..7d085a3a825 100644
--- a/src/mongo/db/s/resharding/resharding_collection_cloner.cpp
+++ b/src/mongo/db/s/resharding/resharding_collection_cloner.cpp
@@ -172,23 +172,23 @@ std::unique_ptr<Pipeline, PipelineDeleter> ReshardingCollectionCloner::makePipel
Doc{{"$expr",
Doc{{"$eq",
Arr{V{"$shard"_sd}, V{_recipientShard.toString()}}}}}}}}},
- V{Doc(fromjson("{$match: {$expr: {$let: {\
- vars: {\
- min: {$map: {input: {$objectToArray: '$_id'}, in: '$$this.v'}},\
- max: {$map: {input: {$objectToArray: '$max'}, in: '$$this.v'}}\
- },\
- in: {$and: [\
- {$gte: ['$$sk', '$$min']},\
- {$cond: {\
- if: {$allElementsTrue: [{$map: {\
- input: '$$max',\
- in: {$eq: [{$type: '$$this'}, 'maxKey']}\
- }}]},\
- then: {$lte: ['$$sk', '$$max']},\
- else: {$lt: ['$$sk', '$$max']}\
- }}\
+ V{Doc{fromjson("{$replaceWith: {\
+ min: {$map: {input: {$objectToArray: '$_id'}, in: '$$this.v'}},\
+ max: {$map: {input: {$objectToArray: '$max'}, in: '$$this.v'}}\
+ }}")}},
+ V{Doc{fromjson("{$addFields: {\
+ isGlobalMax: {$allElementsTrue: [{$map: {\
+ input: '$max',\
+ in: {$eq: [{$type: '$$this'}, 'maxKey']}\
+ }}]}\
+ }}")}},
+ V{Doc{fromjson("{$match: {$expr: {$and: [\
+ {$gte: ['$$sk', '$min']},\
+ {$or: [\
+ {$lt: ['$$sk', '$max']},\
+ '$isGlobalMax'\
]}\
- }}}}"))}}},
+ ]}}}")}}}},
{"as", "intersectingChunk"_sd}}}}
.toBson()
.firstElement(),