summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmr Elhelw <amr.elhelw@mongodb.com>2023-03-13 21:37:17 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2023-03-14 02:26:43 +0000
commitb97c66ded102f70b88bbcb2d75d7309dd73c0910 (patch)
tree0c1c499586c3a736f252c15eca6f9ac9cf8ae8f7
parent2d24e77b9576d0b2f4320810f22c2b81abaaf57f (diff)
downloadmongo-b97c66ded102f70b88bbcb2d75d7309dd73c0910.tar.gz
SERVER-54578 Rename MatchExpression::shallowClone() to MatchExpression::clone()
-rw-r--r--src/mongo/db/exec/bucket_unpacker.cpp4
-rw-r--r--src/mongo/db/matcher/expression.h10
-rw-r--r--src/mongo/db/matcher/expression_algo.cpp16
-rw-r--r--src/mongo/db/matcher/expression_algo_test.cpp2
-rw-r--r--src/mongo/db/matcher/expression_always_boolean.h4
-rw-r--r--src/mongo/db/matcher/expression_always_boolean_test.cpp4
-rw-r--r--src/mongo/db/matcher/expression_arity.h5
-rw-r--r--src/mongo/db/matcher/expression_array.h10
-rw-r--r--src/mongo/db/matcher/expression_expr.cpp2
-rw-r--r--src/mongo/db/matcher/expression_expr.h2
-rw-r--r--src/mongo/db/matcher/expression_expr_test.cpp6
-rw-r--r--src/mongo/db/matcher/expression_geo.cpp4
-rw-r--r--src/mongo/db/matcher/expression_geo.h6
-rw-r--r--src/mongo/db/matcher/expression_internal_bucket_geo_within.cpp2
-rw-r--r--src/mongo/db/matcher/expression_internal_bucket_geo_within.h2
-rw-r--r--src/mongo/db/matcher/expression_internal_expr_comparison.h2
-rw-r--r--src/mongo/db/matcher/expression_internal_expr_eq_test.cpp2
-rw-r--r--src/mongo/db/matcher/expression_leaf.cpp4
-rw-r--r--src/mongo/db/matcher/expression_leaf.h26
-rw-r--r--src/mongo/db/matcher/expression_text.cpp2
-rw-r--r--src/mongo/db/matcher/expression_text.h2
-rw-r--r--src/mongo/db/matcher/expression_text_noop.cpp2
-rw-r--r--src/mongo/db/matcher/expression_text_noop.h2
-rw-r--r--src/mongo/db/matcher/expression_tree.h16
-rw-r--r--src/mongo/db/matcher/expression_tree_test.cpp6
-rw-r--r--src/mongo/db/matcher/expression_type.h10
-rw-r--r--src/mongo/db/matcher/expression_where.cpp2
-rw-r--r--src/mongo/db/matcher/expression_where.h2
-rw-r--r--src/mongo/db/matcher/expression_where_noop.cpp2
-rw-r--r--src/mongo/db/matcher/expression_where_noop.h2
-rw-r--r--src/mongo/db/matcher/expression_with_placeholder.h4
-rw-r--r--src/mongo/db/matcher/rewrite_expr.h2
-rw-r--r--src/mongo/db/matcher/schema/expression_internal_schema_all_elem_match_from_index.cpp5
-rw-r--r--src/mongo/db/matcher/schema/expression_internal_schema_all_elem_match_from_index.h2
-rw-r--r--src/mongo/db/matcher/schema/expression_internal_schema_allowed_properties.cpp7
-rw-r--r--src/mongo/db/matcher/schema/expression_internal_schema_allowed_properties.h2
-rw-r--r--src/mongo/db/matcher/schema/expression_internal_schema_allowed_properties_test.cpp4
-rw-r--r--src/mongo/db/matcher/schema/expression_internal_schema_cond_test.cpp2
-rw-r--r--src/mongo/db/matcher/schema/expression_internal_schema_eq.cpp2
-rw-r--r--src/mongo/db/matcher/schema/expression_internal_schema_eq.h2
-rw-r--r--src/mongo/db/matcher/schema/expression_internal_schema_eq_test.cpp2
-rw-r--r--src/mongo/db/matcher/schema/expression_internal_schema_fmod.h2
-rw-r--r--src/mongo/db/matcher/schema/expression_internal_schema_match_array_index.cpp5
-rw-r--r--src/mongo/db/matcher/schema/expression_internal_schema_match_array_index.h2
-rw-r--r--src/mongo/db/matcher/schema/expression_internal_schema_match_array_index_test.cpp2
-rw-r--r--src/mongo/db/matcher/schema/expression_internal_schema_max_items.h2
-rw-r--r--src/mongo/db/matcher/schema/expression_internal_schema_max_length.h2
-rw-r--r--src/mongo/db/matcher/schema/expression_internal_schema_max_properties.h2
-rw-r--r--src/mongo/db/matcher/schema/expression_internal_schema_min_items.h2
-rw-r--r--src/mongo/db/matcher/schema/expression_internal_schema_min_length.h2
-rw-r--r--src/mongo/db/matcher/schema/expression_internal_schema_min_properties.h2
-rw-r--r--src/mongo/db/matcher/schema/expression_internal_schema_object_match.cpp4
-rw-r--r--src/mongo/db/matcher/schema/expression_internal_schema_object_match.h2
-rw-r--r--src/mongo/db/matcher/schema/expression_internal_schema_root_doc_eq.cpp2
-rw-r--r--src/mongo/db/matcher/schema/expression_internal_schema_root_doc_eq.h2
-rw-r--r--src/mongo/db/matcher/schema/expression_internal_schema_root_doc_eq_test.cpp2
-rw-r--r--src/mongo/db/matcher/schema/expression_internal_schema_unique_items.cpp2
-rw-r--r--src/mongo/db/matcher/schema/expression_internal_schema_unique_items.h2
-rw-r--r--src/mongo/db/matcher/schema/expression_internal_schema_xor.h4
-rw-r--r--src/mongo/db/matcher/schema/expression_internal_schema_xor_test.cpp6
-rw-r--r--src/mongo/db/ops/parsed_delete.cpp2
-rw-r--r--src/mongo/db/pipeline/change_stream_rewrite_helpers.cpp2
-rw-r--r--src/mongo/db/pipeline/document_source_change_stream_oplog_match.cpp2
-rw-r--r--src/mongo/db/query/canonical_query.cpp2
-rw-r--r--src/mongo/db/query/index_tag.cpp2
-rw-r--r--src/mongo/db/query/plan_enumerator.cpp2
-rw-r--r--src/mongo/db/query/planner_access.cpp12
-rw-r--r--src/mongo/db/query/planner_analysis.cpp4
-rw-r--r--src/mongo/db/query/projection_parser.cpp2
-rw-r--r--src/mongo/db/query/query_planner.cpp6
-rw-r--r--src/mongo/db/query/query_planner_test_lib.cpp2
-rw-r--r--src/mongo/db/query/query_solution.cpp2
-rw-r--r--src/mongo/db/query/query_solution.h6
73 files changed, 147 insertions, 143 deletions
diff --git a/src/mongo/db/exec/bucket_unpacker.cpp b/src/mongo/db/exec/bucket_unpacker.cpp
index 90c59c8570e..c76309fd0cf 100644
--- a/src/mongo/db/exec/bucket_unpacker.cpp
+++ b/src/mongo/db/exec/bucket_unpacker.cpp
@@ -691,11 +691,11 @@ BucketSpec::BucketPredicate BucketSpec::createPredicatesOnBucketLevelField(
return handleIneligible(policy, matchExpr, "cannot handle an excluded meta field");
if (expression::hasOnlyRenameableMatchExpressionChildren(*matchExpr)) {
- auto looseResult = matchExpr->shallowClone();
+ auto looseResult = matchExpr->clone();
expression::applyRenamesToExpression(
looseResult.get(),
{{bucketSpec.metaField().value(), timeseries::kBucketMetaFieldName.toString()}});
- auto tightResult = looseResult->shallowClone();
+ auto tightResult = looseResult->clone();
return {std::move(looseResult), std::move(tightResult)};
} else {
return {nullptr, nullptr};
diff --git a/src/mongo/db/matcher/expression.h b/src/mongo/db/matcher/expression.h
index afc50fe73f0..a8923e47abb 100644
--- a/src/mongo/db/matcher/expression.h
+++ b/src/mongo/db/matcher/expression.h
@@ -408,7 +408,15 @@ public:
* also ensure that the buffer held by the underlying BSONObj will not be destroyed during the
* lifetime of the clone.
*/
- virtual std::unique_ptr<MatchExpression> shallowClone() const = 0;
+ virtual std::unique_ptr<MatchExpression> clone() const = 0;
+
+ /**
+ * Temporary method to allow for calling shallowClone() from the enterprise module. This will
+ * be removed in the next PR.
+ */
+ std::unique_ptr<MatchExpression> shallowClone() const {
+ return clone();
+ }
// XXX document
virtual bool equivalent(const MatchExpression* other) const = 0;
diff --git a/src/mongo/db/matcher/expression_algo.cpp b/src/mongo/db/matcher/expression_algo.cpp
index befb3ae39e2..0ba3448ade5 100644
--- a/src/mongo/db/matcher/expression_algo.cpp
+++ b/src/mongo/db/matcher/expression_algo.cpp
@@ -477,9 +477,9 @@ std::unique_ptr<MatchExpression> tryAddExpr(StringData path,
const MatchExpression* me,
StringMap<std::unique_ptr<MatchExpression>>& out) {
if (FieldRef(path).hasNumericPathComponents())
- return me->shallowClone();
+ return me->clone();
- addExpr(path, me->shallowClone(), out);
+ addExpr(path, me->clone(), out);
return nullptr;
}
@@ -539,14 +539,14 @@ std::unique_ptr<MatchExpression> splitMatchExpressionForColumns(
case MatchExpression::GTE: {
auto sub = checked_cast<const ComparisonMatchExpressionBase*>(me);
if (!canCompareWith(sub->getData(), me->matchType() == MatchExpression::EQ))
- return me->shallowClone();
+ return me->clone();
return tryAddExpr(sub->path(), me, out);
}
case MatchExpression::MATCH_IN: {
auto sub = checked_cast<const InMatchExpression*>(me);
if (sub->hasNonScalarOrNonEmptyValues()) {
- return me->shallowClone();
+ return me->clone();
}
return tryAddExpr(sub->path(), me, out);
}
@@ -581,13 +581,13 @@ std::unique_ptr<MatchExpression> splitMatchExpressionForColumns(
// would manifest as non-null residual.
auto sub = checked_cast<const NotMatchExpression*>(me)->getChild(0);
if (sub->matchType() == MatchExpression::AND) {
- return me->shallowClone();
+ return me->clone();
}
StringMap<std::unique_ptr<MatchExpression>> outSub;
StringMap<std::unique_ptr<MatchExpression>> pendingSub;
auto residual = splitMatchExpressionForColumns(sub, outSub, pendingSub);
if (residual || !pendingSub.empty()) {
- return me->shallowClone();
+ return me->clone();
}
uassert(7040600, "Should have exactly one path under $not", outSub.size() == 1);
return tryAddExpr(outSub.begin()->first /* path */, me, pending);
@@ -633,7 +633,7 @@ std::unique_ptr<MatchExpression> splitMatchExpressionForColumns(
case MatchExpression::SIZE:
case MatchExpression::TEXT:
case MatchExpression::WHERE:
- return me->shallowClone();
+ return me->clone();
}
MONGO_UNREACHABLE;
}
@@ -900,7 +900,7 @@ std::pair<unique_ptr<MatchExpression>, unique_ptr<MatchExpression>> splitMatchEx
const OrderedPathSet& fields,
const StringMap<std::string>& renames,
ShouldSplitExprFunc func /*= isIndependentOf */) {
- auto splitExpr = splitMatchExpressionByFunction(expr->shallowClone(), fields, func);
+ auto splitExpr = splitMatchExpressionByFunction(expr->clone(), fields, func);
if (splitExpr.first) {
// If we get attemptedButFailedRenames == true, then it means we could not apply renames
// though there's sub-path match. In such a case, returns the original expression as the
diff --git a/src/mongo/db/matcher/expression_algo_test.cpp b/src/mongo/db/matcher/expression_algo_test.cpp
index 03bf881ffbb..f2032fcdfd8 100644
--- a/src/mongo/db/matcher/expression_algo_test.cpp
+++ b/src/mongo/db/matcher/expression_algo_test.cpp
@@ -1821,7 +1821,7 @@ TEST(SplitMatchExpression, ShouldSplitOutAndRenameJsonSchemaPatternByIsOnlyDepen
ParsedMatchExpressionForTest matcher(
R"({$jsonSchema: {properties: {a: {pattern: "[0-9]*"}}}})");
auto originalExpr = matcher.release();
- auto originalExprCopy = originalExpr->shallowClone();
+ auto originalExprCopy = originalExpr->clone();
// $jsonSchema expression will be split out by the meta field "a" and the meta field "a" will be
// renamed to "meta".
diff --git a/src/mongo/db/matcher/expression_always_boolean.h b/src/mongo/db/matcher/expression_always_boolean.h
index 054b9b417ca..606895887dd 100644
--- a/src/mongo/db/matcher/expression_always_boolean.h
+++ b/src/mongo/db/matcher/expression_always_boolean.h
@@ -115,7 +115,7 @@ public:
return kName;
}
- std::unique_ptr<MatchExpression> shallowClone() const final {
+ std::unique_ptr<MatchExpression> clone() const final {
return std::make_unique<AlwaysFalseMatchExpression>(_errorAnnotation);
}
@@ -143,7 +143,7 @@ public:
return kName;
}
- std::unique_ptr<MatchExpression> shallowClone() const final {
+ std::unique_ptr<MatchExpression> clone() const final {
return std::make_unique<AlwaysTrueMatchExpression>(_errorAnnotation);
}
diff --git a/src/mongo/db/matcher/expression_always_boolean_test.cpp b/src/mongo/db/matcher/expression_always_boolean_test.cpp
index 3290f5079a0..899c6fe1b12 100644
--- a/src/mongo/db/matcher/expression_always_boolean_test.cpp
+++ b/src/mongo/db/matcher/expression_always_boolean_test.cpp
@@ -49,7 +49,7 @@ TEST(AlwaysFalseMatchExpression, RejectsAllObjects) {
TEST(AlwaysFalseMatchExpression, EquivalentReturnsCorrectResults) {
auto falseExpr = std::make_unique<AlwaysFalseMatchExpression>();
ASSERT_TRUE(falseExpr->equivalent(falseExpr.get()));
- ASSERT_TRUE(falseExpr->equivalent(falseExpr->shallowClone().get()));
+ ASSERT_TRUE(falseExpr->equivalent(falseExpr->clone().get()));
AlwaysTrueMatchExpression trueExpr;
ASSERT_FALSE(falseExpr->equivalent(&trueExpr));
@@ -68,7 +68,7 @@ TEST(AlwaysTrueMatchExpression, AcceptsAllObjects) {
TEST(AlwaysTrueMatchExpression, EquivalentReturnsCorrectResults) {
auto trueExpr = std::make_unique<AlwaysTrueMatchExpression>();
ASSERT_TRUE(trueExpr->equivalent(trueExpr.get()));
- ASSERT_TRUE(trueExpr->equivalent(trueExpr->shallowClone().get()));
+ ASSERT_TRUE(trueExpr->equivalent(trueExpr->clone().get()));
AlwaysFalseMatchExpression falseExpr;
ASSERT_FALSE(trueExpr->equivalent(&falseExpr));
diff --git a/src/mongo/db/matcher/expression_arity.h b/src/mongo/db/matcher/expression_arity.h
index e699b6ae363..ebe68bd9255 100644
--- a/src/mongo/db/matcher/expression_arity.h
+++ b/src/mongo/db/matcher/expression_arity.h
@@ -121,14 +121,13 @@ public:
/**
* Clones this MatchExpression by recursively cloning each sub-expression.
*/
- std::unique_ptr<MatchExpression> shallowClone() const final {
+ std::unique_ptr<MatchExpression> clone() const final {
std::array<std::unique_ptr<MatchExpression>, nargs> clonedExpressions;
std::transform(_expressions.begin(),
_expressions.end(),
clonedExpressions.begin(),
[](const auto& orig) {
- return orig ? orig->shallowClone()
- : std::unique_ptr<MatchExpression>(nullptr);
+ return orig ? orig->clone() : std::unique_ptr<MatchExpression>(nullptr);
});
std::unique_ptr<T> clone =
std::make_unique<T>(std::move(clonedExpressions), _errorAnnotation);
diff --git a/src/mongo/db/matcher/expression_array.h b/src/mongo/db/matcher/expression_array.h
index 4c26756d33f..e96358488fd 100644
--- a/src/mongo/db/matcher/expression_array.h
+++ b/src/mongo/db/matcher/expression_array.h
@@ -78,10 +78,10 @@ public:
bool matchesArray(const BSONObj& anArray, MatchDetails* details) const;
- virtual std::unique_ptr<MatchExpression> shallowClone() const {
+ virtual std::unique_ptr<MatchExpression> clone() const {
std::unique_ptr<ElemMatchObjectMatchExpression> e =
std::make_unique<ElemMatchObjectMatchExpression>(
- path(), _sub->shallowClone(), _errorAnnotation);
+ path(), _sub->clone(), _errorAnnotation);
if (getTag()) {
e->setTag(getTag()->clone());
}
@@ -144,11 +144,11 @@ public:
bool matchesArray(const BSONObj& anArray, MatchDetails* details) const;
- virtual std::unique_ptr<MatchExpression> shallowClone() const {
+ virtual std::unique_ptr<MatchExpression> clone() const {
std::unique_ptr<ElemMatchValueMatchExpression> e =
std::make_unique<ElemMatchValueMatchExpression>(path(), _errorAnnotation);
for (size_t i = 0; i < _subs.size(); ++i) {
- e->add(_subs[i]->shallowClone());
+ e->add(_subs[i]->clone());
}
if (getTag()) {
e->setTag(getTag()->clone());
@@ -200,7 +200,7 @@ public:
int size,
clonable_ptr<ErrorAnnotation> annotation = nullptr);
- std::unique_ptr<MatchExpression> shallowClone() const final {
+ std::unique_ptr<MatchExpression> clone() const final {
std::unique_ptr<SizeMatchExpression> e =
std::make_unique<SizeMatchExpression>(path(), _size, _errorAnnotation);
if (getTag()) {
diff --git a/src/mongo/db/matcher/expression_expr.cpp b/src/mongo/db/matcher/expression_expr.cpp
index c8f6a2aad9e..7eae4170ee5 100644
--- a/src/mongo/db/matcher/expression_expr.cpp
+++ b/src/mongo/db/matcher/expression_expr.cpp
@@ -111,7 +111,7 @@ void ExprMatchExpression::_doSetCollator(const CollatorInterface* collator) {
}
-std::unique_ptr<MatchExpression> ExprMatchExpression::shallowClone() const {
+std::unique_ptr<MatchExpression> ExprMatchExpression::clone() const {
// TODO SERVER-31003: Replace Expression clone via serialization with Expression::clone().
BSONObjBuilder bob;
bob << "" << _expression->serialize(false);
diff --git a/src/mongo/db/matcher/expression_expr.h b/src/mongo/db/matcher/expression_expr.h
index 51a1c273c59..0e72ea7f720 100644
--- a/src/mongo/db/matcher/expression_expr.h
+++ b/src/mongo/db/matcher/expression_expr.h
@@ -68,7 +68,7 @@ public:
*/
Value evaluateExpression(const MatchableDocument* doc) const;
- std::unique_ptr<MatchExpression> shallowClone() const final;
+ std::unique_ptr<MatchExpression> clone() const final;
void debugString(StringBuilder& debug, int indentationLevel = 0) const final {
_debugAddSpace(debug, indentationLevel);
diff --git a/src/mongo/db/matcher/expression_expr_test.cpp b/src/mongo/db/matcher/expression_expr_test.cpp
index 846a43f602f..276c4ea1eb9 100644
--- a/src/mongo/db/matcher/expression_expr_test.cpp
+++ b/src/mongo/db/matcher/expression_expr_test.cpp
@@ -705,7 +705,7 @@ TEST(ExprMatchTest, OptimizingAnAlreadyOptimizedCloneIsANoop) {
// Clone the match expression and optimize it again. We expect the twice-optimized match
// expression to be equivalent to the once-optimized one.
- std::unique_ptr<MatchExpression> doublyOptimized = singlyOptimized->shallowClone();
+ std::unique_ptr<MatchExpression> doublyOptimized = singlyOptimized->clone();
doublyOptimized = MatchExpression::optimize(std::move(doublyOptimized));
ASSERT_TRUE(doublyOptimized->equivalent(singlyOptimized.get()));
}
@@ -715,8 +715,8 @@ TEST(ExprMatchTest, ShallowClonedExpressionIsEquivalentToOriginal) {
boost::intrusive_ptr<ExpressionContextForTest> expCtx(new ExpressionContextForTest());
ExprMatchExpression pipelineExpr(expression.firstElement(), std::move(expCtx));
- auto shallowClone = pipelineExpr.shallowClone();
- ASSERT_TRUE(pipelineExpr.equivalent(shallowClone.get()));
+ auto clone = pipelineExpr.clone();
+ ASSERT_TRUE(pipelineExpr.equivalent(clone.get()));
}
TEST(ExprMatchTest, OptimizingExprAbsorbsAndOfAnd) {
diff --git a/src/mongo/db/matcher/expression_geo.cpp b/src/mongo/db/matcher/expression_geo.cpp
index 36a9e3f3107..1bc0266cf9b 100644
--- a/src/mongo/db/matcher/expression_geo.cpp
+++ b/src/mongo/db/matcher/expression_geo.cpp
@@ -467,7 +467,7 @@ bool GeoMatchExpression::equivalent(const MatchExpression* other) const {
return SimpleBSONObjComparator::kInstance.evaluate(_rawObj == realOther->_rawObj);
}
-std::unique_ptr<MatchExpression> GeoMatchExpression::shallowClone() const {
+std::unique_ptr<MatchExpression> GeoMatchExpression::clone() const {
std::unique_ptr<GeoMatchExpression> next =
std::make_unique<GeoMatchExpression>(path(), _query, _rawObj, _errorAnnotation);
next->_canSkipValidation = _canSkipValidation;
@@ -527,7 +527,7 @@ bool GeoNearMatchExpression::equivalent(const MatchExpression* other) const {
return SimpleBSONObjComparator::kInstance.evaluate(_rawObj == realOther->_rawObj);
}
-std::unique_ptr<MatchExpression> GeoNearMatchExpression::shallowClone() const {
+std::unique_ptr<MatchExpression> GeoNearMatchExpression::clone() const {
std::unique_ptr<GeoNearMatchExpression> next =
std::make_unique<GeoNearMatchExpression>(path(), _query, _rawObj);
if (getTag()) {
diff --git a/src/mongo/db/matcher/expression_geo.h b/src/mongo/db/matcher/expression_geo.h
index 1e784e0ba0b..57a45281436 100644
--- a/src/mongo/db/matcher/expression_geo.h
+++ b/src/mongo/db/matcher/expression_geo.h
@@ -110,7 +110,7 @@ public:
virtual bool equivalent(const MatchExpression* other) const;
- virtual std::unique_ptr<MatchExpression> shallowClone() const;
+ virtual std::unique_ptr<MatchExpression> clone() const;
void setCanSkipValidation(bool val) {
_canSkipValidation = val;
@@ -214,7 +214,7 @@ public:
virtual bool equivalent(const MatchExpression* other) const;
- virtual std::unique_ptr<MatchExpression> shallowClone() const;
+ virtual std::unique_ptr<MatchExpression> clone() const;
const GeoNearExpression& getData() const {
return *_query;
@@ -284,7 +284,7 @@ public:
return false;
}
- std::unique_ptr<MatchExpression> shallowClone() const final {
+ std::unique_ptr<MatchExpression> clone() const final {
MONGO_UNREACHABLE;
return nullptr;
}
diff --git a/src/mongo/db/matcher/expression_internal_bucket_geo_within.cpp b/src/mongo/db/matcher/expression_internal_bucket_geo_within.cpp
index e7618378833..0859fae0ec2 100644
--- a/src/mongo/db/matcher/expression_internal_bucket_geo_within.cpp
+++ b/src/mongo/db/matcher/expression_internal_bucket_geo_within.cpp
@@ -213,7 +213,7 @@ void InternalBucketGeoWithinMatchExpression::serialize(BSONObjBuilder* builder,
bob.doneFast();
}
-std::unique_ptr<MatchExpression> InternalBucketGeoWithinMatchExpression::shallowClone() const {
+std::unique_ptr<MatchExpression> InternalBucketGeoWithinMatchExpression::clone() const {
std::unique_ptr<InternalBucketGeoWithinMatchExpression> next =
std::make_unique<InternalBucketGeoWithinMatchExpression>(_geoContainer, _field);
if (getTag()) {
diff --git a/src/mongo/db/matcher/expression_internal_bucket_geo_within.h b/src/mongo/db/matcher/expression_internal_bucket_geo_within.h
index 95127fe106f..b7e4af99eb8 100644
--- a/src/mongo/db/matcher/expression_internal_bucket_geo_within.h
+++ b/src/mongo/db/matcher/expression_internal_bucket_geo_within.h
@@ -96,7 +96,7 @@ public:
void serialize(BSONObjBuilder* builder, SerializationOptions opts) const final;
- std::unique_ptr<MatchExpression> shallowClone() const final;
+ std::unique_ptr<MatchExpression> clone() const final;
std::vector<std::unique_ptr<MatchExpression>>* getChildVector() final {
return nullptr;
diff --git a/src/mongo/db/matcher/expression_internal_expr_comparison.h b/src/mongo/db/matcher/expression_internal_expr_comparison.h
index 8da2367f878..336d8a1fd8b 100644
--- a/src/mongo/db/matcher/expression_internal_expr_comparison.h
+++ b/src/mongo/db/matcher/expression_internal_expr_comparison.h
@@ -98,7 +98,7 @@ public:
}
};
- std::unique_ptr<MatchExpression> shallowClone() const final {
+ std::unique_ptr<MatchExpression> clone() const final {
auto clone = std::make_unique<T>(path(), _rhs);
clone->setCollator(_collator);
if (getTag()) {
diff --git a/src/mongo/db/matcher/expression_internal_expr_eq_test.cpp b/src/mongo/db/matcher/expression_internal_expr_eq_test.cpp
index 445f49c9f12..f4621a6cb23 100644
--- a/src/mongo/db/matcher/expression_internal_expr_eq_test.cpp
+++ b/src/mongo/db/matcher/expression_internal_expr_eq_test.cpp
@@ -296,7 +296,7 @@ TEST(InternalExprEqMatchExpression, EquivalentToClone) {
relevantTag->notFirst.push_back(1u);
eq.getMatchExpression()->setTag(relevantTag.release());
- auto clone = eq.getMatchExpression()->shallowClone();
+ auto clone = eq.getMatchExpression()->clone();
ASSERT_TRUE(eq.getMatchExpression()->equivalent(clone.get()));
}
diff --git a/src/mongo/db/matcher/expression_leaf.cpp b/src/mongo/db/matcher/expression_leaf.cpp
index fe39d9298ce..7303a94a17e 100644
--- a/src/mongo/db/matcher/expression_leaf.cpp
+++ b/src/mongo/db/matcher/expression_leaf.cpp
@@ -434,7 +434,7 @@ InMatchExpression::InMatchExpression(boost::optional<StringData> path,
: LeafMatchExpression(MATCH_IN, path, std::move(annotation)),
_eltCmp(BSONElementComparator::FieldNamesMode::kIgnore, _collator) {}
-std::unique_ptr<MatchExpression> InMatchExpression::shallowClone() const {
+std::unique_ptr<MatchExpression> InMatchExpression::clone() const {
auto next = std::make_unique<InMatchExpression>(path(), _errorAnnotation);
next->setCollator(_collator);
if (getTag()) {
@@ -449,7 +449,7 @@ std::unique_ptr<MatchExpression> InMatchExpression::shallowClone() const {
next->_equalityStorage = _equalityStorage;
for (auto&& regex : _regexes) {
std::unique_ptr<RegexMatchExpression> clonedRegex(
- static_cast<RegexMatchExpression*>(regex->shallowClone().release()));
+ static_cast<RegexMatchExpression*>(regex->clone().release()));
next->_regexes.push_back(std::move(clonedRegex));
}
if (getInputParamId()) {
diff --git a/src/mongo/db/matcher/expression_leaf.h b/src/mongo/db/matcher/expression_leaf.h
index 82b62000365..197790c83bf 100644
--- a/src/mongo/db/matcher/expression_leaf.h
+++ b/src/mongo/db/matcher/expression_leaf.h
@@ -278,7 +278,7 @@ public:
return kName;
}
- std::unique_ptr<MatchExpression> shallowClone() const final {
+ std::unique_ptr<MatchExpression> clone() const final {
std::unique_ptr<ComparisonMatchExpression> e =
std::make_unique<EqualityMatchExpression>(path(), Value(getData()), _errorAnnotation);
if (getTag()) {
@@ -317,7 +317,7 @@ public:
return kName;
}
- std::unique_ptr<MatchExpression> shallowClone() const final {
+ std::unique_ptr<MatchExpression> clone() const final {
std::unique_ptr<ComparisonMatchExpression> e =
std::make_unique<LTEMatchExpression>(path(), _rhs, _errorAnnotation);
if (getTag()) {
@@ -356,7 +356,7 @@ public:
return kName;
}
- std::unique_ptr<MatchExpression> shallowClone() const final {
+ std::unique_ptr<MatchExpression> clone() const final {
std::unique_ptr<ComparisonMatchExpression> e =
std::make_unique<LTMatchExpression>(path(), _rhs, _errorAnnotation);
if (getTag()) {
@@ -400,7 +400,7 @@ public:
return kName;
}
- std::unique_ptr<MatchExpression> shallowClone() const final {
+ std::unique_ptr<MatchExpression> clone() const final {
std::unique_ptr<ComparisonMatchExpression> e =
std::make_unique<GTMatchExpression>(path(), _rhs, _errorAnnotation);
if (getTag()) {
@@ -443,7 +443,7 @@ public:
return kName;
}
- std::unique_ptr<MatchExpression> shallowClone() const final {
+ std::unique_ptr<MatchExpression> clone() const final {
std::unique_ptr<ComparisonMatchExpression> e =
std::make_unique<GTEMatchExpression>(path(), _rhs, _errorAnnotation);
if (getTag()) {
@@ -489,7 +489,7 @@ public:
~RegexMatchExpression();
- std::unique_ptr<MatchExpression> shallowClone() const final {
+ std::unique_ptr<MatchExpression> clone() const final {
std::unique_ptr<RegexMatchExpression> e =
std::make_unique<RegexMatchExpression>(path(), _regex, _flags, _errorAnnotation);
if (getTag()) {
@@ -571,7 +571,7 @@ public:
long long remainder,
clonable_ptr<ErrorAnnotation> annotation = nullptr);
- std::unique_ptr<MatchExpression> shallowClone() const final {
+ std::unique_ptr<MatchExpression> clone() const final {
std::unique_ptr<ModMatchExpression> m =
std::make_unique<ModMatchExpression>(path(), _divisor, _remainder, _errorAnnotation);
if (getTag()) {
@@ -644,7 +644,7 @@ public:
explicit ExistsMatchExpression(boost::optional<StringData> path,
clonable_ptr<ErrorAnnotation> annotation = nullptr);
- virtual std::unique_ptr<MatchExpression> shallowClone() const {
+ virtual std::unique_ptr<MatchExpression> clone() const {
std::unique_ptr<ExistsMatchExpression> e =
std::make_unique<ExistsMatchExpression>(path(), _errorAnnotation);
if (getTag()) {
@@ -685,7 +685,7 @@ public:
explicit InMatchExpression(boost::optional<StringData> path,
clonable_ptr<ErrorAnnotation> annotation = nullptr);
- std::unique_ptr<MatchExpression> shallowClone() const final;
+ std::unique_ptr<MatchExpression> clone() const final;
bool matchesSingleElement(const BSONElement&, MatchDetails* details = nullptr) const final;
@@ -928,7 +928,7 @@ public:
: BitTestMatchExpression(
BITS_ALL_SET, path, bitMaskBinary, bitMaskLen, std::move(annotation)) {}
- std::unique_ptr<MatchExpression> shallowClone() const final {
+ std::unique_ptr<MatchExpression> clone() const final {
std::unique_ptr<BitTestMatchExpression> bitTestMatchExpression =
std::make_unique<BitsAllSetMatchExpression>(
path(), getBitPositions(), _errorAnnotation);
@@ -972,7 +972,7 @@ public:
: BitTestMatchExpression(
BITS_ALL_CLEAR, path, bitMaskBinary, bitMaskLen, std::move(annotation)) {}
- std::unique_ptr<MatchExpression> shallowClone() const final {
+ std::unique_ptr<MatchExpression> clone() const final {
std::unique_ptr<BitTestMatchExpression> bitTestMatchExpression =
std::make_unique<BitsAllClearMatchExpression>(
path(), getBitPositions(), _errorAnnotation);
@@ -1016,7 +1016,7 @@ public:
: BitTestMatchExpression(
BITS_ANY_SET, path, bitMaskBinary, bitMaskLen, std::move(annotation)) {}
- std::unique_ptr<MatchExpression> shallowClone() const final {
+ std::unique_ptr<MatchExpression> clone() const final {
std::unique_ptr<BitTestMatchExpression> bitTestMatchExpression =
std::make_unique<BitsAnySetMatchExpression>(
path(), getBitPositions(), _errorAnnotation);
@@ -1060,7 +1060,7 @@ public:
: BitTestMatchExpression(
BITS_ANY_CLEAR, path, bitMaskBinary, bitMaskLen, std::move(annotation)) {}
- std::unique_ptr<MatchExpression> shallowClone() const final {
+ std::unique_ptr<MatchExpression> clone() const final {
std::unique_ptr<BitTestMatchExpression> bitTestMatchExpression =
std::make_unique<BitsAnyClearMatchExpression>(
path(), getBitPositions(), _errorAnnotation);
diff --git a/src/mongo/db/matcher/expression_text.cpp b/src/mongo/db/matcher/expression_text.cpp
index a4168808c31..f16258a035c 100644
--- a/src/mongo/db/matcher/expression_text.cpp
+++ b/src/mongo/db/matcher/expression_text.cpp
@@ -100,7 +100,7 @@ TextMatchExpression::TextMatchExpression(OperationContext* opCtx,
uassertStatusOK(parseStatus);
}
-std::unique_ptr<MatchExpression> TextMatchExpression::shallowClone() const {
+std::unique_ptr<MatchExpression> TextMatchExpression::clone() const {
auto expr = std::make_unique<TextMatchExpression>(_ftsQuery);
// We use the query-only constructor here directly rather than using the full constructor, to
// avoid needing to examine
diff --git a/src/mongo/db/matcher/expression_text.h b/src/mongo/db/matcher/expression_text.h
index 2b8dba163e7..bdaf88a1e33 100644
--- a/src/mongo/db/matcher/expression_text.h
+++ b/src/mongo/db/matcher/expression_text.h
@@ -62,7 +62,7 @@ public:
return true;
}
- std::unique_ptr<MatchExpression> shallowClone() const final;
+ std::unique_ptr<MatchExpression> clone() const final;
void acceptVisitor(MatchExpressionMutableVisitor* visitor) final {
visitor->visit(this);
diff --git a/src/mongo/db/matcher/expression_text_noop.cpp b/src/mongo/db/matcher/expression_text_noop.cpp
index 93dce710777..46e8551c610 100644
--- a/src/mongo/db/matcher/expression_text_noop.cpp
+++ b/src/mongo/db/matcher/expression_text_noop.cpp
@@ -45,7 +45,7 @@ TextNoOpMatchExpression::TextNoOpMatchExpression(TextParams params)
invariant(_ftsQuery.parse(fts::TEXT_INDEX_VERSION_INVALID));
}
-std::unique_ptr<MatchExpression> TextNoOpMatchExpression::shallowClone() const {
+std::unique_ptr<MatchExpression> TextNoOpMatchExpression::clone() const {
TextParams params;
params.query = _ftsQuery.getQuery();
params.language = _ftsQuery.getLanguage();
diff --git a/src/mongo/db/matcher/expression_text_noop.h b/src/mongo/db/matcher/expression_text_noop.h
index 322b97f7d22..7e261dab2c3 100644
--- a/src/mongo/db/matcher/expression_text_noop.h
+++ b/src/mongo/db/matcher/expression_text_noop.h
@@ -46,7 +46,7 @@ public:
MONGO_UNREACHABLE;
}
- std::unique_ptr<MatchExpression> shallowClone() const final;
+ std::unique_ptr<MatchExpression> clone() const final;
void acceptVisitor(MatchExpressionMutableVisitor* visitor) final {
visitor->visit(this);
diff --git a/src/mongo/db/matcher/expression_tree.h b/src/mongo/db/matcher/expression_tree.h
index 252538b0ea6..ce6fdb95bb1 100644
--- a/src/mongo/db/matcher/expression_tree.h
+++ b/src/mongo/db/matcher/expression_tree.h
@@ -124,11 +124,11 @@ public:
bool matchesSingleElement(const BSONElement&, MatchDetails* details = nullptr) const final;
- virtual std::unique_ptr<MatchExpression> shallowClone() const {
+ virtual std::unique_ptr<MatchExpression> clone() const {
std::unique_ptr<AndMatchExpression> self =
std::make_unique<AndMatchExpression>(_errorAnnotation);
for (size_t i = 0; i < numChildren(); ++i) {
- self->add(getChild(i)->shallowClone());
+ self->add(getChild(i)->clone());
}
if (getTag()) {
self->setTag(getTag()->clone());
@@ -168,11 +168,11 @@ public:
bool matchesSingleElement(const BSONElement&, MatchDetails* details = nullptr) const final;
- virtual std::unique_ptr<MatchExpression> shallowClone() const {
+ virtual std::unique_ptr<MatchExpression> clone() const {
std::unique_ptr<OrMatchExpression> self =
std::make_unique<OrMatchExpression>(_errorAnnotation);
for (size_t i = 0; i < numChildren(); ++i) {
- self->add(getChild(i)->shallowClone());
+ self->add(getChild(i)->clone());
}
if (getTag()) {
self->setTag(getTag()->clone());
@@ -212,11 +212,11 @@ public:
bool matchesSingleElement(const BSONElement&, MatchDetails* details = nullptr) const final;
- virtual std::unique_ptr<MatchExpression> shallowClone() const {
+ virtual std::unique_ptr<MatchExpression> clone() const {
std::unique_ptr<NorMatchExpression> self =
std::make_unique<NorMatchExpression>(_errorAnnotation);
for (size_t i = 0; i < numChildren(); ++i) {
- self->add(getChild(i)->shallowClone());
+ self->add(getChild(i)->clone());
}
if (getTag()) {
self->setTag(getTag()->clone());
@@ -248,9 +248,9 @@ public:
clonable_ptr<ErrorAnnotation> annotation = nullptr)
: MatchExpression(NOT, std::move(annotation)), _exp(std::move(expr)) {}
- virtual std::unique_ptr<MatchExpression> shallowClone() const {
+ virtual std::unique_ptr<MatchExpression> clone() const {
std::unique_ptr<NotMatchExpression> self =
- std::make_unique<NotMatchExpression>(_exp->shallowClone(), _errorAnnotation);
+ std::make_unique<NotMatchExpression>(_exp->clone(), _errorAnnotation);
if (getTag()) {
self->setTag(getTag()->clone());
}
diff --git a/src/mongo/db/matcher/expression_tree_test.cpp b/src/mongo/db/matcher/expression_tree_test.cpp
index 4502768c765..101b0ded6f9 100644
--- a/src/mongo/db/matcher/expression_tree_test.cpp
+++ b/src/mongo/db/matcher/expression_tree_test.cpp
@@ -390,11 +390,11 @@ TEST(NorOp, Equivalent) {
auto sub2 = EqualityMatchExpression{"b"_sd, baseOperand2["b"]};
auto e1 = NorMatchExpression{};
- e1.add(sub1.shallowClone());
- e1.add(sub2.shallowClone());
+ e1.add(sub1.clone());
+ e1.add(sub2.clone());
auto e2 = NorMatchExpression{};
- e2.add(sub1.shallowClone());
+ e2.add(sub1.clone());
ASSERT(e1.equivalent(&e1));
ASSERT(!e1.equivalent(&e2));
diff --git a/src/mongo/db/matcher/expression_type.h b/src/mongo/db/matcher/expression_type.h
index 5b18bee2a9c..e08fe0a4d1b 100644
--- a/src/mongo/db/matcher/expression_type.h
+++ b/src/mongo/db/matcher/expression_type.h
@@ -139,7 +139,7 @@ public:
return kName;
}
- std::unique_ptr<MatchExpression> shallowClone() const final {
+ std::unique_ptr<MatchExpression> clone() const final {
auto expr = std::make_unique<TypeMatchExpression>(path(), typeSet(), _errorAnnotation);
if (getTag()) {
expr->setTag(getTag()->clone());
@@ -193,7 +193,7 @@ public:
return kName;
}
- std::unique_ptr<MatchExpression> shallowClone() const final {
+ std::unique_ptr<MatchExpression> clone() const final {
auto expr =
std::make_unique<InternalSchemaTypeExpression>(path(), typeSet(), _errorAnnotation);
if (getTag()) {
@@ -234,7 +234,7 @@ public:
return elem.type() == BSONType::BinData && elem.binDataType() == _binDataSubType;
}
- std::unique_ptr<MatchExpression> shallowClone() const final {
+ std::unique_ptr<MatchExpression> clone() const final {
auto expr = std::make_unique<InternalSchemaBinDataSubTypeExpression>(
path(), _binDataSubType, _errorAnnotation);
if (getTag()) {
@@ -316,7 +316,7 @@ public:
return kName;
}
- std::unique_ptr<MatchExpression> shallowClone() const final {
+ std::unique_ptr<MatchExpression> clone() const final {
auto expr = std::make_unique<InternalSchemaBinDataEncryptedTypeExpression>(
path(), typeSet(), _errorAnnotation);
if (getTag()) {
@@ -387,7 +387,7 @@ public:
return kName;
}
- std::unique_ptr<MatchExpression> shallowClone() const final {
+ std::unique_ptr<MatchExpression> clone() const final {
auto expr = std::make_unique<InternalSchemaBinDataFLE2EncryptedTypeExpression>(
path(), typeSet(), _errorAnnotation);
if (getTag()) {
diff --git a/src/mongo/db/matcher/expression_where.cpp b/src/mongo/db/matcher/expression_where.cpp
index 58bbe52a41e..95ca4aa2537 100644
--- a/src/mongo/db/matcher/expression_where.cpp
+++ b/src/mongo/db/matcher/expression_where.cpp
@@ -61,7 +61,7 @@ bool WhereMatchExpression::matches(const MatchableDocument* doc, MatchDetails* d
return _jsFunction->runAsPredicate(doc->toBSON());
}
-unique_ptr<MatchExpression> WhereMatchExpression::shallowClone() const {
+unique_ptr<MatchExpression> WhereMatchExpression::clone() const {
validateState();
WhereParams params;
diff --git a/src/mongo/db/matcher/expression_where.h b/src/mongo/db/matcher/expression_where.h
index 08826a7ad58..f3a7de22916 100644
--- a/src/mongo/db/matcher/expression_where.h
+++ b/src/mongo/db/matcher/expression_where.h
@@ -42,7 +42,7 @@ public:
bool matches(const MatchableDocument* doc, MatchDetails* details = nullptr) const final;
- std::unique_ptr<MatchExpression> shallowClone() const final;
+ std::unique_ptr<MatchExpression> clone() const final;
void acceptVisitor(MatchExpressionMutableVisitor* visitor) final {
visitor->visit(this);
diff --git a/src/mongo/db/matcher/expression_where_noop.cpp b/src/mongo/db/matcher/expression_where_noop.cpp
index e300c1517c6..a72d89da593 100644
--- a/src/mongo/db/matcher/expression_where_noop.cpp
+++ b/src/mongo/db/matcher/expression_where_noop.cpp
@@ -43,7 +43,7 @@ bool WhereNoOpMatchExpression::matches(const MatchableDocument* doc, MatchDetail
MONGO_UNREACHABLE;
}
-std::unique_ptr<MatchExpression> WhereNoOpMatchExpression::shallowClone() const {
+std::unique_ptr<MatchExpression> WhereNoOpMatchExpression::clone() const {
WhereParams params;
params.code = getCode();
std::unique_ptr<WhereNoOpMatchExpression> e =
diff --git a/src/mongo/db/matcher/expression_where_noop.h b/src/mongo/db/matcher/expression_where_noop.h
index 38db74cc868..94807ee5646 100644
--- a/src/mongo/db/matcher/expression_where_noop.h
+++ b/src/mongo/db/matcher/expression_where_noop.h
@@ -45,7 +45,7 @@ public:
bool matches(const MatchableDocument* doc, MatchDetails* details = nullptr) const final;
- std::unique_ptr<MatchExpression> shallowClone() const final;
+ std::unique_ptr<MatchExpression> clone() const final;
void acceptVisitor(MatchExpressionMutableVisitor* visitor) final {
visitor->visit(this);
diff --git a/src/mongo/db/matcher/expression_with_placeholder.h b/src/mongo/db/matcher/expression_with_placeholder.h
index 2531c7465d0..9a6629bc9fb 100644
--- a/src/mongo/db/matcher/expression_with_placeholder.h
+++ b/src/mongo/db/matcher/expression_with_placeholder.h
@@ -92,8 +92,8 @@ public:
_filter.reset(other);
}
- std::unique_ptr<ExpressionWithPlaceholder> shallowClone() const {
- return std::make_unique<ExpressionWithPlaceholder>(_placeholder, _filter->shallowClone());
+ std::unique_ptr<ExpressionWithPlaceholder> clone() const {
+ return std::make_unique<ExpressionWithPlaceholder>(_placeholder, _filter->clone());
}
/*
diff --git a/src/mongo/db/matcher/rewrite_expr.h b/src/mongo/db/matcher/rewrite_expr.h
index 1752c9726b8..0cdef20af6a 100644
--- a/src/mongo/db/matcher/rewrite_expr.h
+++ b/src/mongo/db/matcher/rewrite_expr.h
@@ -60,7 +60,7 @@ public:
}
RewriteResult clone() const {
- auto clonedMatch = _matchExpression ? _matchExpression->shallowClone() : nullptr;
+ auto clonedMatch = _matchExpression ? _matchExpression->clone() : nullptr;
return {std::move(clonedMatch), _matchExprElemStorage};
}
diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_all_elem_match_from_index.cpp b/src/mongo/db/matcher/schema/expression_internal_schema_all_elem_match_from_index.cpp
index 9b0c0fa6f74..a74dfa83236 100644
--- a/src/mongo/db/matcher/schema/expression_internal_schema_all_elem_match_from_index.cpp
+++ b/src/mongo/db/matcher/schema/expression_internal_schema_all_elem_match_from_index.cpp
@@ -48,10 +48,9 @@ InternalSchemaAllElemMatchFromIndexMatchExpression::
_index(index),
_expression(std::move(expression)) {}
-std::unique_ptr<MatchExpression> InternalSchemaAllElemMatchFromIndexMatchExpression::shallowClone()
- const {
+std::unique_ptr<MatchExpression> InternalSchemaAllElemMatchFromIndexMatchExpression::clone() const {
auto clone = std::make_unique<InternalSchemaAllElemMatchFromIndexMatchExpression>(
- path(), _index, _expression->shallowClone(), _errorAnnotation);
+ path(), _index, _expression->clone(), _errorAnnotation);
if (getTag()) {
clone->setTag(getTag()->clone());
}
diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_all_elem_match_from_index.h b/src/mongo/db/matcher/schema/expression_internal_schema_all_elem_match_from_index.h
index 1a385142116..007ac6bdf59 100644
--- a/src/mongo/db/matcher/schema/expression_internal_schema_all_elem_match_from_index.h
+++ b/src/mongo/db/matcher/schema/expression_internal_schema_all_elem_match_from_index.h
@@ -53,7 +53,7 @@ public:
std::unique_ptr<ExpressionWithPlaceholder> expression,
clonable_ptr<ErrorAnnotation> annotation = nullptr);
- std::unique_ptr<MatchExpression> shallowClone() const final;
+ std::unique_ptr<MatchExpression> clone() const final;
bool matchesArray(const BSONObj& array, MatchDetails* details) const final {
return !findFirstMismatchInArray(array, details);
diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_allowed_properties.cpp b/src/mongo/db/matcher/schema/expression_internal_schema_allowed_properties.cpp
index 5d86e5571d2..ebb924ed966 100644
--- a/src/mongo/db/matcher/schema/expression_internal_schema_allowed_properties.cpp
+++ b/src/mongo/db/matcher/schema/expression_internal_schema_allowed_properties.cpp
@@ -157,20 +157,19 @@ void InternalSchemaAllowedPropertiesMatchExpression::serialize(BSONObjBuilder* b
expressionBuilder.doneFast();
}
-std::unique_ptr<MatchExpression> InternalSchemaAllowedPropertiesMatchExpression::shallowClone()
- const {
+std::unique_ptr<MatchExpression> InternalSchemaAllowedPropertiesMatchExpression::clone() const {
std::vector<PatternSchema> clonedPatternProperties;
clonedPatternProperties.reserve(_patternProperties.size());
for (auto&& constraint : _patternProperties) {
clonedPatternProperties.emplace_back(Pattern(constraint.first.rawRegex),
- constraint.second->shallowClone());
+ constraint.second->clone());
}
auto clone = std::make_unique<InternalSchemaAllowedPropertiesMatchExpression>(
_properties,
_namePlaceholder,
std::move(clonedPatternProperties),
- _otherwise->shallowClone(),
+ _otherwise->clone(),
_errorAnnotation);
return {std::move(clone)};
}
diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_allowed_properties.h b/src/mongo/db/matcher/schema/expression_internal_schema_allowed_properties.h
index 052b10a4b78..823cfb8c429 100644
--- a/src/mongo/db/matcher/schema/expression_internal_schema_allowed_properties.h
+++ b/src/mongo/db/matcher/schema/expression_internal_schema_allowed_properties.h
@@ -138,7 +138,7 @@ public:
void serialize(BSONObjBuilder* builder, SerializationOptions opts) const final;
- std::unique_ptr<MatchExpression> shallowClone() const final;
+ std::unique_ptr<MatchExpression> clone() const final;
std::vector<std::unique_ptr<MatchExpression>>* getChildVector() final {
return nullptr;
diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_allowed_properties_test.cpp b/src/mongo/db/matcher/schema/expression_internal_schema_allowed_properties_test.cpp
index b14a1b8adca..e7e9243384c 100644
--- a/src/mongo/db/matcher/schema/expression_internal_schema_allowed_properties_test.cpp
+++ b/src/mongo/db/matcher/schema/expression_internal_schema_allowed_properties_test.cpp
@@ -111,7 +111,7 @@ TEST(InternalSchemaAllowedPropertiesMatchExpression, EquivalentToClone) {
boost::intrusive_ptr<ExpressionContextForTest> expCtx(new ExpressionContextForTest());
auto expr = MatchExpressionParser::parse(filter, expCtx);
ASSERT_OK(expr.getStatus());
- auto clone = expr.getValue()->shallowClone();
+ auto clone = expr.getValue()->clone();
ASSERT_TRUE(expr.getValue()->equivalent(clone.get()));
filter = fromjson(
@@ -119,7 +119,7 @@ TEST(InternalSchemaAllowedPropertiesMatchExpression, EquivalentToClone) {
"patternProperties: [], otherwise: {}}}");
expr = MatchExpressionParser::parse(filter, expCtx);
ASSERT_OK(expr.getStatus());
- clone = expr.getValue()->shallowClone();
+ clone = expr.getValue()->clone();
ASSERT_TRUE(expr.getValue()->equivalent(clone.get()));
}
diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_cond_test.cpp b/src/mongo/db/matcher/schema/expression_internal_schema_cond_test.cpp
index 5d8e82b3d7c..58214ae137e 100644
--- a/src/mongo/db/matcher/schema/expression_internal_schema_cond_test.cpp
+++ b/src/mongo/db/matcher/schema/expression_internal_schema_cond_test.cpp
@@ -154,7 +154,7 @@ TEST(InternalSchemaCondMatchExpressionTest, EquivalentToClone) {
auto elseQuery = BSON("interests"
<< "dogs");
auto cond = createCondMatchExpression(conditionQuery, thenQuery, elseQuery);
- auto clone = cond->shallowClone();
+ auto clone = cond->clone();
ASSERT_TRUE(cond->equivalent(clone.get()));
}
} // namespace
diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_eq.cpp b/src/mongo/db/matcher/schema/expression_internal_schema_eq.cpp
index 2919bf1a65f..5ea8e9d1f3d 100644
--- a/src/mongo/db/matcher/schema/expression_internal_schema_eq.cpp
+++ b/src/mongo/db/matcher/schema/expression_internal_schema_eq.cpp
@@ -86,7 +86,7 @@ bool InternalSchemaEqMatchExpression::equivalent(const MatchExpression* other) c
return path() == realOther->path() && _eltCmp.evaluate(_rhsElem == realOther->_rhsElem);
}
-std::unique_ptr<MatchExpression> InternalSchemaEqMatchExpression::shallowClone() const {
+std::unique_ptr<MatchExpression> InternalSchemaEqMatchExpression::clone() const {
auto clone =
std::make_unique<InternalSchemaEqMatchExpression>(path(), _rhsElem, _errorAnnotation);
if (getTag()) {
diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_eq.h b/src/mongo/db/matcher/schema/expression_internal_schema_eq.h
index c4cb5f0d235..5099119f3be 100644
--- a/src/mongo/db/matcher/schema/expression_internal_schema_eq.h
+++ b/src/mongo/db/matcher/schema/expression_internal_schema_eq.h
@@ -53,7 +53,7 @@ public:
BSONElement rhs,
clonable_ptr<ErrorAnnotation> annotation = nullptr);
- std::unique_ptr<MatchExpression> shallowClone() const final;
+ std::unique_ptr<MatchExpression> clone() const final;
bool matchesSingleElement(const BSONElement&, MatchDetails*) const final;
diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_eq_test.cpp b/src/mongo/db/matcher/schema/expression_internal_schema_eq_test.cpp
index e202443d62d..7f3d4362733 100644
--- a/src/mongo/db/matcher/schema/expression_internal_schema_eq_test.cpp
+++ b/src/mongo/db/matcher/schema/expression_internal_schema_eq_test.cpp
@@ -135,7 +135,7 @@ TEST(InternalSchemaEqMatchExpression, EquivalentToClone) {
auto query = fromjson("{a: {$_internalSchemaEq: {a:1, b: {c: 1, d: [1]}}}}");
boost::intrusive_ptr<ExpressionContextForTest> expCtx(new ExpressionContextForTest());
Matcher rootDocEq(query, expCtx);
- auto clone = rootDocEq.getMatchExpression()->shallowClone();
+ auto clone = rootDocEq.getMatchExpression()->clone();
ASSERT_TRUE(rootDocEq.getMatchExpression()->equivalent(clone.get()));
}
diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_fmod.h b/src/mongo/db/matcher/schema/expression_internal_schema_fmod.h
index 46e3f39f860..27caa7dc272 100644
--- a/src/mongo/db/matcher/schema/expression_internal_schema_fmod.h
+++ b/src/mongo/db/matcher/schema/expression_internal_schema_fmod.h
@@ -44,7 +44,7 @@ public:
Decimal128 remainder,
clonable_ptr<ErrorAnnotation> annotation = nullptr);
- std::unique_ptr<MatchExpression> shallowClone() const final {
+ std::unique_ptr<MatchExpression> clone() const final {
std::unique_ptr<InternalSchemaFmodMatchExpression> m =
std::make_unique<InternalSchemaFmodMatchExpression>(
path(), _divisor, _remainder, _errorAnnotation);
diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_match_array_index.cpp b/src/mongo/db/matcher/schema/expression_internal_schema_match_array_index.cpp
index 0792b33b2fe..629e40bd978 100644
--- a/src/mongo/db/matcher/schema/expression_internal_schema_match_array_index.cpp
+++ b/src/mongo/db/matcher/schema/expression_internal_schema_match_array_index.cpp
@@ -90,10 +90,9 @@ BSONObj InternalSchemaMatchArrayIndexMatchExpression::getSerializedRightHandSide
return objBuilder.obj();
}
-std::unique_ptr<MatchExpression> InternalSchemaMatchArrayIndexMatchExpression::shallowClone()
- const {
+std::unique_ptr<MatchExpression> InternalSchemaMatchArrayIndexMatchExpression::clone() const {
auto clone = std::make_unique<InternalSchemaMatchArrayIndexMatchExpression>(
- path(), _index, _expression->shallowClone(), _errorAnnotation);
+ path(), _index, _expression->clone(), _errorAnnotation);
if (getTag()) {
clone->setTag(getTag()->clone());
}
diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_match_array_index.h b/src/mongo/db/matcher/schema/expression_internal_schema_match_array_index.h
index f3230bf0cbd..96fea55511d 100644
--- a/src/mongo/db/matcher/schema/expression_internal_schema_match_array_index.h
+++ b/src/mongo/db/matcher/schema/expression_internal_schema_match_array_index.h
@@ -76,7 +76,7 @@ public:
BSONObj getSerializedRightHandSide(SerializationOptions opts) const final;
- std::unique_ptr<MatchExpression> shallowClone() const final;
+ std::unique_ptr<MatchExpression> clone() const final;
std::vector<std::unique_ptr<MatchExpression>>* getChildVector() final {
return nullptr;
diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_match_array_index_test.cpp b/src/mongo/db/matcher/schema/expression_internal_schema_match_array_index_test.cpp
index b6308f7ca0a..e1938d15063 100644
--- a/src/mongo/db/matcher/schema/expression_internal_schema_match_array_index_test.cpp
+++ b/src/mongo/db/matcher/schema/expression_internal_schema_match_array_index_test.cpp
@@ -112,7 +112,7 @@ TEST(InternalSchemaMatchArrayIndexMatchExpression, EquivalentToClone) {
boost::intrusive_ptr<ExpressionContextForTest> expCtx(new ExpressionContextForTest());
auto expr = MatchExpressionParser::parse(filter, expCtx);
ASSERT_OK(expr.getStatus());
- auto clone = expr.getValue()->shallowClone();
+ auto clone = expr.getValue()->clone();
ASSERT_TRUE(expr.getValue()->equivalent(clone.get()));
}
diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_max_items.h b/src/mongo/db/matcher/schema/expression_internal_schema_max_items.h
index 24b28726293..bab4075f09c 100644
--- a/src/mongo/db/matcher/schema/expression_internal_schema_max_items.h
+++ b/src/mongo/db/matcher/schema/expression_internal_schema_max_items.h
@@ -53,7 +53,7 @@ public:
return (anArray.nFields() <= numItems());
}
- std::unique_ptr<MatchExpression> shallowClone() const final {
+ std::unique_ptr<MatchExpression> clone() const final {
std::unique_ptr<InternalSchemaMaxItemsMatchExpression> maxItems =
std::make_unique<InternalSchemaMaxItemsMatchExpression>(
path(), numItems(), _errorAnnotation);
diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_max_length.h b/src/mongo/db/matcher/schema/expression_internal_schema_max_length.h
index 75b023c3554..9918531d1bf 100644
--- a/src/mongo/db/matcher/schema/expression_internal_schema_max_length.h
+++ b/src/mongo/db/matcher/schema/expression_internal_schema_max_length.h
@@ -52,7 +52,7 @@ public:
};
}
- std::unique_ptr<MatchExpression> shallowClone() const final {
+ std::unique_ptr<MatchExpression> clone() const final {
std::unique_ptr<InternalSchemaMaxLengthMatchExpression> maxLen =
std::make_unique<InternalSchemaMaxLengthMatchExpression>(
path(), strLen(), _errorAnnotation);
diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_max_properties.h b/src/mongo/db/matcher/schema/expression_internal_schema_max_properties.h
index 22d3747aed1..90f41810f7d 100644
--- a/src/mongo/db/matcher/schema/expression_internal_schema_max_properties.h
+++ b/src/mongo/db/matcher/schema/expression_internal_schema_max_properties.h
@@ -60,7 +60,7 @@ public:
return (elem.embeddedObject().nFields() <= numProperties());
}
- virtual std::unique_ptr<MatchExpression> shallowClone() const final {
+ virtual std::unique_ptr<MatchExpression> clone() const final {
auto maxProperties = std::make_unique<InternalSchemaMaxPropertiesMatchExpression>(
numProperties(), _errorAnnotation);
if (getTag()) {
diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_min_items.h b/src/mongo/db/matcher/schema/expression_internal_schema_min_items.h
index 3384aaaf0e6..0a54ba120ec 100644
--- a/src/mongo/db/matcher/schema/expression_internal_schema_min_items.h
+++ b/src/mongo/db/matcher/schema/expression_internal_schema_min_items.h
@@ -53,7 +53,7 @@ public:
return (anArray.nFields() >= numItems());
}
- std::unique_ptr<MatchExpression> shallowClone() const final {
+ std::unique_ptr<MatchExpression> clone() const final {
std::unique_ptr<InternalSchemaMinItemsMatchExpression> minItems =
std::make_unique<InternalSchemaMinItemsMatchExpression>(
path(), numItems(), _errorAnnotation);
diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_min_length.h b/src/mongo/db/matcher/schema/expression_internal_schema_min_length.h
index d7950c37343..8034bd55548 100644
--- a/src/mongo/db/matcher/schema/expression_internal_schema_min_length.h
+++ b/src/mongo/db/matcher/schema/expression_internal_schema_min_length.h
@@ -52,7 +52,7 @@ public:
};
}
- std::unique_ptr<MatchExpression> shallowClone() const final {
+ std::unique_ptr<MatchExpression> clone() const final {
std::unique_ptr<InternalSchemaMinLengthMatchExpression> minLen =
std::make_unique<InternalSchemaMinLengthMatchExpression>(
path(), strLen(), _errorAnnotation);
diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_min_properties.h b/src/mongo/db/matcher/schema/expression_internal_schema_min_properties.h
index 62a0a5ca17b..56ae586a401 100644
--- a/src/mongo/db/matcher/schema/expression_internal_schema_min_properties.h
+++ b/src/mongo/db/matcher/schema/expression_internal_schema_min_properties.h
@@ -60,7 +60,7 @@ public:
return (elem.embeddedObject().nFields() >= numProperties());
}
- virtual std::unique_ptr<MatchExpression> shallowClone() const final {
+ virtual std::unique_ptr<MatchExpression> clone() const final {
auto minProperties = std::make_unique<InternalSchemaMinPropertiesMatchExpression>(
numProperties(), _errorAnnotation);
if (getTag()) {
diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_object_match.cpp b/src/mongo/db/matcher/schema/expression_internal_schema_object_match.cpp
index d1716c00b4f..3e4307b2407 100644
--- a/src/mongo/db/matcher/schema/expression_internal_schema_object_match.cpp
+++ b/src/mongo/db/matcher/schema/expression_internal_schema_object_match.cpp
@@ -79,9 +79,9 @@ bool InternalSchemaObjectMatchExpression::equivalent(const MatchExpression* othe
return _sub->equivalent(other->getChild(0));
}
-std::unique_ptr<MatchExpression> InternalSchemaObjectMatchExpression::shallowClone() const {
+std::unique_ptr<MatchExpression> InternalSchemaObjectMatchExpression::clone() const {
auto clone = std::make_unique<InternalSchemaObjectMatchExpression>(
- path(), _sub->shallowClone(), _errorAnnotation);
+ path(), _sub->clone(), _errorAnnotation);
if (getTag()) {
clone->setTag(getTag()->clone());
}
diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_object_match.h b/src/mongo/db/matcher/schema/expression_internal_schema_object_match.h
index 081f3382721..0d9d5f29942 100644
--- a/src/mongo/db/matcher/schema/expression_internal_schema_object_match.h
+++ b/src/mongo/db/matcher/schema/expression_internal_schema_object_match.h
@@ -46,7 +46,7 @@ public:
bool matchesSingleElement(const BSONElement& elem, MatchDetails* details = nullptr) const final;
- std::unique_ptr<MatchExpression> shallowClone() const final;
+ std::unique_ptr<MatchExpression> clone() const final;
void debugString(StringBuilder& debug, int indentationLevel = 0) const final;
diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_root_doc_eq.cpp b/src/mongo/db/matcher/schema/expression_internal_schema_root_doc_eq.cpp
index c9d607b6c0a..4201d42f6be 100644
--- a/src/mongo/db/matcher/schema/expression_internal_schema_root_doc_eq.cpp
+++ b/src/mongo/db/matcher/schema/expression_internal_schema_root_doc_eq.cpp
@@ -71,7 +71,7 @@ bool InternalSchemaRootDocEqMatchExpression::equivalent(const MatchExpression* o
return _objCmp.evaluate(_rhsObj == realOther->_rhsObj);
}
-std::unique_ptr<MatchExpression> InternalSchemaRootDocEqMatchExpression::shallowClone() const {
+std::unique_ptr<MatchExpression> InternalSchemaRootDocEqMatchExpression::clone() const {
auto clone =
std::make_unique<InternalSchemaRootDocEqMatchExpression>(_rhsObj.copy(), _errorAnnotation);
if (getTag()) {
diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_root_doc_eq.h b/src/mongo/db/matcher/schema/expression_internal_schema_root_doc_eq.h
index 244b17546e3..ea1fc6e8f8f 100644
--- a/src/mongo/db/matcher/schema/expression_internal_schema_root_doc_eq.h
+++ b/src/mongo/db/matcher/schema/expression_internal_schema_root_doc_eq.h
@@ -68,7 +68,7 @@ public:
MONGO_UNREACHABLE;
}
- std::unique_ptr<MatchExpression> shallowClone() const final;
+ std::unique_ptr<MatchExpression> clone() const final;
void debugString(StringBuilder& debug, int indentationLevel = 0) const final;
diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_root_doc_eq_test.cpp b/src/mongo/db/matcher/schema/expression_internal_schema_root_doc_eq_test.cpp
index 596db5a95eb..978ab0c247d 100644
--- a/src/mongo/db/matcher/schema/expression_internal_schema_root_doc_eq_test.cpp
+++ b/src/mongo/db/matcher/schema/expression_internal_schema_root_doc_eq_test.cpp
@@ -111,7 +111,7 @@ TEST(InternalSchemaRootDocEqMatchExpression, EquivalentToClone) {
boost::intrusive_ptr<ExpressionContextForTest> expCtx(new ExpressionContextForTest());
Matcher rootDocEq(std::move(query), expCtx);
- auto clone = rootDocEq.getMatchExpression()->shallowClone();
+ auto clone = rootDocEq.getMatchExpression()->clone();
ASSERT_TRUE(rootDocEq.getMatchExpression()->equivalent(clone.get()));
}
diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_unique_items.cpp b/src/mongo/db/matcher/schema/expression_internal_schema_unique_items.cpp
index 90c7a4b69c4..d1a0551db3a 100644
--- a/src/mongo/db/matcher/schema/expression_internal_schema_unique_items.cpp
+++ b/src/mongo/db/matcher/schema/expression_internal_schema_unique_items.cpp
@@ -67,7 +67,7 @@ BSONObj InternalSchemaUniqueItemsMatchExpression::getSerializedRightHandSide(
return bob.obj();
}
-std::unique_ptr<MatchExpression> InternalSchemaUniqueItemsMatchExpression::shallowClone() const {
+std::unique_ptr<MatchExpression> InternalSchemaUniqueItemsMatchExpression::clone() const {
auto clone =
std::make_unique<InternalSchemaUniqueItemsMatchExpression>(path(), _errorAnnotation);
if (getTag()) {
diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_unique_items.h b/src/mongo/db/matcher/schema/expression_internal_schema_unique_items.h
index 98f7d779377..a789cc044d8 100644
--- a/src/mongo/db/matcher/schema/expression_internal_schema_unique_items.h
+++ b/src/mongo/db/matcher/schema/expression_internal_schema_unique_items.h
@@ -88,7 +88,7 @@ public:
BSONObj getSerializedRightHandSide(SerializationOptions opts) const final;
- std::unique_ptr<MatchExpression> shallowClone() const final;
+ std::unique_ptr<MatchExpression> clone() const final;
void acceptVisitor(MatchExpressionMutableVisitor* visitor) final {
visitor->visit(this);
diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_xor.h b/src/mongo/db/matcher/schema/expression_internal_schema_xor.h
index 2755098390c..903a8044aef 100644
--- a/src/mongo/db/matcher/schema/expression_internal_schema_xor.h
+++ b/src/mongo/db/matcher/schema/expression_internal_schema_xor.h
@@ -56,10 +56,10 @@ public:
bool matchesSingleElement(const BSONElement&, MatchDetails* details = nullptr) const final;
- virtual std::unique_ptr<MatchExpression> shallowClone() const {
+ virtual std::unique_ptr<MatchExpression> clone() const {
auto xorCopy = std::make_unique<InternalSchemaXorMatchExpression>(_errorAnnotation);
for (size_t i = 0; i < numChildren(); ++i) {
- xorCopy->add(getChild(i)->shallowClone());
+ xorCopy->add(getChild(i)->clone());
}
if (getTag()) {
xorCopy->setTag(getTag()->clone());
diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_xor_test.cpp b/src/mongo/db/matcher/schema/expression_internal_schema_xor_test.cpp
index 5b75f0c4e8c..cda74422ecc 100644
--- a/src/mongo/db/matcher/schema/expression_internal_schema_xor_test.cpp
+++ b/src/mongo/db/matcher/schema/expression_internal_schema_xor_test.cpp
@@ -104,11 +104,11 @@ TEST(InternalSchemaXorOp, Equivalent) {
EqualityMatchExpression sub2("b"_sd, baseOperand2["b"]);
InternalSchemaXorMatchExpression e1;
- e1.add(sub1.shallowClone());
- e1.add(sub2.shallowClone());
+ e1.add(sub1.clone());
+ e1.add(sub2.clone());
InternalSchemaXorMatchExpression e2;
- e2.add(sub1.shallowClone());
+ e2.add(sub1.clone());
ASSERT(e1.equivalent(&e1));
ASSERT_FALSE(e1.equivalent(&e2));
diff --git a/src/mongo/db/ops/parsed_delete.cpp b/src/mongo/db/ops/parsed_delete.cpp
index 9d7ecf79b56..8e32d87d812 100644
--- a/src/mongo/db/ops/parsed_delete.cpp
+++ b/src/mongo/db/ops/parsed_delete.cpp
@@ -124,7 +124,7 @@ Status ParsedDelete::splitOutBucketMatchExpression(const ExtensionsCallback& ext
auto metaField = optMetaField->toString();
std::tie(details->_bucketMatchExpr, details->_residualExpr) =
expression::splitMatchExpressionBy(
- swMatchExpr.getValue()->shallowClone(),
+ swMatchExpr.getValue()->clone(),
{metaField},
{{metaField, timeseries::kBucketMetaFieldName.toString()}},
expression::isOnlyDependentOn);
diff --git a/src/mongo/db/pipeline/change_stream_rewrite_helpers.cpp b/src/mongo/db/pipeline/change_stream_rewrite_helpers.cpp
index ccda68f58ec..2a27148423a 100644
--- a/src/mongo/db/pipeline/change_stream_rewrite_helpers.cpp
+++ b/src/mongo/db/pipeline/change_stream_rewrite_helpers.cpp
@@ -56,7 +56,7 @@ namespace {
std::unique_ptr<PathMatchExpression> cloneWithSubstitution(
const PathMatchExpression* predicate, const StringMap<std::string>& renameList) {
auto clonedPred = std::unique_ptr<PathMatchExpression>(
- static_cast<PathMatchExpression*>(predicate->shallowClone().release()));
+ static_cast<PathMatchExpression*>(predicate->clone().release()));
clonedPred->applyRename(renameList);
return clonedPred;
}
diff --git a/src/mongo/db/pipeline/document_source_change_stream_oplog_match.cpp b/src/mongo/db/pipeline/document_source_change_stream_oplog_match.cpp
index efb9cdf9c6c..79457243c69 100644
--- a/src/mongo/db/pipeline/document_source_change_stream_oplog_match.cpp
+++ b/src/mongo/db/pipeline/document_source_change_stream_oplog_match.cpp
@@ -51,7 +51,7 @@ namespace change_stream_filter {
* entries that would definitely be filtered out by the 'userMatch' filter.
*
* NB: When passing a non-NULL 'userMatch' expression, the resulting expression is built using a
- * "shallow clone" of the 'userMatch' (i.e., the result of 'MatchExpression::shallowClone()') and
+ * "shallow clone" of the 'userMatch' (i.e., the result of 'MatchExpression::clone()') and
* can contain references to strings in the BSONObj that 'userMatch' originated from. Callers that
* keep the new filter long-term should serialize and re-parse it to guard against the possibility
* of stale string references.
diff --git a/src/mongo/db/query/canonical_query.cpp b/src/mongo/db/query/canonical_query.cpp
index 07bcedfc496..406336cdbd3 100644
--- a/src/mongo/db/query/canonical_query.cpp
+++ b/src/mongo/db/query/canonical_query.cpp
@@ -169,7 +169,7 @@ StatusWith<std::unique_ptr<CanonicalQuery>> CanonicalQuery::canonicalize(
baseQuery.getExpCtx(),
std::move(findCommand),
baseQuery.canHaveNoopMatchNodes(),
- root->shallowClone(),
+ root->clone(),
ProjectionPolicies::findProjectionPolicies(),
{} /* an empty pipeline */,
baseQuery.isCountLike());
diff --git a/src/mongo/db/query/index_tag.cpp b/src/mongo/db/query/index_tag.cpp
index 65094671d4e..c71bb810ab9 100644
--- a/src/mongo/db/query/index_tag.cpp
+++ b/src/mongo/db/query/index_tag.cpp
@@ -133,7 +133,7 @@ void attachNode(MatchExpression* node,
OrMatchExpression* targetParent,
size_t targetPosition,
std::unique_ptr<MatchExpression::TagData> tagData) {
- auto clone = node->shallowClone();
+ auto clone = node->clone();
if (clone->matchType() == MatchExpression::NOT) {
IndexTag* indexTag = checked_cast<IndexTag*>(tagData.get());
clone->setTag(new IndexTag(indexTag->index));
diff --git a/src/mongo/db/query/plan_enumerator.cpp b/src/mongo/db/query/plan_enumerator.cpp
index 26dad772006..cebc0486640 100644
--- a/src/mongo/db/query/plan_enumerator.cpp
+++ b/src/mongo/db/query/plan_enumerator.cpp
@@ -377,7 +377,7 @@ unique_ptr<MatchExpression> PlanEnumerator::getNext() {
// Tag with our first solution.
tagMemo(memoIDForNode(_root));
- unique_ptr<MatchExpression> tree(_root->shallowClone());
+ unique_ptr<MatchExpression> tree(_root->clone());
tagForSort(tree.get());
_root->resetTag();
diff --git a/src/mongo/db/query/planner_access.cpp b/src/mongo/db/query/planner_access.cpp
index 7dc31d20296..106fe354716 100644
--- a/src/mongo/db/query/planner_access.cpp
+++ b/src/mongo/db/query/planner_access.cpp
@@ -359,7 +359,7 @@ std::unique_ptr<QuerySolutionNode> QueryPlannerAccess::makeCollectionScan(
// Make the (only) node, a collection scan.
auto csn = std::make_unique<CollectionScanNode>();
csn->name = query.ns();
- csn->filter = query.root()->shallowClone();
+ csn->filter = query.root()->clone();
csn->tailable = tailable;
csn->shouldTrackLatestOplogTimestamp =
params.options & QueryPlannerParams::TRACK_LATEST_OPLOG_TS;
@@ -773,7 +773,7 @@ void buildTextSubPlan(TextMatchNode* tn) {
// If we will be adding a TEXT_OR or OR stage, then it is responsible for applying the
// filter. Otherwise, the index scan applies the filter.
if (!needOrStage && tn->filter) {
- ixscan->filter = tn->filter->shallowClone();
+ ixscan->filter = tn->filter->clone();
}
indexScanList.push_back(std::move(ixscan));
@@ -1424,7 +1424,7 @@ std::unique_ptr<QuerySolutionNode> QueryPlannerAccess::buildIndexedAnd(
// match expression to be sure that the FETCH stage will recheck the entire predicate. It is not
// correct to trim predicates for index intersection plans, as this can lead to spurious matches
// (see SERVER-16750).
- auto clonedRoot = root->shallowClone();
+ auto clonedRoot = root->clone();
std::vector<std::unique_ptr<QuerySolutionNode>> ixscanNodes;
const bool inArrayOperator = !ownedRoot;
@@ -1767,7 +1767,7 @@ std::unique_ptr<QuerySolutionNode> QueryPlannerAccess::scanWholeIndex(
isn->direction = -1;
}
- unique_ptr<MatchExpression> filter = query.root()->shallowClone();
+ unique_ptr<MatchExpression> filter = query.root()->clone();
// If it's find({}) remove the no-op root.
if (MatchExpression::AND == filter->matchType() && (0 == filter->numChildren())) {
@@ -1805,7 +1805,7 @@ void QueryPlannerAccess::addFilterToSolutionNode(QuerySolutionNode* node,
verify(MatchExpression::OR == type);
listFilter = std::make_unique<OrMatchExpression>();
}
- unique_ptr<MatchExpression> oldFilter = node->filter->shallowClone();
+ unique_ptr<MatchExpression> oldFilter = node->filter->clone();
listFilter->add(std::move(oldFilter));
listFilter->add(std::move(match));
node->filter = std::move(listFilter);
@@ -1897,7 +1897,7 @@ std::unique_ptr<QuerySolutionNode> QueryPlannerAccess::makeIndexScan(
isn->bounds.boundInclusion = BoundInclusion::kIncludeStartKeyOnly;
isn->queryCollator = query.getCollator();
- unique_ptr<MatchExpression> filter = query.root()->shallowClone();
+ unique_ptr<MatchExpression> filter = query.root()->clone();
// If it's find({}) remove the no-op root.
if (MatchExpression::AND == filter->matchType() && (0 == filter->numChildren())) {
diff --git a/src/mongo/db/query/planner_analysis.cpp b/src/mongo/db/query/planner_analysis.cpp
index ab80925d666..67702310b83 100644
--- a/src/mongo/db/query/planner_analysis.cpp
+++ b/src/mongo/db/query/planner_analysis.cpp
@@ -268,7 +268,7 @@ void explodeNode(const QuerySolutionNode* node,
// Copy the filter, if there is one.
if (isn->filter.get()) {
- child->filter = isn->filter->shallowClone();
+ child->filter = isn->filter->clone();
}
// Create child bounds.
@@ -288,7 +288,7 @@ void explodeNode(const QuerySolutionNode* node,
// Copy the FETCH's filter, if it exists.
if (origFetchNode->filter.get()) {
- newFetchNode->filter = origFetchNode->filter->shallowClone();
+ newFetchNode->filter = origFetchNode->filter->clone();
}
// Add the 'child' IXSCAN under the FETCH stage, and the FETCH stage to the result set.
diff --git a/src/mongo/db/query/projection_parser.cpp b/src/mongo/db/query/projection_parser.cpp
index e093d840d9f..50cb3b5b97f 100644
--- a/src/mongo/db/query/projection_parser.cpp
+++ b/src/mongo/db/query/projection_parser.cpp
@@ -425,7 +425,7 @@ void parseInclusion(ParseContext* ctx,
// Copy the original match expression, which makes sure to preserve any input parameter ids
// attached to the tree.
- CopyableMatchExpression matcher{ctx->queryObj, ctx->query->shallowClone()};
+ CopyableMatchExpression matcher{ctx->queryObj, ctx->query->clone()};
invariant(ctx->query);
addNodeAtPath(parent,
diff --git a/src/mongo/db/query/query_planner.cpp b/src/mongo/db/query/query_planner.cpp
index a3245cf6de9..ecd7c67ea5d 100644
--- a/src/mongo/db/query/query_planner.cpp
+++ b/src/mongo/db/query/query_planner.cpp
@@ -932,7 +932,7 @@ StatusWith<std::unique_ptr<QuerySolution>> QueryPlanner::planFromCache(
// cases, and we proceed by using the PlanCacheIndexTree to tag the query tree.
// Create a copy of the expression tree. We use cachedSoln to annotate this with indices.
- unique_ptr<MatchExpression> clone = query.root()->shallowClone();
+ unique_ptr<MatchExpression> clone = query.root()->clone();
LOGV2_DEBUG(20963,
5,
@@ -1359,7 +1359,7 @@ StatusWith<std::vector<std::unique_ptr<QuerySolution>>> QueryPlanner::plan(
// Store the plan cache index tree before calling prepareForAccessingPlanning(), so
// that the PlanCacheIndexTree has the same sort as the MatchExpression used to
// generate the plan cache key.
- std::unique_ptr<MatchExpression> clone(nextTaggedTree->shallowClone());
+ std::unique_ptr<MatchExpression> clone(nextTaggedTree->clone());
std::unique_ptr<PlanCacheIndexTree> cacheData;
auto statusWithCacheData = cacheDataFromTaggedTree(clone.get(), relevantIndices);
if (!statusWithCacheData.isOK()) {
@@ -1810,7 +1810,7 @@ StatusWith<QueryPlanner::SubqueriesPlanningResult> QueryPlanner::planSubqueries(
invariant(query.root()->matchType() == MatchExpression::OR);
invariant(query.root()->numChildren(), "Cannot plan subqueries for an $or with no children");
- SubqueriesPlanningResult planningResult{query.root()->shallowClone()};
+ SubqueriesPlanningResult planningResult{query.root()->clone()};
for (size_t i = 0; i < params.indices.size(); ++i) {
const IndexEntry& ie = params.indices[i];
const auto insertionRes = planningResult.indexMap.insert(std::make_pair(ie.identifier, i));
diff --git a/src/mongo/db/query/query_planner_test_lib.cpp b/src/mongo/db/query/query_planner_test_lib.cpp
index 6cedaffc6f3..3814952b2a6 100644
--- a/src/mongo/db/query/query_planner_test_lib.cpp
+++ b/src/mongo/db/query/query_planner_test_lib.cpp
@@ -67,7 +67,7 @@ Status filterMatches(const BSONObj& testFilter,
if (!trueFilter) {
return {ErrorCodes::Error{6298503}, "actual (true) filter was null"};
}
- std::unique_ptr<MatchExpression> trueFilterClone(trueFilter->shallowClone());
+ std::unique_ptr<MatchExpression> trueFilterClone(trueFilter->clone());
MatchExpression::sortTree(trueFilterClone.get());
boost::intrusive_ptr<ExpressionContextForTest> expCtx(new ExpressionContextForTest());
diff --git a/src/mongo/db/query/query_solution.cpp b/src/mongo/db/query/query_solution.cpp
index c321132e89b..c59969e3dc3 100644
--- a/src/mongo/db/query/query_solution.cpp
+++ b/src/mongo/db/query/query_solution.cpp
@@ -1256,7 +1256,7 @@ void ProjectionNode::computeProperties() {
void ProjectionNode::cloneProjectionData(ProjectionNode* copy) const {
// ProjectionNode should not populate filter. This should be a no-op.
if (this->filter)
- copy->filter = this->filter->shallowClone();
+ copy->filter = this->filter->clone();
copy->sortSet = this->sortSet;
}
diff --git a/src/mongo/db/query/query_solution.h b/src/mongo/db/query/query_solution.h
index 47729fefbdb..686764dccc6 100644
--- a/src/mongo/db/query/query_solution.h
+++ b/src/mongo/db/query/query_solution.h
@@ -293,7 +293,7 @@ protected:
other->children.push_back(this->children[i]->clone());
}
if (nullptr != this->filter) {
- other->filter = this->filter->shallowClone();
+ other->filter = this->filter->clone();
}
}
@@ -543,14 +543,14 @@ struct ColumnIndexScanNode : public QuerySolutionNode {
std::unique_ptr<QuerySolutionNode> clone() const final {
StringMap<std::unique_ptr<MatchExpression>> clonedFiltersByPath;
for (auto&& [path, filter] : filtersByPath) {
- clonedFiltersByPath[path] = filter->shallowClone();
+ clonedFiltersByPath[path] = filter->clone();
}
return std::make_unique<ColumnIndexScanNode>(indexEntry,
outputFields,
matchFields,
allFields,
std::move(clonedFiltersByPath),
- postAssemblyFilter->shallowClone(),
+ postAssemblyFilter->clone(),
extraFieldsPermitted);
}