summaryrefslogtreecommitdiff
path: root/src/mongo/db/pipeline/accumulator_min_max.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/pipeline/accumulator_min_max.cpp')
-rw-r--r--src/mongo/db/pipeline/accumulator_min_max.cpp27
1 files changed, 12 insertions, 15 deletions
diff --git a/src/mongo/db/pipeline/accumulator_min_max.cpp b/src/mongo/db/pipeline/accumulator_min_max.cpp
index 86172cb3338..c3c5a9790f0 100644
--- a/src/mongo/db/pipeline/accumulator_min_max.cpp
+++ b/src/mongo/db/pipeline/accumulator_min_max.cpp
@@ -21,27 +21,24 @@
namespace mongo {
- Value AccumulatorMinMax::evaluate(const Document& pDocument) const {
- verify(vpOperand.size() == 1);
- Value prhs(vpOperand[0]->evaluate(pDocument));
-
+ void AccumulatorMinMax::processInternal(const Value& input) {
// nullish values should have no impact on result
- if (!prhs.nullish()) {
+ if (!input.nullish()) {
/* compare with the current value; swap if appropriate */
- int cmp = Value::compare(pValue, prhs) * sense;
- if (cmp > 0 || pValue.missing()) // missing is lower than all other values
- pValue = prhs;
+ int cmp = Value::compare(_val, input) * _sense;
+ if (cmp > 0 || _val.missing()) // missing is lower than all other values
+ _val = input;
}
-
- return Value();
}
- AccumulatorMinMax::AccumulatorMinMax(int theSense):
- AccumulatorSingleValue(),
- sense(theSense) {
- verify((sense == 1) || (sense == -1));
+ Value AccumulatorMinMax::getValue() const {
+ return _val;
}
+ AccumulatorMinMax::AccumulatorMinMax(int theSense)
+ :_sense(theSense)
+ { verify((_sense == 1) || (_sense == -1)); }
+
intrusive_ptr<Accumulator> AccumulatorMinMax::createMin(
const intrusive_ptr<ExpressionContext> &pCtx) {
intrusive_ptr<AccumulatorMinMax> pAccumulator(
@@ -57,7 +54,7 @@ namespace mongo {
}
const char *AccumulatorMinMax::getOpName() const {
- if (sense == 1)
+ if (_sense == 1)
return "$min";
return "$max";
}