summaryrefslogtreecommitdiff
path: root/src/mongo/db/exec/sbe/vm/vm.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/exec/sbe/vm/vm.h')
-rw-r--r--src/mongo/db/exec/sbe/vm/vm.h67
1 files changed, 64 insertions, 3 deletions
diff --git a/src/mongo/db/exec/sbe/vm/vm.h b/src/mongo/db/exec/sbe/vm/vm.h
index 255a1a497c2..e5148e8d4b2 100644
--- a/src/mongo/db/exec/sbe/vm/vm.h
+++ b/src/mongo/db/exec/sbe/vm/vm.h
@@ -511,12 +511,33 @@ enum class Builtin : uint8_t {
collAddToSet, // agg function to append to a set (with collation)
collAddToSetCapped, // agg function to append to a set (with collation), fails when the set
// reaches specified size
- doubleDoubleSum, // special double summation
+
+ // Special double summation.
+ doubleDoubleSum,
+ // A variant of the standard sum aggregate function which maintains a DoubleDouble as the
+ // accumulator's underlying state.
aggDoubleDoubleSum,
+ // Converts a DoubleDouble sum into a single numeric scalar for use once the summation is
+ // complete.
doubleDoubleSumFinalize,
+ // A form of doubleDoubleSum finalization only necessary for sharding support when the cluster
+ // is not yet fully upgraded to FCV 6.0.
doubleDoubleMergeSumFinalize,
+ // Converts a partial sum into a format suitable for serialization over the wire to the merging
+ // node. The merging node expects the internal state of the DoubleDouble summation to be
+ // serialized in a particular format.
doubleDoublePartialSumFinalize,
+ // An agg function which can be used to sum a sequence of DoubleDouble inputs, producing the
+ // resulting total as a DoubleDouble.
+ aggMergeDoubleDoubleSums,
+
+ // Implements Welford's online algorithm for computing sample or population standard deviation
+ // in a single pass.
aggStdDev,
+ // Combines standard deviations that have been partially computed on a subset of the data
+ // using Welford's online algorithm.
+ aggMergeStdDevs,
+
stdDevPopFinalize,
stdDevSampFinalize,
bitTestZero, // test bitwise mask & value is zero
@@ -527,6 +548,18 @@ enum class Builtin : uint8_t {
toLower,
coerceToString,
concat,
+ concatArrays,
+
+ // Agg function to concatenate arrays, failing when the accumulator reaches a specified size.
+ aggConcatArraysCapped,
+
+ // Agg functions to compute the set union of two arrays, failing when the accumulator reaches a
+ // specified size.
+ aggSetUnionCapped,
+ aggCollSetUnionCapped,
+ // Agg function for a simple set union (with no size cap or collation).
+ aggSetUnion,
+
acos,
acosh,
asin,
@@ -980,11 +1013,19 @@ private:
value::TypeTags fieldTag,
value::Value fieldValue);
- void aggDoubleDoubleSumImpl(value::Array* arr, value::TypeTags rhsTag, value::Value rhsValue);
+ void aggDoubleDoubleSumImpl(value::Array* accumulator,
+ value::TypeTags rhsTag,
+ value::Value rhsValue);
+ void aggMergeDoubleDoubleSumsImpl(value::Array* accumulator,
+ value::TypeTags rhsTag,
+ value::Value rhsValue);
// This is an implementation of the following algorithm:
// https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Welford's_online_algorithm
- void aggStdDevImpl(value::Array* arr, value::TypeTags rhsTag, value::Value rhsValue);
+ void aggStdDevImpl(value::Array* accumulator, value::TypeTags rhsTag, value::Value rhsValue);
+ void aggMergeStdDevsImpl(value::Array* accumulator,
+ value::TypeTags rhsTag,
+ value::Value rhsValue);
std::tuple<bool, value::TypeTags, value::Value> aggStdDevFinalizeImpl(value::Value fieldValue,
bool isSamp);
@@ -1103,14 +1144,24 @@ private:
CollatorInterface* collator);
std::tuple<bool, value::TypeTags, value::Value> builtinAddToSetCapped(ArityType arity);
std::tuple<bool, value::TypeTags, value::Value> builtinCollAddToSetCapped(ArityType arity);
+
std::tuple<bool, value::TypeTags, value::Value> builtinDoubleDoubleSum(ArityType arity);
+ // The template parameter is false for a regular DoubleDouble summation and true if merging
+ // partially computed DoubleDouble sums.
+ template <bool merging>
std::tuple<bool, value::TypeTags, value::Value> builtinAggDoubleDoubleSum(ArityType arity);
+
// This is only for compatibility with mongos/sharding and we will revisit this later.
template <bool keepIntegerPrecision = false>
std::tuple<bool, value::TypeTags, value::Value> builtinDoubleDoubleSumFinalize(ArityType arity);
std::tuple<bool, value::TypeTags, value::Value> builtinDoubleDoublePartialSumFinalize(
ArityType arity);
+
+ // The template parameter is false for a regular std dev and true if merging partially computed
+ // standard devations.
+ template <bool merging>
std::tuple<bool, value::TypeTags, value::Value> builtinAggStdDev(ArityType arity);
+
std::tuple<bool, value::TypeTags, value::Value> builtinStdDevPopFinalize(ArityType arity);
std::tuple<bool, value::TypeTags, value::Value> builtinStdDevSampFinalize(ArityType arity);
std::tuple<bool, value::TypeTags, value::Value> builtinBitTestZero(ArityType arity);
@@ -1137,6 +1188,16 @@ private:
std::tuple<bool, value::TypeTags, value::Value> builtinTanh(ArityType arity);
std::tuple<bool, value::TypeTags, value::Value> builtinRound(ArityType arity);
std::tuple<bool, value::TypeTags, value::Value> builtinConcat(ArityType arity);
+ std::tuple<bool, value::TypeTags, value::Value> builtinConcatArrays(ArityType arity);
+ std::tuple<bool, value::TypeTags, value::Value> builtinAggConcatArraysCapped(ArityType arity);
+ std::tuple<bool, value::TypeTags, value::Value> builtinAggSetUnion(ArityType arity);
+ std::tuple<bool, value::TypeTags, value::Value> builtinAggSetUnionCapped(ArityType arity);
+ std::tuple<bool, value::TypeTags, value::Value> builtinAggCollSetUnionCapped(ArityType arity);
+ std::tuple<bool, value::TypeTags, value::Value> aggSetUnionCappedImpl(
+ value::TypeTags tagNewElem,
+ value::Value valNewElem,
+ int32_t sizeCap,
+ CollatorInterface* collator);
std::tuple<bool, value::TypeTags, value::Value> builtinIsMember(ArityType arity);
std::tuple<bool, value::TypeTags, value::Value> builtinCollIsMember(ArityType arity);
std::tuple<bool, value::TypeTags, value::Value> builtinIndexOfBytes(ArityType arity);