summaryrefslogtreecommitdiff
path: root/src/mongo/db/pipeline/accumulator_first.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_first.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_first.cpp')
-rwxr-xr-xsrc/mongo/db/pipeline/accumulator_first.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/mongo/db/pipeline/accumulator_first.cpp b/src/mongo/db/pipeline/accumulator_first.cpp
index b226fb552d6..ce53cccd365 100755
--- a/src/mongo/db/pipeline/accumulator_first.cpp
+++ b/src/mongo/db/pipeline/accumulator_first.cpp
@@ -25,15 +25,19 @@ namespace mongo {
verify(vpOperand.size() == 1);
/* only remember the first value seen */
- if (pValue.missing())
+ if (!_haveFirst) {
+ // can't use pValue.missing() since we want the first value even if missing
+ _haveFirst = true;
pValue = vpOperand[0]->evaluate(pDocument);
+ }
return pValue;
}
- AccumulatorFirst::AccumulatorFirst():
- AccumulatorSingleValue() {
- }
+ AccumulatorFirst::AccumulatorFirst()
+ : AccumulatorSingleValue()
+ , _haveFirst(false)
+ {}
intrusive_ptr<Accumulator> AccumulatorFirst::create(
const intrusive_ptr<ExpressionContext> &pCtx) {