summaryrefslogtreecommitdiff
path: root/src/mongo/db/pipeline/document_source_match.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/pipeline/document_source_match.cpp')
-rw-r--r--src/mongo/db/pipeline/document_source_match.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/mongo/db/pipeline/document_source_match.cpp b/src/mongo/db/pipeline/document_source_match.cpp
index 10346eb6a46..418f1821b4b 100644
--- a/src/mongo/db/pipeline/document_source_match.cpp
+++ b/src/mongo/db/pipeline/document_source_match.cpp
@@ -93,11 +93,12 @@ DocumentSource::GetNextResult DocumentSourceMatch::doGetNext() {
auto nextInput = pSource->getNext();
for (; nextInput.isAdvanced(); nextInput = pSource->getNext()) {
// MatchExpression only takes BSON documents, so we have to make one. As an optimization,
- // only serialize the fields we need to do the match.
+ // only serialize the fields we need to do the match. Specify BSONObj::LargeSizeTrait so
+ // that matching against a large document mid-pipeline does not throw a BSON max-size error.
BSONObj toMatch = _dependencies.needWholeDocument
- ? nextInput.getDocument().toBson()
- : document_path_support::documentToBsonWithPaths(nextInput.getDocument(),
- _dependencies.fields);
+ ? nextInput.getDocument().toBson<BSONObj::LargeSizeTrait>()
+ : document_path_support::documentToBsonWithPaths<BSONObj::LargeSizeTrait>(
+ nextInput.getDocument(), _dependencies.fields);
if (_expression->matchesBSON(toMatch)) {
return nextInput;
@@ -410,13 +411,13 @@ void DocumentSourceMatch::joinMatchWith(intrusive_ptr<DocumentSourceMatch> other
}
pair<intrusive_ptr<DocumentSourceMatch>, intrusive_ptr<DocumentSourceMatch>>
-DocumentSourceMatch::splitSourceBy(const std::set<std::string>& fields,
+DocumentSourceMatch::splitSourceBy(const OrderedPathSet& fields,
const StringMap<std::string>& renames) && {
return std::move(*this).splitSourceByFunc(fields, renames, expression::isIndependentOf);
}
pair<intrusive_ptr<DocumentSourceMatch>, intrusive_ptr<DocumentSourceMatch>>
-DocumentSourceMatch::splitSourceByFunc(const std::set<std::string>& fields,
+DocumentSourceMatch::splitSourceByFunc(const OrderedPathSet& fields,
const StringMap<std::string>& renames,
expression::ShouldSplitExprFunc func) && {
pair<unique_ptr<MatchExpression>, unique_ptr<MatchExpression>> newExpr(
@@ -499,7 +500,7 @@ DocumentSourceMatch::splitMatchByModifiedFields(
const boost::intrusive_ptr<DocumentSourceMatch>& match,
const DocumentSource::GetModPathsReturn& modifiedPathsRet) {
// Attempt to move some or all of this $match before this stage.
- std::set<std::string> modifiedPaths;
+ OrderedPathSet modifiedPaths;
switch (modifiedPathsRet.type) {
case DocumentSource::GetModPathsReturn::Type::kNotSupported:
// We don't know what paths this stage might modify, so refrain from swapping.