summaryrefslogtreecommitdiff
path: root/src/mongo/util/summation.h
diff options
context:
space:
mode:
authorAdityavardhan Agrawal <adi.agrawal@mongodb.com>2021-09-01 17:17:08 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-09-01 17:59:18 +0000
commit23f9d2a53917d63fc3d3b8c8646f40f2bc4caa2f (patch)
treea8ee8e3c51d0961b9317c314010dbc70f2e82c7b /src/mongo/util/summation.h
parent8671522fd5a59d43cb32ebe78b8c97f5e7a07afa (diff)
downloadmongo-23f9d2a53917d63fc3d3b8c8646f40f2bc4caa2f.tar.gz
SERVER-57553 add $sum accumulator to SBE
Diffstat (limited to 'src/mongo/util/summation.h')
-rw-r--r--src/mongo/util/summation.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/mongo/util/summation.h b/src/mongo/util/summation.h
index d199fc304a7..18f03e35151 100644
--- a/src/mongo/util/summation.h
+++ b/src/mongo/util/summation.h
@@ -48,6 +48,15 @@ using DoubleDouble = std::pair<double, double>;
*/
class DoubleDoubleSummation {
public:
+ DoubleDoubleSummation() = default;
+
+ /**
+ * Factory method.
+ */
+ static constexpr DoubleDoubleSummation create(double sum, double addend) noexcept {
+ return DoubleDoubleSummation(sum, addend);
+ }
+
/**
* Adds x to the sum, keeping track of a compensation amount to be subtracted later.
*/
@@ -151,5 +160,8 @@ private:
// Simple sum to be returned if _sum is NaN. This addresses infinities turning into NaNs when
// using compensated addition.
double _special = 0.0;
+
+ constexpr DoubleDoubleSummation(double sum, double addend) noexcept
+ : _sum(sum), _addend(addend), _special(sum) {}
};
} // namespace mongo