diff options
author | Bernard Gorman <bernard.gorman@gmail.com> | 2017-09-21 02:22:00 -0400 |
---|---|---|
committer | Bernard Gorman <bernard.gorman@gmail.com> | 2017-09-24 15:59:10 -0400 |
commit | 21f5028d4404ea9584d53bdb81dd63ca8a505d6f (patch) | |
tree | ec6e458b171de330c0e4756603ba95ba3df06834 /src/mongo/db/pipeline/dependencies.h | |
parent | 280981d3a4cadeb91da9fd69864924e61d7ef99a (diff) | |
download | mongo-21f5028d4404ea9584d53bdb81dd63ca8a505d6f.tar.gz |
SERVER-30399 Add caching for $lookup non-correlated sub-pipeline prefix
Diffstat (limited to 'src/mongo/db/pipeline/dependencies.h')
-rw-r--r-- | src/mongo/db/pipeline/dependencies.h | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/mongo/db/pipeline/dependencies.h b/src/mongo/db/pipeline/dependencies.h index 19cf3ee33f8..133fc1d9893 100644 --- a/src/mongo/db/pipeline/dependencies.h +++ b/src/mongo/db/pipeline/dependencies.h @@ -33,6 +33,7 @@ #include <string> #include "mongo/db/pipeline/document.h" +#include "mongo/db/pipeline/variables.h" namespace mongo { class ParsedDeps; @@ -60,6 +61,16 @@ struct DepsTracker { return fields.empty() && !needWholeDocument && !_needTextScore; } + /** + * Returns 'true' if any of the DepsTracker's variables appear in the passed 'ids' set. + */ + bool hasVariableReferenceTo(const std::set<Variables::Id>& ids) const { + std::vector<Variables::Id> match; + std::set_intersection( + vars.begin(), vars.end(), ids.begin(), ids.end(), std::back_inserter(match)); + return !match.empty(); + } + MetadataAvailable getMetadataAvailable() const { return _metadataAvailable; } @@ -91,9 +102,10 @@ struct DepsTracker { _needSortKey = needSortKey; } - std::set<std::string> fields; // The names of needed fields in dotted notation. - bool needWholeDocument = false; // If true, ignore 'fields' and assume the whole document is - // needed. + std::set<std::string> fields; // Names of needed fields in dotted notation. + std::set<Variables::Id> vars; // IDs of referenced variables. + bool needWholeDocument = false; // If true, ignore 'fields'; the whole document is needed. + private: /** * Appends the meta projections for the sort key and/or text score to 'bb' if necessary. Returns |