summaryrefslogtreecommitdiff
path: root/src/mongo/db/update
diff options
context:
space:
mode:
authorTed Tuckman <ted.tuckman@mongodb.com>2019-03-26 10:01:50 -0400
committerTed Tuckman <ted.tuckman@mongodb.com>2019-03-27 08:30:16 -0400
commit31568981a81fe446d57f8e8892cf690dff37c7a6 (patch)
tree5b848366dd695fd5b7fbe1b3cadc795adf6a41d6 /src/mongo/db/update
parent3aecf68d4b9cbdb3a9bde86bde945c733f50efe7 (diff)
downloadmongo-31568981a81fe446d57f8e8892cf690dff37c7a6.tar.gz
SERVER-39257 Move FieldRefTempAppend to FieldRef class
Diffstat (limited to 'src/mongo/db/update')
-rw-r--r--src/mongo/db/update/update_array_node.cpp7
-rw-r--r--src/mongo/db/update/update_array_node.h3
-rw-r--r--src/mongo/db/update/update_internal_node.cpp2
-rw-r--r--src/mongo/db/update/update_internal_node.h18
-rw-r--r--src/mongo/db/update/update_object_node.h4
5 files changed, 9 insertions, 25 deletions
diff --git a/src/mongo/db/update/update_array_node.cpp b/src/mongo/db/update/update_array_node.cpp
index 8730c05a0ad..d895272e8f3 100644
--- a/src/mongo/db/update/update_array_node.cpp
+++ b/src/mongo/db/update/update_array_node.cpp
@@ -116,7 +116,8 @@ UpdateNode::ApplyResult UpdateArrayNode::apply(ApplyParams applyParams) const {
// Merge all of the updates for this array element.
invariant(updates->second.size() > 0);
auto mergedChild = updates->second[0];
- FieldRefTempAppend tempAppend(*(applyParams.pathTaken), childElement.getFieldName());
+ FieldRef::FieldRefTempAppend tempAppend(*(applyParams.pathTaken),
+ childElement.getFieldName());
for (size_t j = 1; j < updates->second.size(); ++j) {
// Use the cached merge result, if it is available.
@@ -172,8 +173,8 @@ UpdateNode::ApplyResult UpdateArrayNode::apply(ApplyParams applyParams) const {
// Log the modified array element.
invariant(modifiedElement);
- FieldRefTempAppend tempAppend(*(applyParams.pathTaken),
- modifiedElement->getFieldName());
+ FieldRef::FieldRefTempAppend tempAppend(*(applyParams.pathTaken),
+ modifiedElement->getFieldName());
auto logElement = applyParams.logBuilder->getDocument().makeElementWithNewFieldName(
applyParams.pathTaken->dottedField(), *modifiedElement);
invariant(logElement.ok());
diff --git a/src/mongo/db/update/update_array_node.h b/src/mongo/db/update/update_array_node.h
index 88f3996afa1..2dfad295f62 100644
--- a/src/mongo/db/update/update_array_node.h
+++ b/src/mongo/db/update/update_array_node.h
@@ -86,7 +86,8 @@ public:
std::map<std::string, std::vector<std::pair<std::string, BSONObj>>>*
operatorOrientedUpdates) const final {
for (const auto & [ pathSuffix, child ] : _children) {
- FieldRefTempAppend tempAppend(*currentPath, toArrayFilterIdentifier(pathSuffix));
+ FieldRef::FieldRefTempAppend tempAppend(*currentPath,
+ toArrayFilterIdentifier(pathSuffix));
child->produceSerializationMap(currentPath, operatorOrientedUpdates);
}
}
diff --git a/src/mongo/db/update/update_internal_node.cpp b/src/mongo/db/update/update_internal_node.cpp
index 2ae1ef3c8e3..95cc60eda8e 100644
--- a/src/mongo/db/update/update_internal_node.cpp
+++ b/src/mongo/db/update/update_internal_node.cpp
@@ -85,7 +85,7 @@ std::unique_ptr<UpdateNode> UpdateInternalNode::copyOrMergeAsNecessary(
} else if (!rightNode) {
return leftNode->clone();
} else {
- FieldRefTempAppend tempAppend(
+ FieldRef::FieldRefTempAppend tempAppend(
*pathTaken,
wrapFieldNameAsArrayFilterIdentifier ? toArrayFilterIdentifier(nextField) : nextField);
return UpdateNode::createUpdateNodeByMerging(*leftNode, *rightNode, pathTaken);
diff --git a/src/mongo/db/update/update_internal_node.h b/src/mongo/db/update/update_internal_node.h
index cfb787d2c5a..9cadd04fc57 100644
--- a/src/mongo/db/update/update_internal_node.h
+++ b/src/mongo/db/update/update_internal_node.h
@@ -44,24 +44,6 @@ namespace mongo {
*/
class UpdateInternalNode : public UpdateNode {
public:
- /**
- * Helper class for appending to a FieldRef for the duration of the current scope and then
- * restoring the FieldRef at the end of the scope.
- */
- class FieldRefTempAppend {
- public:
- FieldRefTempAppend(FieldRef& fieldRef, StringData part) : _fieldRef(fieldRef) {
- _fieldRef.appendPart(part);
- }
-
- ~FieldRefTempAppend() {
- _fieldRef.removeLastPart();
- }
-
- private:
- FieldRef& _fieldRef;
- };
-
UpdateInternalNode(UpdateNode::Type type) : UpdateNode(type) {}
/**
diff --git a/src/mongo/db/update/update_object_node.h b/src/mongo/db/update/update_object_node.h
index 2eee5c4d8f3..e09934148ca 100644
--- a/src/mongo/db/update/update_object_node.h
+++ b/src/mongo/db/update/update_object_node.h
@@ -111,12 +111,12 @@ public:
std::map<std::string, std::vector<std::pair<std::string, BSONObj>>>*
operatorOrientedUpdates) const final {
for (const auto & [ pathSuffix, child ] : _children) {
- FieldRefTempAppend tempAppend(*currentPath, pathSuffix);
+ FieldRef::FieldRefTempAppend tempAppend(*currentPath, pathSuffix);
child->produceSerializationMap(currentPath, operatorOrientedUpdates);
}
// Object nodes have a positional child that must be accounted for.
if (_positionalChild) {
- FieldRefTempAppend tempAppend(*currentPath, "$");
+ FieldRef::FieldRefTempAppend tempAppend(*currentPath, "$");
_positionalChild->produceSerializationMap(currentPath, operatorOrientedUpdates);
}
}