summaryrefslogtreecommitdiff
path: root/src/mongo/db/pipeline/accumulator_push.cpp
diff options
context:
space:
mode:
authorMathias Stearn <mathias@10gen.com>2012-10-26 19:35:31 -0400
committerMathias Stearn <mathias@10gen.com>2012-11-16 17:32:59 -0500
commitffd194f68edf4a61bff35fac591452b715cff849 (patch)
tree67ed1e6300f04d1333fee769e9c1ba2f8b4d41d6 /src/mongo/db/pipeline/accumulator_push.cpp
parent7eb3fc28fbd9cb0464cbf6dba5ffb497ba2088e9 (diff)
downloadmongo-ffd194f68edf4a61bff35fac591452b715cff849.tar.gz
Rewrite Document and Value classes
Diffstat (limited to 'src/mongo/db/pipeline/accumulator_push.cpp')
-rwxr-xr-xsrc/mongo/db/pipeline/accumulator_push.cpp26
1 files changed, 12 insertions, 14 deletions
diff --git a/src/mongo/db/pipeline/accumulator_push.cpp b/src/mongo/db/pipeline/accumulator_push.cpp
index b7a6370d77f..4530b798465 100755
--- a/src/mongo/db/pipeline/accumulator_push.cpp
+++ b/src/mongo/db/pipeline/accumulator_push.cpp
@@ -21,15 +21,16 @@
#include "db/pipeline/value.h"
namespace mongo {
- intrusive_ptr<const Value> AccumulatorPush::evaluate(
- const intrusive_ptr<Document> &pDocument) const {
+ Value AccumulatorPush::evaluate(const Document& pDocument) const {
verify(vpOperand.size() == 1);
- intrusive_ptr<const Value> prhs(vpOperand[0]->evaluate(pDocument));
+ Value prhs(vpOperand[0]->evaluate(pDocument));
- if (prhs->getType() == Undefined)
- ; /* nothing to add to the array */
- else if (!pCtx->getDoingMerge())
+ if (prhs.getType() == Undefined) {
+ /* nothing to add to the array */
+ }
+ else if (!pCtx->getDoingMerge()) {
vpValue.push_back(prhs);
+ }
else {
/*
If we're in the router, we need to take apart the arrays we
@@ -37,19 +38,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(prhs.getType() == Array);
- intrusive_ptr<ValueIterator> pvi(prhs->getArray());
- while(pvi->more()) {
- intrusive_ptr<const Value> pElement(pvi->next());
- vpValue.push_back(pElement);
- }
+ const vector<Value>& vec = prhs.getArray();
+ vpValue.insert(vpValue.end(), vec.begin(), vec.end());
}
- return Value::getNull();
+ return Value();
}
- intrusive_ptr<const Value> AccumulatorPush::getValue() const {
+ Value AccumulatorPush::getValue() const {
return Value::createArray(vpValue);
}