summaryrefslogtreecommitdiff
path: root/src/mongo/db/pipeline/accumulator_add_to_set.cpp
diff options
context:
space:
mode:
authorMathias Stearn <mathias@10gen.com>2013-05-30 16:22:49 -0400
committerMathias Stearn <mathias@10gen.com>2013-06-18 12:51:15 -0400
commit4c30d0500b1da673840f0ea12a9277f3803a230f (patch)
treee8b9cb4fa87e6c2fe442eea56271260fdb7cd64e /src/mongo/db/pipeline/accumulator_add_to_set.cpp
parentbe4e909ad1ae382a073f456710052a65c2b5fd39 (diff)
downloadmongo-4c30d0500b1da673840f0ea12a9277f3803a230f.tar.gz
Accumulators are not Expressions so they shouldn't derive
There may be a place for a common parent of "tree-like" things, but Expression is not the correct base. This commit keeps the public API of accumulators the same so consumers don't need to be modified.
Diffstat (limited to 'src/mongo/db/pipeline/accumulator_add_to_set.cpp')
-rw-r--r--src/mongo/db/pipeline/accumulator_add_to_set.cpp24
1 files changed, 7 insertions, 17 deletions
diff --git a/src/mongo/db/pipeline/accumulator_add_to_set.cpp b/src/mongo/db/pipeline/accumulator_add_to_set.cpp
index 7af52df062b..aaf2fc4e6a5 100644
--- a/src/mongo/db/pipeline/accumulator_add_to_set.cpp
+++ b/src/mongo/db/pipeline/accumulator_add_to_set.cpp
@@ -21,13 +21,10 @@
#include "db/pipeline/value.h"
namespace mongo {
- Value AccumulatorAddToSet::evaluate(const Document& pDocument) const {
- verify(vpOperand.size() == 1);
- Value prhs(vpOperand[0]->evaluate(pDocument));
-
+ void AccumulatorAddToSet::processInternal(const Value& input) {
if (!pCtx->getDoingMerge()) {
- if (!prhs.missing()) {
- set.insert(prhs);
+ if (!input.missing()) {
+ set.insert(input);
}
} else {
/*
@@ -36,23 +33,16 @@ namespace mongo {
If we didn't, then we'd get an array of arrays, with one array
from each shard that responds.
*/
- verify(prhs.getType() == Array);
+ verify(input.getType() == Array);
- const vector<Value>& array = prhs.getArray();
+ const vector<Value>& array = input.getArray();
set.insert(array.begin(), array.end());
}
-
- return Value();
}
Value AccumulatorAddToSet::getValue() const {
- vector<Value> valVec;
-
- for (itr = set.begin(); itr != set.end(); ++itr) {
- valVec.push_back(*itr);
- }
-
- return Value(valVec);
+ vector<Value> valVec(set.begin(), set.end());
+ return Value::consume(valVec);
}
AccumulatorAddToSet::AccumulatorAddToSet(