diff options
author | Mathias Stearn <mathias@10gen.com> | 2013-07-03 13:43:31 -0400 |
---|---|---|
committer | Mathias Stearn <mathias@10gen.com> | 2013-07-10 17:17:59 -0400 |
commit | 7d978b9ef92ca75a3b690601e7826a53f796c86a (patch) | |
tree | 799068c7700a5681de28b05e426b1c204db80d82 /src/mongo/db/pipeline/accumulator_min_max.cpp | |
parent | 1571ab85d3ecfd5b21670c00d6d29b6700adb84a (diff) | |
download | mongo-7d978b9ef92ca75a3b690601e7826a53f796c86a.tar.gz |
SERVER-9444 Remove context-awareness from Accumulators to prep $group for Sorter
Diffstat (limited to 'src/mongo/db/pipeline/accumulator_min_max.cpp')
-rw-r--r-- | src/mongo/db/pipeline/accumulator_min_max.cpp | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/src/mongo/db/pipeline/accumulator_min_max.cpp b/src/mongo/db/pipeline/accumulator_min_max.cpp index c3c5a9790f0..ace2cb34af5 100644 --- a/src/mongo/db/pipeline/accumulator_min_max.cpp +++ b/src/mongo/db/pipeline/accumulator_min_max.cpp @@ -21,36 +21,40 @@ namespace mongo { - void AccumulatorMinMax::processInternal(const Value& input) { + void AccumulatorMinMax::processInternal(const Value& input, bool merging) { // nullish values should have no impact on result if (!input.nullish()) { /* compare with the current value; swap if appropriate */ int cmp = Value::compare(_val, input) * _sense; - if (cmp > 0 || _val.missing()) // missing is lower than all other values + if (cmp > 0 || _val.missing()) { // missing is lower than all other values _val = input; + _memUsageBytes = sizeof(*this) + input.getApproximateSize() - sizeof(Value); + } } } - Value AccumulatorMinMax::getValue() const { + Value AccumulatorMinMax::getValue(bool toBeMerged) const { return _val; } AccumulatorMinMax::AccumulatorMinMax(int theSense) :_sense(theSense) - { verify((_sense == 1) || (_sense == -1)); } + { + verify((_sense == 1) || (_sense == -1)); + _memUsageBytes = sizeof(*this); + } + + void AccumulatorMinMax::reset() { + _val = Value(); + _memUsageBytes = sizeof(*this); + } - intrusive_ptr<Accumulator> AccumulatorMinMax::createMin( - const intrusive_ptr<ExpressionContext> &pCtx) { - intrusive_ptr<AccumulatorMinMax> pAccumulator( - new AccumulatorMinMax(1)); - return pAccumulator; + intrusive_ptr<Accumulator> AccumulatorMinMax::createMin() { + return new AccumulatorMinMax(1); } - intrusive_ptr<Accumulator> AccumulatorMinMax::createMax( - const intrusive_ptr<ExpressionContext> &pCtx) { - intrusive_ptr<AccumulatorMinMax> pAccumulator( - new AccumulatorMinMax(-1)); - return pAccumulator; + intrusive_ptr<Accumulator> AccumulatorMinMax::createMax() { + return new AccumulatorMinMax(-1); } const char *AccumulatorMinMax::getOpName() const { |