summaryrefslogtreecommitdiff
path: root/src/mongo/db/pipeline/accumulator_std_dev.cpp
diff options
context:
space:
mode:
authorJames Cohan <james.cohan@10gen.com>2015-07-16 12:12:36 -0400
committerJames Cohan <james.cohan@10gen.com>2015-08-11 17:08:41 -0400
commitf9828f5a0312801fa5b8592b31648a64f0ea7f67 (patch)
tree94f5f8236dca8e2bd5fcaa95615024f5b36efd96 /src/mongo/db/pipeline/accumulator_std_dev.cpp
parentac4450e7e2102705a8667ac43540689b998b9b60 (diff)
downloadmongo-f9828f5a0312801fa5b8592b31648a64f0ea7f67.tar.gz
SERVER-9625 Makes $sum, $avg, $min, $max, $stdDevPop, and $stdDevSamp accumulators available as expressions
Diffstat (limited to 'src/mongo/db/pipeline/accumulator_std_dev.cpp')
-rw-r--r--src/mongo/db/pipeline/accumulator_std_dev.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/mongo/db/pipeline/accumulator_std_dev.cpp b/src/mongo/db/pipeline/accumulator_std_dev.cpp
index 00922345ed9..6b7e757cac7 100644
--- a/src/mongo/db/pipeline/accumulator_std_dev.cpp
+++ b/src/mongo/db/pipeline/accumulator_std_dev.cpp
@@ -30,14 +30,17 @@
#include "mongo/db/pipeline/accumulator.h"
#include "mongo/db/pipeline/document.h"
+#include "mongo/db/pipeline/expression.h"
#include "mongo/db/pipeline/expression_context.h"
#include "mongo/db/pipeline/value.h"
namespace mongo {
using boost::intrusive_ptr;
-REGISTER_ACCUMULATOR(stdDevPop, AccumulatorStdDev::createPop);
-REGISTER_ACCUMULATOR(stdDevSamp, AccumulatorStdDev::createSamp);
+REGISTER_ACCUMULATOR(stdDevPop, AccumulatorStdDevPop::create);
+REGISTER_ACCUMULATOR(stdDevSamp, AccumulatorStdDevSamp::create);
+REGISTER_EXPRESSION(stdDevPop, ExpressionFromAccumulator<AccumulatorStdDevPop>::parse);
+REGISTER_EXPRESSION(stdDevSamp, ExpressionFromAccumulator<AccumulatorStdDevSamp>::parse);
const char* AccumulatorStdDev::getOpName() const {
return (_isSamp ? "$stdDevSamp" : "$stdDevPop");
@@ -90,12 +93,12 @@ Value AccumulatorStdDev::getValue(bool toBeMerged) const {
}
}
-intrusive_ptr<Accumulator> AccumulatorStdDev::createSamp() {
- return new AccumulatorStdDev(true);
+intrusive_ptr<Accumulator> AccumulatorStdDevSamp::create() {
+ return new AccumulatorStdDevSamp();
}
-intrusive_ptr<Accumulator> AccumulatorStdDev::createPop() {
- return new AccumulatorStdDev(false);
+intrusive_ptr<Accumulator> AccumulatorStdDevPop::create() {
+ return new AccumulatorStdDevPop();
}
AccumulatorStdDev::AccumulatorStdDev(bool isSamp) : _isSamp(isSamp), _count(0), _mean(0), _m2(0) {