summaryrefslogtreecommitdiff
path: root/src/mongo/db/pipeline
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/pipeline')
-rw-r--r--src/mongo/db/pipeline/document_source_densify.cpp2
-rw-r--r--src/mongo/db/pipeline/document_source_graph_lookup.cpp2
-rw-r--r--src/mongo/db/pipeline/document_source_group.cpp2
-rw-r--r--src/mongo/db/pipeline/document_source_internal_unpack_bucket_test/optimize_lastpoint_test.cpp4
-rw-r--r--src/mongo/db/pipeline/document_source_lookup.cpp2
-rw-r--r--src/mongo/db/pipeline/document_source_merge.cpp2
-rw-r--r--src/mongo/db/pipeline/document_source_queue.cpp2
-rw-r--r--src/mongo/db/pipeline/document_source_set_window_fields.cpp2
-rw-r--r--src/mongo/db/pipeline/expression.h2
-rw-r--r--src/mongo/db/pipeline/expression_bm.cpp2
-rw-r--r--src/mongo/db/pipeline/expression_convert_test.cpp4
-rw-r--r--src/mongo/db/pipeline/expression_date_test.cpp4
-rw-r--r--src/mongo/db/pipeline/expression_test.cpp2
-rw-r--r--src/mongo/db/pipeline/pipeline_test.cpp2
-rw-r--r--src/mongo/db/pipeline/sharded_agg_helpers.cpp2
-rw-r--r--src/mongo/db/pipeline/window_function/window_function_add_to_set_test.cpp2
-rw-r--r--src/mongo/db/pipeline/window_function/window_function_covariance.cpp2
-rw-r--r--src/mongo/db/pipeline/window_function/window_function_covariance_test.cpp2
-rw-r--r--src/mongo/db/pipeline/window_function/window_function_integral_test.cpp2
-rw-r--r--src/mongo/db/pipeline/window_function/window_function_push_test.cpp2
20 files changed, 23 insertions, 23 deletions
diff --git a/src/mongo/db/pipeline/document_source_densify.cpp b/src/mongo/db/pipeline/document_source_densify.cpp
index addddc34708..427ce8d9da0 100644
--- a/src/mongo/db/pipeline/document_source_densify.cpp
+++ b/src/mongo/db/pipeline/document_source_densify.cpp
@@ -183,7 +183,7 @@ SortPattern getSortPatternForDensify(RangeStatement rangeStatement,
std::vector<SortPatternPart> sortParts;
// We do not add partitions to the sort spec if the range is "full".
if (!stdx::holds_alternative<Full>(rangeStatement.getBounds())) {
- for (auto partition : partitions) {
+ for (const auto& partition : partitions) {
SortPatternPart part;
part.fieldPath = partition.fullPath();
sortParts.push_back(std::move(part));
diff --git a/src/mongo/db/pipeline/document_source_graph_lookup.cpp b/src/mongo/db/pipeline/document_source_graph_lookup.cpp
index 666d8952284..78761b412bd 100644
--- a/src/mongo/db/pipeline/document_source_graph_lookup.cpp
+++ b/src/mongo/db/pipeline/document_source_graph_lookup.cpp
@@ -478,7 +478,7 @@ void DocumentSourceGraphLookUp::performSearch() {
// If _startWith evaluates to an array, treat each value as a separate starting point.
if (startingValue.isArray()) {
- for (auto value : startingValue.getArray()) {
+ for (const auto& value : startingValue.getArray()) {
_frontier.insert(value);
_frontierUsageBytes += value.getApproximateSize();
}
diff --git a/src/mongo/db/pipeline/document_source_group.cpp b/src/mongo/db/pipeline/document_source_group.cpp
index d0fe18d0078..c7ccdaa4d73 100644
--- a/src/mongo/db/pipeline/document_source_group.cpp
+++ b/src/mongo/db/pipeline/document_source_group.cpp
@@ -746,7 +746,7 @@ shared_ptr<Sorter<Value, Value>::Iterator> DocumentSourceGroup::spill() {
_groups->clear();
// Zero out the current per-accumulation statement memory consumption, as the memory has been
// freed by spilling.
- for (auto accum : _accumulatedFields) {
+ for (const auto& accum : _accumulatedFields) {
_memoryTracker.set(accum.fieldName, 0);
}
diff --git a/src/mongo/db/pipeline/document_source_internal_unpack_bucket_test/optimize_lastpoint_test.cpp b/src/mongo/db/pipeline/document_source_internal_unpack_bucket_test/optimize_lastpoint_test.cpp
index a170819aa3c..77cfaadabde 100644
--- a/src/mongo/db/pipeline/document_source_internal_unpack_bucket_test/optimize_lastpoint_test.cpp
+++ b/src/mongo/db/pipeline/document_source_internal_unpack_bucket_test/optimize_lastpoint_test.cpp
@@ -44,7 +44,7 @@ void assertExpectedLastpointOpt(const boost::intrusive_ptr<ExpressionContext> ex
const std::vector<std::string>& expectedPipelineStrs,
const bool expectedSuccess = true) {
std::vector<BSONObj> inputPipelineBson;
- for (auto stageStr : inputPipelineStrs) {
+ for (const auto& stageStr : inputPipelineStrs) {
inputPipelineBson.emplace_back(fromjson(stageStr));
}
@@ -62,7 +62,7 @@ void assertExpectedLastpointOpt(const boost::intrusive_ptr<ExpressionContext> ex
// Assert the pipeline is unchanged.
auto serializedItr = serialized.begin();
- for (auto stageStr : expectedPipelineStrs) {
+ for (const auto& stageStr : expectedPipelineStrs) {
auto expectedStageBson = fromjson(stageStr);
ASSERT_BSONOBJ_EQ(*serializedItr, expectedStageBson);
++serializedItr;
diff --git a/src/mongo/db/pipeline/document_source_lookup.cpp b/src/mongo/db/pipeline/document_source_lookup.cpp
index 11fe6ebdf4a..20253fec682 100644
--- a/src/mongo/db/pipeline/document_source_lookup.cpp
+++ b/src/mongo/db/pipeline/document_source_lookup.cpp
@@ -1025,7 +1025,7 @@ void DocumentSourceLookUp::serializeToArray(
}
if (!hasLocalFieldForeignFieldJoin() || pipeline.size() > 0) {
MutableDocument exprList;
- for (auto letVar : _letVariables) {
+ for (const auto& letVar : _letVariables) {
exprList.addField(letVar.name,
letVar.expression->serialize(static_cast<bool>(explain)));
}
diff --git a/src/mongo/db/pipeline/document_source_merge.cpp b/src/mongo/db/pipeline/document_source_merge.cpp
index d9f6d06179b..d48bbe5491f 100644
--- a/src/mongo/db/pipeline/document_source_merge.cpp
+++ b/src/mongo/db/pipeline/document_source_merge.cpp
@@ -552,7 +552,7 @@ Value DocumentSourceMerge::serialize(boost::optional<ExplainOptions::Verbosity>
spec.setWhenNotMatched(_descriptor.mode.second);
spec.setOn([&]() {
std::vector<std::string> mergeOnFields;
- for (auto path : _mergeOnFields) {
+ for (const auto& path : _mergeOnFields) {
mergeOnFields.push_back(path.fullPath());
}
return mergeOnFields;
diff --git a/src/mongo/db/pipeline/document_source_queue.cpp b/src/mongo/db/pipeline/document_source_queue.cpp
index c724db5ae10..77efefd5249 100644
--- a/src/mongo/db/pipeline/document_source_queue.cpp
+++ b/src/mongo/db/pipeline/document_source_queue.cpp
@@ -82,7 +82,7 @@ DocumentSource::GetNextResult DocumentSourceQueue::doGetNext() {
Value DocumentSourceQueue::serialize(boost::optional<ExplainOptions::Verbosity> explain) const {
ValueArrayStream vals;
- for (auto elem : _queue) {
+ for (const auto& elem : _queue) {
vals << elem.getDocument().getOwned();
}
return Value(DOC(kStageName << vals.done()));
diff --git a/src/mongo/db/pipeline/document_source_set_window_fields.cpp b/src/mongo/db/pipeline/document_source_set_window_fields.cpp
index f21394ae338..0200ce21cc7 100644
--- a/src/mongo/db/pipeline/document_source_set_window_fields.cpp
+++ b/src/mongo/db/pipeline/document_source_set_window_fields.cpp
@@ -239,7 +239,7 @@ list<intrusive_ptr<DocumentSource>> document_source_set_window_fields::create(
combined.emplace_back(std::move(part));
}
if (sortBy) {
- for (auto part : *sortBy) {
+ for (const auto& part : *sortBy) {
combined.push_back(part);
}
}
diff --git a/src/mongo/db/pipeline/expression.h b/src/mongo/db/pipeline/expression.h
index 918173b50ba..83ac940f999 100644
--- a/src/mongo/db/pipeline/expression.h
+++ b/src/mongo/db/pipeline/expression.h
@@ -559,7 +559,7 @@ public:
// Verify that '_output' produces an array and pass each element to 'process'.
auto output = _output->evaluate(root, variables);
uassert(5788200, "Input must be an array", output.isArray());
- for (auto& item : output.getArray()) {
+ for (const auto& item : output.getArray()) {
accum.process(item, false);
}
return accum.getValue(false);
diff --git a/src/mongo/db/pipeline/expression_bm.cpp b/src/mongo/db/pipeline/expression_bm.cpp
index 6978d426c42..0d2a2e798c3 100644
--- a/src/mongo/db/pipeline/expression_bm.cpp
+++ b/src/mongo/db/pipeline/expression_bm.cpp
@@ -57,7 +57,7 @@ void benchmarkExpression(BSONObj expressionSpec,
// Run the test.
for (auto keepRunning : state) {
- for (auto document : documents) {
+ for (const auto& document : documents) {
benchmark::DoNotOptimize(expression->evaluate(document, variables));
}
benchmark::ClobberMemory();
diff --git a/src/mongo/db/pipeline/expression_convert_test.cpp b/src/mongo/db/pipeline/expression_convert_test.cpp
index 678c29b5b16..4bf42b9b8a5 100644
--- a/src/mongo/db/pipeline/expression_convert_test.cpp
+++ b/src/mongo/db/pipeline/expression_convert_test.cpp
@@ -276,7 +276,7 @@ TEST_F(ExpressionConvertTest, UnsupportedConversionShouldThrowUnlessOnErrorProvi
};
// Attempt all of the unsupported conversions listed above.
- for (auto conversion : unsupportedConversions) {
+ for (const auto& conversion : unsupportedConversions) {
auto inputValue = conversion.first;
auto targetTypeName = conversion.second;
@@ -299,7 +299,7 @@ TEST_F(ExpressionConvertTest, UnsupportedConversionShouldThrowUnlessOnErrorProvi
}
// Attempt them again, this time with an "onError" value.
- for (auto conversion : unsupportedConversions) {
+ for (const auto& conversion : unsupportedConversions) {
auto inputValue = conversion.first;
auto targetTypeName = conversion.second;
diff --git a/src/mongo/db/pipeline/expression_date_test.cpp b/src/mongo/db/pipeline/expression_date_test.cpp
index 97ec344fd9f..1a76e1e1838 100644
--- a/src/mongo/db/pipeline/expression_date_test.cpp
+++ b/src/mongo/db/pipeline/expression_date_test.cpp
@@ -1350,7 +1350,7 @@ TEST_F(ExpressionDateFromStringTest, ReturnsOnErrorForParseFailures) {
std::vector<std::string> invalidDates = {
"60.Monday1770/06:59", "July 4th", "12:50:53", "2017, 12:50:53"};
- for (auto date : invalidDates) {
+ for (const auto& date : invalidDates) {
auto spec = BSON("$dateFromString" << BSON("dateString" << date << "onError"
<< "Error default"));
auto dateExp = Expression::parseExpression(expCtx.get(), spec, expCtx->variablesParseState);
@@ -1363,7 +1363,7 @@ TEST_F(ExpressionDateFromStringTest, ReturnsOnErrorForFormatMismatch) {
const std::string date = "2018/02/06";
std::vector<std::string> unmatchedFormats = {"%Y", "%Y/%m/%d:%H", "Y/m/d"};
- for (auto format : unmatchedFormats) {
+ for (const auto& format : unmatchedFormats) {
auto spec =
BSON("$dateFromString" << BSON("dateString" << date << "format" << format << "onError"
<< "Error default"));
diff --git a/src/mongo/db/pipeline/expression_test.cpp b/src/mongo/db/pipeline/expression_test.cpp
index 2a9978e1bba..fe8a5f19c6a 100644
--- a/src/mongo/db/pipeline/expression_test.cpp
+++ b/src/mongo/db/pipeline/expression_test.cpp
@@ -3916,7 +3916,7 @@ TEST(ExpressionAddTest, VerifyNoDoubleDoubleSummation) {
-9.779323414999364, -546522170658.2997};
double straightSum = 0.0;
DoubleDoubleSummation compensatedSum;
- for (auto x : doubleValues) {
+ for (const auto& x : doubleValues) {
compensatedSum.addDouble(x.getDouble());
straightSum += x.getDouble();
}
diff --git a/src/mongo/db/pipeline/pipeline_test.cpp b/src/mongo/db/pipeline/pipeline_test.cpp
index 62c89ef192f..ed4c9c4cc69 100644
--- a/src/mongo/db/pipeline/pipeline_test.cpp
+++ b/src/mongo/db/pipeline/pipeline_test.cpp
@@ -3292,7 +3292,7 @@ void assertTwoPipelinesOptimizeAndMergeTo(const std::string inputPipe1,
auto pipeline2 = getOptimizedPipeline(input2Bson);
// Merge the pipelines
- for (auto source : pipeline2->getSources()) {
+ for (const auto& source : pipeline2->getSources()) {
pipeline1->pushBack(source);
}
pipeline1->optimizePipeline();
diff --git a/src/mongo/db/pipeline/sharded_agg_helpers.cpp b/src/mongo/db/pipeline/sharded_agg_helpers.cpp
index 68d03d0c96a..e9a7c0c76a8 100644
--- a/src/mongo/db/pipeline/sharded_agg_helpers.cpp
+++ b/src/mongo/db/pipeline/sharded_agg_helpers.cpp
@@ -1305,7 +1305,7 @@ partitionCursors(std::vector<OwnedRemoteCursor> ownedCursors) {
*/
void injectMetaCursor(Pipeline* mergePipeline, std::vector<OwnedRemoteCursor> metaCursors) {
// Provide the "meta" cursors to the $setVariableFromSubPipeline stage.
- for (auto source : mergePipeline->getSources()) {
+ for (const auto& source : mergePipeline->getSources()) {
if (auto* setVarStage =
dynamic_cast<DocumentSourceSetVariableFromSubPipeline*>(source.get())) {
diff --git a/src/mongo/db/pipeline/window_function/window_function_add_to_set_test.cpp b/src/mongo/db/pipeline/window_function/window_function_add_to_set_test.cpp
index d7a2e80dea9..25e444826a6 100644
--- a/src/mongo/db/pipeline/window_function/window_function_add_to_set_test.cpp
+++ b/src/mongo/db/pipeline/window_function/window_function_add_to_set_test.cpp
@@ -42,7 +42,7 @@ public:
WindowFunctionAddToSetTest() : expCtx(getExpCtx()), addToSet(expCtx.get()) {}
void addValuesToWindow(const std::vector<Value>& values) {
- for (auto val : values)
+ for (const auto& val : values)
addToSet.add(val);
}
diff --git a/src/mongo/db/pipeline/window_function/window_function_covariance.cpp b/src/mongo/db/pipeline/window_function/window_function_covariance.cpp
index cab8fdb6193..c9b56a7d1d7 100644
--- a/src/mongo/db/pipeline/window_function/window_function_covariance.cpp
+++ b/src/mongo/db/pipeline/window_function/window_function_covariance.cpp
@@ -47,7 +47,7 @@ bool validateValue(const Value& val) {
Value convertNonFiniteInputValue(Value value) {
int posCnt = 0, negCnt = 0, nanCnt = 0;
bool isDecimal = false;
- for (auto val : value.getArray()) {
+ for (const auto& val : value.getArray()) {
if (val.isNaN()) {
nanCnt++;
} else if (val.getType() == NumberDecimal) {
diff --git a/src/mongo/db/pipeline/window_function/window_function_covariance_test.cpp b/src/mongo/db/pipeline/window_function/window_function_covariance_test.cpp
index 9d1b296a1ef..a170bb97be8 100644
--- a/src/mongo/db/pipeline/window_function/window_function_covariance_test.cpp
+++ b/src/mongo/db/pipeline/window_function/window_function_covariance_test.cpp
@@ -53,7 +53,7 @@ public:
void addToWindowCovariance(WindowFunctionCovariance* covariance,
const std::vector<Value>& valToAdd) {
- for (auto val : valToAdd) {
+ for (const auto& val : valToAdd) {
covariance->add(val);
}
}
diff --git a/src/mongo/db/pipeline/window_function/window_function_integral_test.cpp b/src/mongo/db/pipeline/window_function/window_function_integral_test.cpp
index c929bfa478c..6e6db7086c4 100644
--- a/src/mongo/db/pipeline/window_function/window_function_integral_test.cpp
+++ b/src/mongo/db/pipeline/window_function/window_function_integral_test.cpp
@@ -43,7 +43,7 @@ public:
WindowFunctionIntegralTest() : expCtx(getExpCtx()), integral(expCtx.get()) {}
void addValuesToWindow(const std::vector<Value>& values) {
- for (auto val : values)
+ for (const auto& val : values)
integral.add(val);
}
diff --git a/src/mongo/db/pipeline/window_function/window_function_push_test.cpp b/src/mongo/db/pipeline/window_function/window_function_push_test.cpp
index a7790ee22e6..ac41abe6a67 100644
--- a/src/mongo/db/pipeline/window_function/window_function_push_test.cpp
+++ b/src/mongo/db/pipeline/window_function/window_function_push_test.cpp
@@ -42,7 +42,7 @@ public:
WindowFunctionPushTest() : expCtx(getExpCtx()), push(expCtx.get()) {}
void addValuesToWindow(const std::vector<Value>& values) {
- for (auto val : values)
+ for (const auto& val : values)
push.add(val);
}