diff options
Diffstat (limited to 'src/mongo/db/pipeline/accumulator_push.cpp')
-rw-r--r-- | src/mongo/db/pipeline/accumulator_push.cpp | 71 |
1 files changed, 35 insertions, 36 deletions
diff --git a/src/mongo/db/pipeline/accumulator_push.cpp b/src/mongo/db/pipeline/accumulator_push.cpp index e7a2b6b5514..b19ec08f71d 100644 --- a/src/mongo/db/pipeline/accumulator_push.cpp +++ b/src/mongo/db/pipeline/accumulator_push.cpp @@ -34,50 +34,49 @@ namespace mongo { - using boost::intrusive_ptr; - using std::vector; +using boost::intrusive_ptr; +using std::vector; - void AccumulatorPush::processInternal(const Value& input, bool merging) { - if (!merging) { - if (!input.missing()) { - vpValue.push_back(input); - _memUsageBytes += input.getApproximateSize(); - } +void AccumulatorPush::processInternal(const Value& input, bool merging) { + if (!merging) { + if (!input.missing()) { + vpValue.push_back(input); + _memUsageBytes += input.getApproximateSize(); } - else { - // If we're merging, we need to take apart the arrays we - // receive and put their elements into the array we are collecting. - // If we didn't, then we'd get an array of arrays, with one array - // from each merge source. - verify(input.getType() == Array); - - const vector<Value>& vec = input.getArray(); - vpValue.insert(vpValue.end(), vec.begin(), vec.end()); + } else { + // If we're merging, we need to take apart the arrays we + // receive and put their elements into the array we are collecting. + // If we didn't, then we'd get an array of arrays, with one array + // from each merge source. + verify(input.getType() == Array); - for (size_t i=0; i < vec.size(); i++) { - _memUsageBytes += vec[i].getApproximateSize(); - } + const vector<Value>& vec = input.getArray(); + vpValue.insert(vpValue.end(), vec.begin(), vec.end()); + + for (size_t i = 0; i < vec.size(); i++) { + _memUsageBytes += vec[i].getApproximateSize(); } } +} - Value AccumulatorPush::getValue(bool toBeMerged) const { - return Value(vpValue); - } +Value AccumulatorPush::getValue(bool toBeMerged) const { + return Value(vpValue); +} - AccumulatorPush::AccumulatorPush() { - _memUsageBytes = sizeof(*this); - } +AccumulatorPush::AccumulatorPush() { + _memUsageBytes = sizeof(*this); +} - void AccumulatorPush::reset() { - vector<Value>().swap(vpValue); - _memUsageBytes = sizeof(*this); - } +void AccumulatorPush::reset() { + vector<Value>().swap(vpValue); + _memUsageBytes = sizeof(*this); +} - intrusive_ptr<Accumulator> AccumulatorPush::create() { - return new AccumulatorPush(); - } +intrusive_ptr<Accumulator> AccumulatorPush::create() { + return new AccumulatorPush(); +} - const char *AccumulatorPush::getOpName() const { - return "$push"; - } +const char* AccumulatorPush::getOpName() const { + return "$push"; +} } |