diff options
Diffstat (limited to 'src/mongo/db/pipeline/expression_context.h')
| -rw-r--r-- | src/mongo/db/pipeline/expression_context.h | 71 |
1 files changed, 61 insertions, 10 deletions
diff --git a/src/mongo/db/pipeline/expression_context.h b/src/mongo/db/pipeline/expression_context.h index 3f83fba6c8e..38747fd60ae 100644 --- a/src/mongo/db/pipeline/expression_context.h +++ b/src/mongo/db/pipeline/expression_context.h @@ -60,15 +60,6 @@ namespace mongo { class AggregateCommandRequest; -/** - * The structure ExpressionCounters encapsulates counters for match, aggregate, and other - * expression types as seen in the end-user queries. - */ -struct ExpressionCounters { - StringMap<uint64_t> aggExprCountersMap; - StringMap<uint64_t> matchExprCountersMap; -}; - class ExpressionContext : public RefCountable { public: struct ResolvedNamespace { @@ -118,6 +109,8 @@ public: struct ExpressionCounters { StringMap<uint64_t> aggExprCountersMap; StringMap<uint64_t> matchExprCountersMap; + StringMap<uint64_t> groupAccumulatorExprCountersMap; + StringMap<uint64_t> windowAccumulatorExprCountersMap; }; /** @@ -380,6 +373,16 @@ public: void incrementAggExprCounter(StringData name); /** + * Increment the counter for the $group accumulator expression with a given name. + */ + void incrementGroupAccumulatorExprCounter(StringData name); + + /** + * Increment the counter for the $setWindowFields accumulator expression with a given name. + */ + void incrementWindowAccumulatorExprCounter(StringData name); + + /** * Merge expression counters from the current expression context into the global maps * and stop counting. */ @@ -433,7 +436,7 @@ public: // Tracks the depth of nested aggregation sub-pipelines. Used to enforce depth limits. long long subPipelineDepth = 0; - // True if this 'ExpressionContext' object is for the inner side of a $lookup. + // True if this 'ExpressionContext' object is for the inner side of a $lookup or $graphLookup. bool inLookup = false; // If set, this will disallow use of features introduced in versions above the provided version. @@ -481,11 +484,57 @@ public: // The resume token version that should be generated by a change stream. int changeStreamTokenVersion = ResumeTokenData::kDefaultTokenVersion; + // If set to true, always use 'changeStreamTokenVersion' when resuming a stream, regardless of + // the client resume token's version. + bool ignoreTokenVersionOnResume = false; + // True if the expression context is the original one for a given pipeline. // False if another context is created for the same pipeline. Used to disable duplicate // expression counting. bool enabledCounters = true; + // Sets or clears a flag which tells DocumentSource parsers whether any involved Collection + // may contain extended-range dates. + void setRequiresTimeseriesExtendedRangeSupport(bool v) { + _requiresTimeseriesExtendedRangeSupport = v; + } + bool getRequiresTimeseriesExtendedRangeSupport() const { + return _requiresTimeseriesExtendedRangeSupport; + } + + // This is state that is to be shared between the DocumentInternalSearchMongotRemote and + // DocumentInternalSearchIdLookup stages (these stages are the result of desugaring $search) + // during runtime. + class SharedSearchState { + public: + SharedSearchState() {} + + long long getDocsReturnedByIdLookup() const { + return _docsReturnedByIdLookup; + } + + /** + * Sets the value of _docsReturnedByIdLookup to 0. + */ + void resetDocsReturnedByIdLookup() { + _docsReturnedByIdLookup = 0; + } + + /** + * Increments the value of _docsReturnedByIdLookup by 1. + */ + void incrementDocsReturnedByIdLookup() { + _docsReturnedByIdLookup++; + } + + private: + // When there is an extractable limit in the query, DocumentInternalSearchMongotRemote sends + // a getMore to mongot that specifies how many more documents it needs to fulfill that + // limit, and it incorporates the amount of documents returned by the + // DocumentInternalSearchIdLookup stage into that value. + long long _docsReturnedByIdLookup = 0; + } sharedSearchState; + protected: static const int kInterruptCheckPeriod = 128; @@ -510,6 +559,8 @@ protected: bool _isCappedDelete = false; + bool _requiresTimeseriesExtendedRangeSupport = false; + private: boost::optional<ExpressionCounters> _expressionCounters = boost::none; }; |
