diff options
author | Rui Liu <rui.liu@mongodb.com> | 2022-11-02 21:06:09 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-11-02 22:14:44 +0000 |
commit | 660a4274bf88a46734619a6606c320da30e868ab (patch) | |
tree | 8fe77dd4470c892a53b57ed9be979ca4a74d1724 /src/mongo/db/pipeline/document_source_internal_unpack_bucket.h | |
parent | a29be1cf33df71c62ebbcc55ec1c1d870c46e297 (diff) | |
download | mongo-660a4274bf88a46734619a6606c320da30e868ab.tar.gz |
SERVER-70269 Push match predicates into unpack stage
Diffstat (limited to 'src/mongo/db/pipeline/document_source_internal_unpack_bucket.h')
-rw-r--r-- | src/mongo/db/pipeline/document_source_internal_unpack_bucket.h | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/src/mongo/db/pipeline/document_source_internal_unpack_bucket.h b/src/mongo/db/pipeline/document_source_internal_unpack_bucket.h index 4dd93046533..a5dab5462ad 100644 --- a/src/mongo/db/pipeline/document_source_internal_unpack_bucket.h +++ b/src/mongo/db/pipeline/document_source_internal_unpack_bucket.h @@ -51,6 +51,8 @@ public: static constexpr StringData kBucketMaxSpanSeconds = "bucketMaxSpanSeconds"_sd; static constexpr StringData kIncludeMinTimeAsMetadata = "includeMinTimeAsMetadata"_sd; static constexpr StringData kIncludeMaxTimeAsMetadata = "includeMaxTimeAsMetadata"_sd; + static constexpr StringData kWholeBucketFilter = "wholeBucketFilter"_sd; + static constexpr StringData kEventFilter = "eventFilter"_sd; static boost::intrusive_ptr<DocumentSource> createFromBsonInternal( BSONElement elem, const boost::intrusive_ptr<ExpressionContext>& expCtx); @@ -62,6 +64,13 @@ public: int bucketMaxSpanSeconds, bool assumeNoMixedSchemaData = false); + DocumentSourceInternalUnpackBucket(const boost::intrusive_ptr<ExpressionContext>& expCtx, + BucketUnpacker bucketUnpacker, + int bucketMaxSpanSeconds, + const boost::optional<BSONObj>& eventFilterBson, + const boost::optional<BSONObj>& wholeBucketFilterBson, + bool assumeNoMixedSchemaData = false); + const char* getSourceName() const override { return kStageNameInternal.rawData(); } @@ -158,7 +167,7 @@ public: /** * Convenience wrapper around BucketSpec::createPredicatesOnBucketLevelField(). */ - std::unique_ptr<MatchExpression> createPredicatesOnBucketLevelField( + BucketSpec::BucketPredicate createPredicatesOnBucketLevelField( const MatchExpression* matchExpr) const; /** @@ -243,8 +252,14 @@ public: GetModPathsReturn getModifiedPaths() const final override; + DepsTracker getRestPipelineDependencies(Pipeline::SourceContainer::iterator itr, + Pipeline::SourceContainer* container) const; + private: GetNextResult doGetNext() final; + + boost::optional<Document> getNextMatchingMeasure(); + bool haveComputedMetaField() const; // If buckets contained a mixed type schema along some path, we have to push down special @@ -261,9 +276,13 @@ private: int _bucketMaxCount = 0; boost::optional<long long> _sampleSize; - // Used to avoid infinite loops after we step backwards to optimize a $match on bucket level - // fields, otherwise we may do an infinite number of $match pushdowns. - bool _triedBucketLevelFieldsPredicatesPushdown = false; + // Filters pushed from the later $match stages + std::unique_ptr<MatchExpression> _eventFilter; + BSONObj _eventFilterBson; + DepsTracker _eventFilterDeps; + std::unique_ptr<MatchExpression> _wholeBucketFilter; + BSONObj _wholeBucketFilterBson; + bool _optimizedEndOfPipeline = false; bool _triedInternalizeProject = false; bool _triedLastpointRewrite = false; |