summaryrefslogtreecommitdiff
path: root/src/mongo/db/pipeline/accumulator_min_max.cpp
diff options
context:
space:
mode:
authorMathias Stearn <mathias@10gen.com>2012-12-05 18:55:25 -0500
committerMathias Stearn <mathias@10gen.com>2012-12-10 18:54:04 -0500
commit459467c7cf47b57d8990eeb41c65b4e203e15b65 (patch)
treee1b969346a3c8f42ff60a078469b86316dd3c3c0 /src/mongo/db/pipeline/accumulator_min_max.cpp
parentfefb4334afe40664438668a289c6daed6813b3c3 (diff)
downloadmongo-459467c7cf47b57d8990eeb41c65b4e203e15b65.tar.gz
Normalize handling of Undefined vs EOO/missing in agg
Related tickets: SERVER-6571 replace use of Undefined as missing with EOO SERVER-6471 ignore nullish values in $min and $max accumulators SERVER-6144 divide by zero makes field disappear (this solution isn't final)
Diffstat (limited to 'src/mongo/db/pipeline/accumulator_min_max.cpp')
-rwxr-xr-xsrc/mongo/db/pipeline/accumulator_min_max.cpp10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/mongo/db/pipeline/accumulator_min_max.cpp b/src/mongo/db/pipeline/accumulator_min_max.cpp
index bc48b6fb480..86172cb3338 100755
--- a/src/mongo/db/pipeline/accumulator_min_max.cpp
+++ b/src/mongo/db/pipeline/accumulator_min_max.cpp
@@ -25,17 +25,15 @@ namespace mongo {
verify(vpOperand.size() == 1);
Value prhs(vpOperand[0]->evaluate(pDocument));
- /* if this is the first value, just use it */
- if (pValue.missing())
- pValue = prhs;
- else {
+ // nullish values should have no impact on result
+ if (!prhs.nullish()) {
/* compare with the current value; swap if appropriate */
int cmp = Value::compare(pValue, prhs) * sense;
- if (cmp > 0)
+ if (cmp > 0 || pValue.missing()) // missing is lower than all other values
pValue = prhs;
}
- return pValue;
+ return Value();
}
AccumulatorMinMax::AccumulatorMinMax(int theSense):