summaryrefslogtreecommitdiff
path: root/src/mongo/db/pipeline/accumulator_min_max.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/pipeline/accumulator_min_max.cpp')
-rw-r--r--src/mongo/db/pipeline/accumulator_min_max.cpp63
1 files changed, 31 insertions, 32 deletions
diff --git a/src/mongo/db/pipeline/accumulator_min_max.cpp b/src/mongo/db/pipeline/accumulator_min_max.cpp
index 8f7d857de76..da4f280f797 100644
--- a/src/mongo/db/pipeline/accumulator_min_max.cpp
+++ b/src/mongo/db/pipeline/accumulator_min_max.cpp
@@ -33,45 +33,44 @@
namespace mongo {
- using boost::intrusive_ptr;
+using boost::intrusive_ptr;
- 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
- _val = input;
- _memUsageBytes = sizeof(*this) + input.getApproximateSize() - sizeof(Value);
- }
+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
+ _val = input;
+ _memUsageBytes = sizeof(*this) + input.getApproximateSize() - sizeof(Value);
}
}
+}
- Value AccumulatorMinMax::getValue(bool toBeMerged) const {
- return _val;
- }
+Value AccumulatorMinMax::getValue(bool toBeMerged) const {
+ return _val;
+}
- AccumulatorMinMax::AccumulatorMinMax(Sense sense) :
- _sense(sense) {
- _memUsageBytes = sizeof(*this);
- }
+AccumulatorMinMax::AccumulatorMinMax(Sense sense) : _sense(sense) {
+ _memUsageBytes = sizeof(*this);
+}
- void AccumulatorMinMax::reset() {
- _val = Value();
- _memUsageBytes = sizeof(*this);
- }
+void AccumulatorMinMax::reset() {
+ _val = Value();
+ _memUsageBytes = sizeof(*this);
+}
- intrusive_ptr<Accumulator> AccumulatorMinMax::createMin() {
- return new AccumulatorMinMax(Sense::MIN);
- }
+intrusive_ptr<Accumulator> AccumulatorMinMax::createMin() {
+ return new AccumulatorMinMax(Sense::MIN);
+}
- intrusive_ptr<Accumulator> AccumulatorMinMax::createMax() {
- return new AccumulatorMinMax(Sense::MAX);
- }
+intrusive_ptr<Accumulator> AccumulatorMinMax::createMax() {
+ return new AccumulatorMinMax(Sense::MAX);
+}
- const char *AccumulatorMinMax::getOpName() const {
- if (_sense == 1)
- return "$min";
- return "$max";
- }
+const char* AccumulatorMinMax::getOpName() const {
+ if (_sense == 1)
+ return "$min";
+ return "$max";
+}
}