summaryrefslogtreecommitdiff
path: root/src/mongo/db/pipeline/accumulator_add_to_set.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/pipeline/accumulator_add_to_set.cpp')
-rw-r--r--src/mongo/db/pipeline/accumulator_add_to_set.cpp75
1 files changed, 37 insertions, 38 deletions
diff --git a/src/mongo/db/pipeline/accumulator_add_to_set.cpp b/src/mongo/db/pipeline/accumulator_add_to_set.cpp
index bd151964ffa..bf2bc183afd 100644
--- a/src/mongo/db/pipeline/accumulator_add_to_set.cpp
+++ b/src/mongo/db/pipeline/accumulator_add_to_set.cpp
@@ -34,53 +34,52 @@
namespace mongo {
- using boost::intrusive_ptr;
- using std::vector;
+using boost::intrusive_ptr;
+using std::vector;
- void AccumulatorAddToSet::processInternal(const Value& input, bool merging) {
- if (!merging) {
- if (!input.missing()) {
- bool inserted = set.insert(input).second;
- if (inserted) {
- _memUsageBytes += input.getApproximateSize();
- }
+void AccumulatorAddToSet::processInternal(const Value& input, bool merging) {
+ if (!merging) {
+ if (!input.missing()) {
+ bool inserted = set.insert(input).second;
+ if (inserted) {
+ _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>& array = input.getArray();
- for (size_t i=0; i < array.size(); i++) {
- bool inserted = set.insert(array[i]).second;
- if (inserted) {
- _memUsageBytes += array[i].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>& array = input.getArray();
+ for (size_t i = 0; i < array.size(); i++) {
+ bool inserted = set.insert(array[i]).second;
+ if (inserted) {
+ _memUsageBytes += array[i].getApproximateSize();
}
}
}
+}
- Value AccumulatorAddToSet::getValue(bool toBeMerged) const {
- return Value(vector<Value>(set.begin(), set.end()));
- }
+Value AccumulatorAddToSet::getValue(bool toBeMerged) const {
+ return Value(vector<Value>(set.begin(), set.end()));
+}
- AccumulatorAddToSet::AccumulatorAddToSet() {
- _memUsageBytes = sizeof(*this);
- }
+AccumulatorAddToSet::AccumulatorAddToSet() {
+ _memUsageBytes = sizeof(*this);
+}
- void AccumulatorAddToSet::reset() {
- SetType().swap(set);
- _memUsageBytes = sizeof(*this);
- }
+void AccumulatorAddToSet::reset() {
+ SetType().swap(set);
+ _memUsageBytes = sizeof(*this);
+}
- intrusive_ptr<Accumulator> AccumulatorAddToSet::create() {
- return new AccumulatorAddToSet();
- }
+intrusive_ptr<Accumulator> AccumulatorAddToSet::create() {
+ return new AccumulatorAddToSet();
+}
- const char *AccumulatorAddToSet::getOpName() const {
- return "$addToSet";
- }
+const char* AccumulatorAddToSet::getOpName() const {
+ return "$addToSet";
+}
}