diff options
author | Mihai Andrei <mihai.andrei@10gen.com> | 2021-09-15 02:51:21 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-09-15 03:30:23 +0000 |
commit | 68922ea9287d053c379658dca08fb7318fe389ac (patch) | |
tree | 59b50fecb0a1c9b70475e53f58a27a3549ea92e2 /src/mongo/db/pipeline/accumulator_multi.cpp | |
parent | e780ce217f71510a7831ef6022714b89f075d4b5 (diff) | |
download | mongo-68922ea9287d053c379658dca08fb7318fe389ac.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); |