diff options
author | Mihai Andrei <mihai.andrei@10gen.com> | 2021-09-13 23:20:19 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-09-13 23:55:08 +0000 |
commit | 15c51de0d4700d490c71ca70f961c3c44c1d4a1c (patch) | |
tree | 6e415ce171ccc92eaa7bc1f250464e39d2450e67 /src/mongo/db/pipeline/accumulator_multi.cpp | |
parent | 926b0287318744f7ef751aa10e64ec310d36695e (diff) | |
download | mongo-15c51de0d4700d490c71ca70f961c3c44c1d4a1c.tar.gz |
SERVER-58379 Extend REGISTER macros to support API version, FCV, and conditional checks for accumulators, expressions, and window functions
Diffstat (limited to 'src/mongo/db/pipeline/accumulator_multi.cpp')
-rw-r--r-- | src/mongo/db/pipeline/accumulator_multi.cpp | 99 |
1 files changed, 56 insertions, 43 deletions
diff --git a/src/mongo/db/pipeline/accumulator_multi.cpp b/src/mongo/db/pipeline/accumulator_multi.cpp index 78bd99e740d..912d7c56569 100644 --- a/src/mongo/db/pipeline/accumulator_multi.cpp +++ b/src/mongo/db/pipeline/accumulator_multi.cpp @@ -34,39 +34,64 @@ namespace mongo { using FirstLastSense = AccumulatorFirstLastN::Sense; using MinMaxSense = AccumulatorMinMax::Sense; -REGISTER_ACCUMULATOR_WITH_MIN_VERSION(maxN, - AccumulatorMinMaxN::parseMinMaxN<MinMaxSense::kMax>, - multiversion::FeatureCompatibilityVersion::kVersion_5_1); -REGISTER_ACCUMULATOR_WITH_MIN_VERSION(minN, - AccumulatorMinMaxN::parseMinMaxN<MinMaxSense::kMin>, - multiversion::FeatureCompatibilityVersion::kVersion_5_1); -REGISTER_EXPRESSION_WITH_MIN_VERSION(maxN, - AccumulatorMinMaxN::parseExpression<MinMaxSense::kMax>, - AllowedWithApiStrict::kNeverInVersion1, - AllowedWithClientType::kAny, - multiversion::FeatureCompatibilityVersion::kVersion_5_1); -REGISTER_EXPRESSION_WITH_MIN_VERSION(minN, - AccumulatorMinMaxN::parseExpression<MinMaxSense::kMin>, - AllowedWithApiStrict::kNeverInVersion1, - AllowedWithClientType::kAny, - multiversion::FeatureCompatibilityVersion::kVersion_5_1); -REGISTER_ACCUMULATOR_WITH_MIN_VERSION( +// TODO SERVER-52247 Replace boost::none with 'gFeatureFlagExactTopNAccumulator.getVersion()' below +// once 'gFeatureFlagExactTopNAccumulator' is set to true by default and is configured with an FCV. +REGISTER_ACCUMULATOR_CONDITIONALLY( + maxN, + AccumulatorMinMaxN::parseMinMaxN<MinMaxSense::kMax>, + AllowedWithApiStrict::kNeverInVersion1, + AllowedWithClientType::kAny, + boost::none, + feature_flags::gFeatureFlagExactTopNAccumulator.isEnabledAndIgnoreFCV()); +REGISTER_ACCUMULATOR_CONDITIONALLY( + minN, + AccumulatorMinMaxN::parseMinMaxN<MinMaxSense::kMin>, + AllowedWithApiStrict::kNeverInVersion1, + AllowedWithClientType::kAny, + boost::none, + feature_flags::gFeatureFlagExactTopNAccumulator.isEnabledAndIgnoreFCV()); +REGISTER_EXPRESSION_CONDITIONALLY( + maxN, + AccumulatorMinMaxN::parseExpression<MinMaxSense::kMax>, + AllowedWithApiStrict::kNeverInVersion1, + AllowedWithClientType::kAny, + boost::none, + feature_flags::gFeatureFlagExactTopNAccumulator.isEnabledAndIgnoreFCV()); +REGISTER_EXPRESSION_CONDITIONALLY( + minN, + AccumulatorMinMaxN::parseExpression<MinMaxSense::kMin>, + AllowedWithApiStrict::kNeverInVersion1, + AllowedWithClientType::kAny, + boost::none, + feature_flags::gFeatureFlagExactTopNAccumulator.isEnabledAndIgnoreFCV()); +REGISTER_ACCUMULATOR_CONDITIONALLY( firstN, AccumulatorFirstLastN::parseFirstLastN<FirstLastSense::kFirst>, - multiversion::FeatureCompatibilityVersion::kVersion_5_1); -REGISTER_ACCUMULATOR_WITH_MIN_VERSION(lastN, - AccumulatorFirstLastN::parseFirstLastN<FirstLastSense::kLast>, - multiversion::FeatureCompatibilityVersion::kVersion_5_1); -REGISTER_EXPRESSION_WITH_MIN_VERSION(firstN, - AccumulatorFirstLastN::parseExpression<FirstLastSense::kFirst>, - AllowedWithApiStrict::kNeverInVersion1, - AllowedWithClientType::kAny, - multiversion::FeatureCompatibilityVersion::kVersion_5_1); -REGISTER_EXPRESSION_WITH_MIN_VERSION(lastN, - AccumulatorFirstLastN::parseExpression<FirstLastSense::kLast>, - AllowedWithApiStrict::kNeverInVersion1, - AllowedWithClientType::kAny, - multiversion::FeatureCompatibilityVersion::kVersion_5_1); + AllowedWithApiStrict::kNeverInVersion1, + AllowedWithClientType::kAny, + boost::none, + feature_flags::gFeatureFlagExactTopNAccumulator.isEnabledAndIgnoreFCV()); +REGISTER_ACCUMULATOR_CONDITIONALLY( + lastN, + AccumulatorFirstLastN::parseFirstLastN<FirstLastSense::kLast>, + AllowedWithApiStrict::kNeverInVersion1, + AllowedWithClientType::kAny, + boost::none, + feature_flags::gFeatureFlagExactTopNAccumulator.isEnabledAndIgnoreFCV()); +REGISTER_EXPRESSION_CONDITIONALLY( + firstN, + AccumulatorFirstLastN::parseExpression<FirstLastSense::kFirst>, + AllowedWithApiStrict::kNeverInVersion1, + AllowedWithClientType::kAny, + boost::none, + feature_flags::gFeatureFlagExactTopNAccumulator.isEnabledAndIgnoreFCV()); +REGISTER_EXPRESSION_CONDITIONALLY( + lastN, + AccumulatorFirstLastN::parseExpression<FirstLastSense::kLast>, + AllowedWithApiStrict::kNeverInVersion1, + AllowedWithClientType::kAny, + boost::none, + feature_flags::gFeatureFlagExactTopNAccumulator.isEnabledAndIgnoreFCV()); // TODO SERVER-57884 Add $firstN/$lastN as window functions. AccumulatorN::AccumulatorN(ExpressionContext* const expCtx) @@ -182,12 +207,6 @@ AccumulationExpression AccumulatorMinMaxN::parseMinMaxN(ExpressionContext* const } }(); - // TODO SERVER-58379 Remove this uassert once the FCV constants are upgraded and the REGISTER - // macros above are updated accordingly. - uassert(5787909, - str::stream() << "Cannot create " << name << " accumulator if feature flag is disabled", - feature_flags::gFeatureFlagExactTopNAccumulator.isEnabled( - serverGlobalParams.featureCompatibility)); uassert(5787900, str::stream() << "specification must be an object; found " << elem, elem.type() == BSONType::Object); @@ -279,12 +298,6 @@ AccumulationExpression AccumulatorFirstLastN::parseFirstLastN(ExpressionContext* } }(); - // TODO SERVER-58379 Remove this uassert once the FCV constants are upgraded and the REGISTER - // macros above are updated accordingly. - uassert(5787800, - str::stream() << "Cannot create " << name << " accumulator if feature flag is disabled", - feature_flags::gFeatureFlagExactTopNAccumulator.isEnabled( - serverGlobalParams.featureCompatibility)); uassert(5787801, str::stream() << "specification must be an object; found " << elem, elem.type() == BSONType::Object); |