summaryrefslogtreecommitdiff
path: root/src/mongo/db/pipeline/document_source_unwind.cpp
diff options
context:
space:
mode:
authorDavid Storch <david.storch@10gen.com>2016-10-03 11:48:27 -0400
committerDavid Storch <david.storch@10gen.com>2016-10-06 11:19:24 -0400
commit4976eb401b3f16482fb35287ea60d7e8b33fe76d (patch)
tree3ab5cfaec3f76dc334b006f0b1eeb7162772d4d6 /src/mongo/db/pipeline/document_source_unwind.cpp
parenta2d34afd4330258e05c5ac1e9174338cfda29a10 (diff)
downloadmongo-4976eb401b3f16482fb35287ea60d7e8b33fe76d.tar.gz
SERVER-19153 push $match as far forward as possible
Diffstat (limited to 'src/mongo/db/pipeline/document_source_unwind.cpp')
-rw-r--r--src/mongo/db/pipeline/document_source_unwind.cpp41
1 files changed, 5 insertions, 36 deletions
diff --git a/src/mongo/db/pipeline/document_source_unwind.cpp b/src/mongo/db/pipeline/document_source_unwind.cpp
index a03bd1e8034..02b8dc62355 100644
--- a/src/mongo/db/pipeline/document_source_unwind.cpp
+++ b/src/mongo/db/pipeline/document_source_unwind.cpp
@@ -232,43 +232,12 @@ BSONObjSet DocumentSourceUnwind::getOutputSorts() {
return out;
}
-Pipeline::SourceContainer::iterator DocumentSourceUnwind::optimizeAt(
- Pipeline::SourceContainer::iterator itr, Pipeline::SourceContainer* container) {
- invariant(*itr == this);
-
- if (auto nextMatch = dynamic_cast<DocumentSourceMatch*>((*std::next(itr)).get())) {
- std::set<std::string> fields = {_unwindPath.fullPath()};
-
- if (_indexPath) {
- fields.insert((*_indexPath).fullPath());
- }
-
- auto splitMatch = nextMatch->splitSourceBy(fields);
-
- invariant(splitMatch.first || splitMatch.second);
-
- if (!splitMatch.first && splitMatch.second) {
- // No optimization was possible.
- return std::next(itr);
- }
-
- container->erase(std::next(itr));
-
- // If splitMatch.second is not null, then there is a new $match stage to insert after
- // ourselves.
- if (splitMatch.second) {
- container->insert(std::next(itr), std::move(splitMatch.second));
- }
-
- if (splitMatch.first) {
- container->insert(itr, std::move(splitMatch.first));
- if (std::prev(itr) == container->begin()) {
- return std::prev(itr);
- }
- return std::prev(std::prev(itr));
- }
+DocumentSource::GetModPathsReturn DocumentSourceUnwind::getModifiedPaths() const {
+ std::set<std::string> modifiedFields{_unwindPath.fullPath()};
+ if (_indexPath) {
+ modifiedFields.insert(_indexPath->fullPath());
}
- return std::next(itr);
+ return {GetModPathsReturn::Type::kFiniteSet, std::move(modifiedFields)};
}
Value DocumentSourceUnwind::serialize(bool explain) const {