summaryrefslogtreecommitdiff
path: root/src/mongo/db
diff options
context:
space:
mode:
authorAndrew Morrow <acm@10gen.com>2013-07-19 17:41:14 -0400
committerAndrew Morrow <acm@10gen.com>2013-07-22 14:03:59 -0400
commitcd03b044d5050a763f7572471aaf2d8c9b3b59d2 (patch)
treee1ecc13a211cc226ec77f020fde8e6c97031cee4 /src/mongo/db
parent4e2b1743b1366a5c6f943dbb40df2d19ac190da5 (diff)
downloadmongo-cd03b044d5050a763f7572471aaf2d8c9b3b59d2.tar.gz
SERVER-10267 Remove in-place state from mods now that mutable and udpate driver handle it
Diffstat (limited to 'src/mongo/db')
-rw-r--r--src/mongo/db/ops/modifier_add_to_set.cpp3
-rw-r--r--src/mongo/db/ops/modifier_add_to_set_test.cpp21
-rw-r--r--src/mongo/db/ops/modifier_bit.cpp15
-rw-r--r--src/mongo/db/ops/modifier_bit_test.cpp32
-rw-r--r--src/mongo/db/ops/modifier_inc.cpp18
-rw-r--r--src/mongo/db/ops/modifier_inc_test.cpp31
-rw-r--r--src/mongo/db/ops/modifier_interface.h3
-rw-r--r--src/mongo/db/ops/modifier_object_replace.h2
-rw-r--r--src/mongo/db/ops/modifier_pop.cpp4
-rw-r--r--src/mongo/db/ops/modifier_pop_test.cpp19
-rw-r--r--src/mongo/db/ops/modifier_pull.cpp3
-rw-r--r--src/mongo/db/ops/modifier_pull_all.cpp5
-rw-r--r--src/mongo/db/ops/modifier_pull_all_test.cpp14
-rw-r--r--src/mongo/db/ops/modifier_pull_test.cpp22
-rw-r--r--src/mongo/db/ops/modifier_push_test.cpp38
-rw-r--r--src/mongo/db/ops/modifier_rename.cpp4
-rw-r--r--src/mongo/db/ops/modifier_rename_test.cpp12
-rw-r--r--src/mongo/db/ops/modifier_set.cpp14
-rw-r--r--src/mongo/db/ops/modifier_set_test.cpp48
-rw-r--r--src/mongo/db/ops/modifier_unset.cpp7
-rw-r--r--src/mongo/db/ops/modifier_unset_test.cpp36
21 files changed, 123 insertions, 228 deletions
diff --git a/src/mongo/db/ops/modifier_add_to_set.cpp b/src/mongo/db/ops/modifier_add_to_set.cpp
index 16b88051974..a35e2b4268a 100644
--- a/src/mongo/db/ops/modifier_add_to_set.cpp
+++ b/src/mongo/db/ops/modifier_add_to_set.cpp
@@ -262,10 +262,9 @@ namespace mongo {
eachIter = eachIter.rightSibling();
}
- // If we didn't find any elements to add, then this is a no-op, and therefore in place.
+ // If we didn't find any elements to add, then this is a no-op.
if (_preparedState->elementsToAdd.empty()) {
_preparedState->noOp = execInfo->noOp = true;
- execInfo->inPlace = true;
}
return Status::OK();
diff --git a/src/mongo/db/ops/modifier_add_to_set_test.cpp b/src/mongo/db/ops/modifier_add_to_set_test.cpp
index dd3a2d30ea4..0257741bdb6 100644
--- a/src/mongo/db/ops/modifier_add_to_set_test.cpp
+++ b/src/mongo/db/ops/modifier_add_to_set_test.cpp
@@ -124,7 +124,6 @@ namespace {
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a");
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
}
@@ -135,7 +134,6 @@ namespace {
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a");
- ASSERT_TRUE(execInfo.inPlace);
ASSERT_TRUE(execInfo.noOp);
Document logDoc;
@@ -167,10 +165,10 @@ namespace {
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a");
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(mod.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson("{ a : [ 1 ] }"), doc);
Document logDoc;
@@ -186,10 +184,10 @@ namespace {
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a");
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(mod.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson("{ a : [ 1 ] }"), doc);
Document logDoc;
@@ -205,10 +203,10 @@ namespace {
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a");
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(mod.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson("{ a : [ 1, 2, 3 ] }"), doc);
Document logDoc;
@@ -224,10 +222,10 @@ namespace {
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a");
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(mod.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson("{ a : [ 1, 2, 3 ] }"), doc);
Document logDoc;
@@ -243,10 +241,10 @@ namespace {
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a");
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(mod.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson("{ a : [ 'x', 1 ] }"), doc);
Document logDoc;
@@ -262,10 +260,10 @@ namespace {
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a");
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(mod.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson("{ a : [ 'x', 1, 2, 3 ] }"), doc);
Document logDoc;
@@ -281,7 +279,6 @@ namespace {
ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a");
ASSERT_TRUE(execInfo.noOp);
- ASSERT_TRUE(execInfo.inPlace);
Document logDoc;
LogBuilder logBuilder(logDoc.root());
@@ -296,7 +293,6 @@ namespace {
ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a");
ASSERT_TRUE(execInfo.noOp);
- ASSERT_TRUE(execInfo.inPlace);
Document logDoc;
LogBuilder logBuilder(logDoc.root());
@@ -311,7 +307,6 @@ namespace {
ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a");
ASSERT_TRUE(execInfo.noOp);
- ASSERT_TRUE(execInfo.inPlace);
Document logDoc;
LogBuilder logBuilder(logDoc.root());
@@ -327,9 +322,9 @@ namespace {
ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a");
ASSERT_FALSE(execInfo.noOp);
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_OK(mod.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson("{ a : [ 1, 1, 2, 1, 2, 2, 3] }"), doc);
Document logDoc;
@@ -346,9 +341,9 @@ namespace {
ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a");
ASSERT_FALSE(execInfo.noOp);
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_OK(mod.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson("{ a : [ 1, 1, 2, 1, 2, 2, 4, 3] }"), doc);
Document logDoc;
diff --git a/src/mongo/db/ops/modifier_bit.cpp b/src/mongo/db/ops/modifier_bit.cpp
index ca20f02feed..df8332ecb12 100644
--- a/src/mongo/db/ops/modifier_bit.cpp
+++ b/src/mongo/db/ops/modifier_bit.cpp
@@ -34,7 +34,6 @@ namespace mongo {
, idxFound(0)
, elemFound(doc.end())
, boundDollar("")
- , inPlace(false)
, noOp(false) {
}
@@ -53,9 +52,6 @@ namespace mongo {
// Value to be applied.
SafeNum newValue;
- // True if this update can be applied in place.
- bool inPlace;
-
// True if this update is a no-op
bool noOp;
};
@@ -189,19 +185,12 @@ namespace mongo {
return Status(ErrorCodes::BadValue,
"Failed to apply $bit to current value");
- // If the values are identical (same type, same value), then this is a no-op, and
- // therefore in-place as well.
+ // If the values are identical (same type, same value), then this is a no-op.
if (_preparedState->newValue.isIdentical(currentValue)) {
_preparedState->noOp = execInfo->noOp = true;
- _preparedState->inPlace = execInfo->inPlace = true;
return Status::OK();
}
- // TODO: Cases where the type changes but size is the same.
- if (currentValue.type() == _preparedState->newValue.type()) {
- _preparedState->inPlace = execInfo->inPlace = true;
- }
-
return Status::OK();
}
@@ -215,8 +204,6 @@ namespace mongo {
return _preparedState->elemFound.setValueSafeNum(_preparedState->newValue);
}
- dassert(_preparedState->inPlace == false);
-
//
// Complete document path logic
//
diff --git a/src/mongo/db/ops/modifier_bit_test.cpp b/src/mongo/db/ops/modifier_bit_test.cpp
index cd11f0246c1..79b940c2a77 100644
--- a/src/mongo/db/ops/modifier_bit_test.cpp
+++ b/src/mongo/db/ops/modifier_bit_test.cpp
@@ -123,7 +123,6 @@ namespace {
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
}
@@ -134,7 +133,6 @@ namespace {
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
- ASSERT_TRUE(execInfo.inPlace);
ASSERT_TRUE(execInfo.noOp);
Document logDoc;
@@ -174,10 +172,10 @@ namespace {
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(mod.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson("{ a : 0 }"), doc);
Document logDoc;
@@ -192,10 +190,10 @@ namespace {
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(mod.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson("{ a : 1 }"), doc);
Document logDoc;
@@ -210,10 +208,10 @@ namespace {
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
- ASSERT_TRUE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(mod.apply());
+ ASSERT_TRUE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson("{ a : 4 }"), doc);
Document logDoc;
@@ -228,10 +226,10 @@ namespace {
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
- ASSERT_TRUE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(mod.apply());
+ ASSERT_TRUE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson("{ a : 7 }"), doc);
Document logDoc;
@@ -247,7 +245,6 @@ namespace {
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
ASSERT_TRUE(execInfo.noOp);
- ASSERT_TRUE(execInfo.inPlace);
Document logDoc;
LogBuilder logBuilder(logDoc.root());
@@ -262,7 +259,6 @@ namespace {
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
ASSERT_TRUE(execInfo.noOp);
- ASSERT_TRUE(execInfo.inPlace);
Document logDoc;
LogBuilder logBuilder(logDoc.root());
@@ -277,7 +273,6 @@ namespace {
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
ASSERT_TRUE(execInfo.noOp);
- ASSERT_TRUE(execInfo.inPlace);
Document logDoc;
LogBuilder logBuilder(logDoc.root());
@@ -292,7 +287,6 @@ namespace {
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
ASSERT_TRUE(execInfo.noOp);
- ASSERT_TRUE(execInfo.inPlace);
Document logDoc;
LogBuilder logBuilder(logDoc.root());
@@ -307,7 +301,6 @@ namespace {
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
ASSERT_FALSE(execInfo.noOp);
- ASSERT_FALSE(execInfo.inPlace);
}
TEST(InPlace, IntToLongOrIsNotInPlace) {
@@ -317,7 +310,6 @@ namespace {
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
ASSERT_FALSE(execInfo.noOp);
- ASSERT_FALSE(execInfo.inPlace);
}
TEST(NoOp, IntAnd) {
@@ -327,7 +319,6 @@ namespace {
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
ASSERT_TRUE(execInfo.noOp);
- ASSERT_TRUE(execInfo.inPlace);
Document logDoc;
LogBuilder logBuilder(logDoc.root());
@@ -342,7 +333,6 @@ namespace {
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
ASSERT_TRUE(execInfo.noOp);
- ASSERT_TRUE(execInfo.inPlace);
Document logDoc;
LogBuilder logBuilder(logDoc.root());
@@ -357,7 +347,6 @@ namespace {
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
ASSERT_TRUE(execInfo.noOp);
- ASSERT_TRUE(execInfo.inPlace);
Document logDoc;
LogBuilder logBuilder(logDoc.root());
@@ -373,7 +362,6 @@ namespace {
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
ASSERT_TRUE(execInfo.noOp);
- ASSERT_TRUE(execInfo.inPlace);
Document logDoc;
LogBuilder logBuilder(logDoc.root());
@@ -389,9 +377,9 @@ namespace {
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
ASSERT_FALSE(execInfo.noOp);
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_OK(mod.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson("{ a : 1 }"), doc);
ASSERT_EQUALS(mongo::NumberLong, doc.root()["a"].getType());
}
@@ -403,9 +391,9 @@ namespace {
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
ASSERT_FALSE(execInfo.noOp);
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_OK(mod.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson("{ a : 1 }"), doc);
ASSERT_EQUALS(mongo::NumberLong, doc.root()["a"].getType());
}
@@ -417,9 +405,9 @@ namespace {
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
ASSERT_FALSE(execInfo.noOp);
- ASSERT_TRUE(execInfo.inPlace);
ASSERT_OK(mod.apply());
+ ASSERT_TRUE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson("{ a : 0 }"), doc);
ASSERT_EQUALS(mongo::NumberLong, doc.root()["a"].getType());
}
@@ -431,9 +419,9 @@ namespace {
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
ASSERT_FALSE(execInfo.noOp);
- ASSERT_TRUE(execInfo.inPlace);
ASSERT_OK(mod.apply());
+ ASSERT_TRUE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson("{ a : 3 }"), doc);
ASSERT_EQUALS(mongo::NumberLong, doc.root()["a"].getType());
}
@@ -448,9 +436,9 @@ namespace {
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
ASSERT_FALSE(execInfo.noOp);
- ASSERT_TRUE(execInfo.inPlace);
ASSERT_OK(mod.apply());
+ ASSERT_TRUE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(BSON("a" << static_cast<int>(1)), doc);
ASSERT_EQUALS(mongo::NumberInt, doc.root()["a"].getType());
@@ -467,9 +455,9 @@ namespace {
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
ASSERT_FALSE(execInfo.noOp);
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_OK(mod.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(BSON("a" << static_cast<int>(0) << "b" << static_cast<int>(1)), doc);
ASSERT_EQUALS(mongo::NumberInt, doc.root()["a"].getType());
diff --git a/src/mongo/db/ops/modifier_inc.cpp b/src/mongo/db/ops/modifier_inc.cpp
index eef9b0d2f64..e78ad09343c 100644
--- a/src/mongo/db/ops/modifier_inc.cpp
+++ b/src/mongo/db/ops/modifier_inc.cpp
@@ -35,7 +35,6 @@ namespace mongo {
, elemFound(doc.end())
, boundDollar("")
, newValue()
- , inPlace(false)
, noOp(false) {
}
@@ -54,9 +53,6 @@ namespace mongo {
// Value to be applied
SafeNum newValue;
- // This $inc is in-place?
- bool inPlace;
-
// This $inc is a no-op?
bool noOp;
};
@@ -177,22 +173,12 @@ namespace mongo {
return Status(ErrorCodes::BadValue,
"Failed to increment current value");
- // If the values are identical (same type, same value), then this is a no-op, and
- // therefore in-place as well.
+ // If the values are identical (same type, same value), then this is a no-op.
if (_preparedState->newValue.isIdentical(currentValue)) {
_preparedState->noOp = execInfo->noOp = true;
- _preparedState->inPlace = execInfo->inPlace = true;
return Status::OK();
}
- // If the types are the same, this can be done in place.
- //
- // TODO: Potentially, cases where $inc results in a mixed type of the same size could
- // be in-place as well, but we don't currently handle them.
- if (_preparedState->newValue.type() == currentValue.type()) {
- _preparedState->inPlace = execInfo->inPlace = true;
- }
-
return Status::OK();
}
@@ -206,8 +192,6 @@ namespace mongo {
return _preparedState->elemFound.setValueSafeNum(_preparedState->newValue);
}
- dassert(_preparedState->inPlace == false);
-
//
// Complete document path logic
//
diff --git a/src/mongo/db/ops/modifier_inc_test.cpp b/src/mongo/db/ops/modifier_inc_test.cpp
index b5e76e8cfde..f399c31ffb2 100644
--- a/src/mongo/db/ops/modifier_inc_test.cpp
+++ b/src/mongo/db/ops/modifier_inc_test.cpp
@@ -113,7 +113,7 @@ namespace {
ASSERT_OK(incMod.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a");
- ASSERT_TRUE(execInfo.inPlace);
+ ASSERT_TRUE(doc.isInPlaceModeEnabled());
ASSERT_FALSE(execInfo.noOp);
}
@@ -148,10 +148,10 @@ namespace {
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(incMod.prepare(doc.root(), "", &execInfo));
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(incMod.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson("{ a : 1 }"), doc);
Document logDoc;
@@ -166,7 +166,6 @@ namespace {
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(incMod.prepare(doc.root(), "", &execInfo));
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
Document logDoc;
@@ -181,10 +180,10 @@ namespace {
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(incMod.prepare(doc.root(), "", &execInfo));
- ASSERT_TRUE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(incMod.apply());
+ ASSERT_TRUE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson("{ a : 3 }"), doc);
Document logDoc;
@@ -199,10 +198,10 @@ namespace {
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(incMod.prepare(doc.root(), "", &execInfo));
- ASSERT_TRUE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(incMod.apply());
+ ASSERT_TRUE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson("{ a : { b : 3 } }"), doc);
Document logDoc;
@@ -217,7 +216,6 @@ namespace {
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(incMod.prepare(doc.root(), "", &execInfo));
ASSERT_FALSE(execInfo.noOp);
- ASSERT_TRUE(execInfo.inPlace);
}
TEST(InPlace, LongToLong) {
@@ -226,7 +224,6 @@ namespace {
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(incMod.prepare(doc.root(), "", &execInfo));
ASSERT_FALSE(execInfo.noOp);
- ASSERT_TRUE(execInfo.inPlace);
}
TEST(InPlace, DoubleToDouble) {
@@ -235,7 +232,6 @@ namespace {
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(incMod.prepare(doc.root(), "", &execInfo));
ASSERT_FALSE(execInfo.noOp);
- ASSERT_TRUE(execInfo.inPlace);
}
TEST(NoOp, Int) {
@@ -244,7 +240,6 @@ namespace {
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(incMod.prepare(doc.root(), "", &execInfo));
ASSERT_TRUE(execInfo.noOp);
- ASSERT_TRUE(execInfo.inPlace);
}
TEST(NoOp, Long) {
@@ -253,7 +248,6 @@ namespace {
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(incMod.prepare(doc.root(), "", &execInfo));
ASSERT_TRUE(execInfo.noOp);
- ASSERT_TRUE(execInfo.inPlace);
}
TEST(NoOp, Double) {
@@ -262,7 +256,6 @@ namespace {
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(incMod.prepare(doc.root(), "", &execInfo));
ASSERT_TRUE(execInfo.noOp);
- ASSERT_TRUE(execInfo.inPlace);
}
TEST(Upcasting, UpcastIntToLong) {
@@ -276,9 +269,9 @@ namespace {
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(incMod.prepare(doc.root(), "", &execInfo));
ASSERT_FALSE(execInfo.noOp);
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_OK(incMod.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson("{ a : 1 }"), doc);
ASSERT_EQUALS(mongo::NumberLong, doc.root()["a"].getType());
@@ -300,9 +293,9 @@ namespace {
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(incMod.prepare(doc.root(), "", &execInfo));
ASSERT_FALSE(execInfo.noOp);
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_OK(incMod.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson("{ a : 1.0 }"), doc);
ASSERT_EQUALS(mongo::NumberDouble, doc.root()["a"].getType());
@@ -324,9 +317,9 @@ namespace {
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(incMod.prepare(doc.root(), "", &execInfo));
ASSERT_FALSE(execInfo.noOp);
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_OK(incMod.apply());
+ ASSERT_TRUE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson("{ a : 1.0 }"), doc);
ASSERT_EQUALS(mongo::NumberDouble, doc.root()["a"].getType());
@@ -347,9 +340,9 @@ namespace {
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(incMod.prepare(doc.root(), "", &execInfo));
ASSERT_FALSE(execInfo.noOp);
- ASSERT_TRUE(execInfo.inPlace);
ASSERT_OK(incMod.apply());
+ ASSERT_TRUE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson("{ a : 2.0 }"), doc);
ASSERT_EQUALS(mongo::NumberDouble, doc.root()["a"].getType());
@@ -373,11 +366,11 @@ namespace {
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(incMod.prepare(doc.root(), "", &execInfo));
ASSERT_FALSE(execInfo.noOp);
- ASSERT_FALSE(execInfo.inPlace);
const long long target_value = static_cast<long long>(initial_value) + 1;
ASSERT_OK(incMod.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(BSON("a" << target_value), doc);
}
@@ -391,11 +384,11 @@ namespace {
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(incMod.prepare(doc.root(), "", &execInfo));
ASSERT_FALSE(execInfo.noOp);
- ASSERT_FALSE(execInfo.inPlace);
const long long target_value = static_cast<long long>(initial_value) - 1;
ASSERT_OK(incMod.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(BSON("a" << target_value), doc);
}
@@ -407,17 +400,17 @@ namespace {
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(incMod.prepare(doc1.root(), "", &execInfo));
- ASSERT_TRUE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(incMod.apply());
+ ASSERT_TRUE(doc1.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson("{ a : 2 }"), doc1);
ASSERT_OK(incMod.prepare(doc2.root(), "", &execInfo));
- ASSERT_TRUE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(incMod.apply());
+ ASSERT_TRUE(doc2.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson("{ a : 2 }"), doc2);
}
diff --git a/src/mongo/db/ops/modifier_interface.h b/src/mongo/db/ops/modifier_interface.h
index 3341de8ba20..9d39bb67947 100644
--- a/src/mongo/db/ops/modifier_interface.h
+++ b/src/mongo/db/ops/modifier_interface.h
@@ -141,7 +141,7 @@ namespace mongo {
ANY_CONTEXT
};
- ExecInfo() : inPlace(false), noOp(false), context(ANY_CONTEXT) {
+ ExecInfo() : noOp(false), context(ANY_CONTEXT) {
for (int i = 0; i < MAX_NUM_FIELDS; i++) {
fieldRef[i] = NULL;
}
@@ -149,7 +149,6 @@ namespace mongo {
// The fields of concern to the driver: no other op may modify the fields listed here.
FieldRef* fieldRef[MAX_NUM_FIELDS]; // not owned here
- bool inPlace;
bool noOp;
UpdateContext context;
};
diff --git a/src/mongo/db/ops/modifier_object_replace.h b/src/mongo/db/ops/modifier_object_replace.h
index f81ec8de299..df175b4fd90 100644
--- a/src/mongo/db/ops/modifier_object_replace.h
+++ b/src/mongo/db/ops/modifier_object_replace.h
@@ -50,7 +50,7 @@ namespace mongo {
/**
* Registers the that 'root' is in the document that we want to fully replace.
- * prepare() returns OK and always fills 'execInfo' with false for inPlace and true for
+ * prepare() returns OK and always fills 'execInfo' with true for
* noOp.
*/
virtual Status prepare(mutablebson::Element root,
diff --git a/src/mongo/db/ops/modifier_pop.cpp b/src/mongo/db/ops/modifier_pop.cpp
index b70b69d3d07..fcb7e6f2c9e 100644
--- a/src/mongo/db/ops/modifier_pop.cpp
+++ b/src/mongo/db/ops/modifier_pop.cpp
@@ -128,7 +128,7 @@ namespace mongo {
// No children, nothing to do -- not an error state
if (!_preparedState->pathFoundElement.hasChildren()) {
- execInfo->noOp = execInfo->inPlace = true;
+ execInfo->noOp = true;
} else {
_preparedState->elementToRemove = _fromTop ?
_preparedState->pathFoundElement.leftChild() :
@@ -136,7 +136,7 @@ namespace mongo {
}
} else {
// Let the caller know we can't do anything given the mod, _fieldRef, and doc.
- execInfo->noOp = execInfo->inPlace = true;
+ execInfo->noOp = true;
_preparedState->pathFoundElement = root.getDocument().end();
//okay if path not found
diff --git a/src/mongo/db/ops/modifier_pop_test.cpp b/src/mongo/db/ops/modifier_pop_test.cpp
index 5e278e9ac31..f1fedd08993 100644
--- a/src/mongo/db/ops/modifier_pop_test.cpp
+++ b/src/mongo/db/ops/modifier_pop_test.cpp
@@ -104,7 +104,6 @@ namespace {
ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "s");
- ASSERT_TRUE(execInfo.inPlace);
ASSERT_TRUE(execInfo.noOp);
Document logDoc;
@@ -121,7 +120,6 @@ namespace {
ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a");
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
}
@@ -133,10 +131,10 @@ namespace {
ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a");
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(mod.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson(("{a: [1]}")), doc);
}
@@ -148,7 +146,6 @@ namespace {
ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a");
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
}
@@ -160,10 +157,10 @@ namespace {
ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a");
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(mod.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson(("{a: [2]}")), doc);
}
@@ -175,10 +172,10 @@ namespace {
ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a");
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(mod.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson(("{a: [1]}")), doc);
}
@@ -190,10 +187,10 @@ namespace {
ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a");
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(mod.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson(("{a:[1]}")), doc);
Document logDoc;
@@ -210,7 +207,6 @@ namespace {
ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a");
- ASSERT_TRUE(execInfo.inPlace);
ASSERT_TRUE(execInfo.noOp);
}
@@ -222,10 +218,10 @@ namespace {
ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a");
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(mod.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson(("{a:[]}")), doc);
Document logDoc;
@@ -242,10 +238,10 @@ namespace {
ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a.0");
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(mod.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson(("{a:[[1], 1]}")), doc);
Document logDoc;
@@ -262,10 +258,10 @@ namespace {
ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a.0");
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(mod.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson(("{a:[[], 1]}")), doc);
Document logDoc;
@@ -281,6 +277,5 @@ namespace {
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
ASSERT_TRUE(execInfo.noOp);
- ASSERT_TRUE(execInfo.inPlace);
}
} // unnamed namespace
diff --git a/src/mongo/db/ops/modifier_pull.cpp b/src/mongo/db/ops/modifier_pull.cpp
index 0e886328284..ddd95200392 100644
--- a/src/mongo/db/ops/modifier_pull.cpp
+++ b/src/mongo/db/ops/modifier_pull.cpp
@@ -135,7 +135,6 @@ namespace mongo {
_preparedState->idxFound < (_fieldRef.numParts() - 1)) {
// If no target element exists, then there is nothing to do here.
_preparedState->noOp = execInfo->noOp = true;
- execInfo->inPlace = true;
return Status::OK();
}
@@ -148,7 +147,6 @@ namespace mongo {
// If the array is empty, there is nothing to pull, so this is a noop.
if (!_preparedState->elemFound.hasChildren()) {
_preparedState->noOp = execInfo->noOp = true;
- execInfo->inPlace = true;
return Status::OK();
}
@@ -165,7 +163,6 @@ namespace mongo {
// If we didn't find any elements to add, then this is a no-op, and therefore in place.
if (_preparedState->elementsToRemove.empty()) {
_preparedState->noOp = execInfo->noOp = true;
- execInfo->inPlace = true;
}
return Status::OK();
diff --git a/src/mongo/db/ops/modifier_pull_all.cpp b/src/mongo/db/ops/modifier_pull_all.cpp
index f805dd8560d..e4ca877e419 100644
--- a/src/mongo/db/ops/modifier_pull_all.cpp
+++ b/src/mongo/db/ops/modifier_pull_all.cpp
@@ -144,7 +144,7 @@ namespace mongo {
// No children, nothing to do -- not an error state
if (!_preparedState->pathFoundElement.hasChildren()) {
- execInfo->inPlace = execInfo->noOp = true;
+ execInfo->noOp = true;
} else {
mutablebson::Element elem = _preparedState->pathFoundElement.leftChild();
while (elem.ok()) {
@@ -159,13 +159,12 @@ namespace mongo {
// Nothing to remove so it is a noOp.
if (_preparedState->elementsToRemove.empty())
- execInfo->inPlace = execInfo->noOp = true;
+ execInfo->noOp = true;
}
} else {
// Let the caller know we can't do anything given the mod, _fieldRef, and doc.
execInfo->noOp = true;
- execInfo->inPlace = true;
//okay if path not found
diff --git a/src/mongo/db/ops/modifier_pull_all_test.cpp b/src/mongo/db/ops/modifier_pull_all_test.cpp
index 1053cf8d74d..85899c9ace1 100644
--- a/src/mongo/db/ops/modifier_pull_all_test.cpp
+++ b/src/mongo/db/ops/modifier_pull_all_test.cpp
@@ -99,9 +99,9 @@ namespace {
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
ASSERT_FALSE(execInfo.noOp);
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_OK(mod.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson("{ a : ['a', {r:1, b:2}] }"), doc);
}
@@ -112,9 +112,9 @@ namespace {
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
ASSERT_TRUE(execInfo.noOp);
- ASSERT_TRUE(execInfo.inPlace);
ASSERT_OK(mod.apply());
+ ASSERT_TRUE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson("{ a : [1, 'a', {r:1, b:2}] }"), doc);
}
@@ -125,9 +125,9 @@ namespace {
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
ASSERT_FALSE(execInfo.noOp);
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_OK(mod.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson("{ a : [{r:1, b:2}] }"), doc);
}
@@ -138,9 +138,9 @@ namespace {
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
ASSERT_FALSE(execInfo.noOp);
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_OK(mod.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson("{ a : [] }"), doc);
Document logDoc;
@@ -156,9 +156,9 @@ namespace {
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
ASSERT_FALSE(execInfo.noOp);
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_OK(mod.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson("{ a : [] }"), doc);
Document logDoc;
@@ -174,9 +174,9 @@ namespace {
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
ASSERT_FALSE(execInfo.noOp);
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_OK(mod.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson("{ a : [] }"), doc);
Document logDoc;
@@ -192,7 +192,6 @@ namespace {
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
ASSERT_TRUE(execInfo.noOp);
- ASSERT_TRUE(execInfo.inPlace);
Document logDoc;
LogBuilder logBuilder(logDoc.root());
@@ -207,7 +206,6 @@ namespace {
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
ASSERT_TRUE(execInfo.noOp);
- ASSERT_TRUE(execInfo.inPlace);
Document logDoc;
LogBuilder logBuilder(logDoc.root());
diff --git a/src/mongo/db/ops/modifier_pull_test.cpp b/src/mongo/db/ops/modifier_pull_test.cpp
index 064d717006a..d8239dfc36b 100644
--- a/src/mongo/db/ops/modifier_pull_test.cpp
+++ b/src/mongo/db/ops/modifier_pull_test.cpp
@@ -79,7 +79,6 @@ namespace {
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a");
- ASSERT_TRUE(execInfo.inPlace);
ASSERT_TRUE(execInfo.noOp);
Document logDoc;
@@ -95,7 +94,6 @@ namespace {
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a");
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
}
@@ -122,7 +120,6 @@ namespace {
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a");
- ASSERT_TRUE(execInfo.inPlace);
ASSERT_TRUE(execInfo.noOp);
Document logDoc;
@@ -138,7 +135,6 @@ namespace {
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a.b.c.d");
- ASSERT_TRUE(execInfo.inPlace);
ASSERT_TRUE(execInfo.noOp);
Document logDoc;
@@ -154,7 +150,6 @@ namespace {
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a");
- ASSERT_TRUE(execInfo.inPlace);
ASSERT_TRUE(execInfo.noOp);
Document logDoc;
@@ -170,7 +165,6 @@ namespace {
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a");
- ASSERT_TRUE(execInfo.inPlace);
ASSERT_TRUE(execInfo.noOp);
Document logDoc;
@@ -186,10 +180,10 @@ namespace {
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a");
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(mod.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson("{ a : [ 1, 2, 3, 4, 5 ] }"), doc);
Document logDoc;
@@ -205,10 +199,10 @@ namespace {
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a");
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(mod.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson("{ a : [ 1, 2, 3, 4, 5 ] }"), doc);
Document logDoc;
@@ -224,10 +218,10 @@ namespace {
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a");
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(mod.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson("{ a : [] }"), doc);
Document logDoc;
@@ -265,10 +259,10 @@ namespace {
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a.b");
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(mod.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson(strings[2]), doc);
Document logDoc;
@@ -300,10 +294,10 @@ namespace {
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a.b");
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(mod.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson(strings[2]), doc);
Document logDoc;
@@ -335,10 +329,10 @@ namespace {
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a.b");
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(mod.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson(strings[2]), doc);
Document logDoc;
@@ -369,10 +363,10 @@ namespace {
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a");
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(mod.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson(strings[2]), doc);
Document logDoc;
@@ -403,10 +397,10 @@ namespace {
ModifierInterface::ExecInfo execInfo;
ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a");
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(mod.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson(strings[2]), doc);
Document logDoc;
diff --git a/src/mongo/db/ops/modifier_push_test.cpp b/src/mongo/db/ops/modifier_push_test.cpp
index df12ff2fc2c..aececbe3b3b 100644
--- a/src/mongo/db/ops/modifier_push_test.cpp
+++ b/src/mongo/db/ops/modifier_push_test.cpp
@@ -466,10 +466,10 @@ namespace {
ASSERT_OK(pushMod.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a");
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(pushMod.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson("{a: [1]}"), doc);
Document logDoc;
@@ -487,10 +487,10 @@ namespace {
ASSERT_OK(pushMod.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a");
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(pushMod.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson("{a: [1]}"), doc);
Document logDoc;
@@ -508,10 +508,10 @@ namespace {
ASSERT_OK(pushMod.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a");
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(pushMod.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson("{a: [0,1]}"), doc);
Document logDoc;
@@ -541,10 +541,10 @@ namespace {
ASSERT_OK(pushMod.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a");
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(pushMod.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson("{a: [{b:1}]}"), doc);
Document logDoc;
@@ -562,10 +562,10 @@ namespace {
ASSERT_OK(pushMod.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a");
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(pushMod.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson("{a: [{b:1}]}"), doc);
Document logDoc;
@@ -583,10 +583,10 @@ namespace {
ASSERT_OK(pushMod.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a");
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(pushMod.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson("{a: [{b:0},{b:1}]}"), doc);
Document logDoc;
@@ -609,10 +609,10 @@ namespace {
ASSERT_OK(pushMod.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "choices.first.votes");
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(pushMod.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson( "{ _id : 1 , "
" question : 'a', "
" choices : { "
@@ -641,10 +641,10 @@ namespace {
ASSERT_OK(pushMod.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a");
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(pushMod.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(doc, fromjson("{a: [1]}"));
Document logDoc;
@@ -662,10 +662,10 @@ namespace {
ASSERT_OK(pushMod.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a");
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(pushMod.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(doc, fromjson("{a: [1]}"));
Document logDoc;
@@ -683,10 +683,10 @@ namespace {
ASSERT_OK(pushMod.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a");
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(pushMod.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_TRUE(checkDoc(doc, fromjson("{a: [0,1,2]}")));
Document logDoc;
@@ -716,10 +716,10 @@ namespace {
ASSERT_OK(pushMod.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a");
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(pushMod.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson("{a: [1]}"), doc);
Document logDoc;
@@ -737,10 +737,10 @@ namespace {
ASSERT_OK(pushMod.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a");
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(pushMod.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson("{a: [1]}"), doc);
Document logDoc;
@@ -758,10 +758,10 @@ namespace {
ASSERT_OK(pushMod.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a");
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(pushMod.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson("{a: [1, 2]}"), doc);
Document logDoc;
@@ -779,10 +779,10 @@ namespace {
ASSERT_OK(pushMod.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a");
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(pushMod.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson("{a: [0,1]}"), doc);
Document logDoc;
@@ -800,10 +800,10 @@ namespace {
ASSERT_OK(pushMod.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a");
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(pushMod.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson("{a: [0,1,2]}"), doc);
Document logDoc;
@@ -927,10 +927,10 @@ namespace {
ASSERT_OK(mod().prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a");
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(mod().apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
vector<int> combinedVec;
combineVec(docArray, /* a: [] */
@@ -958,10 +958,10 @@ namespace {
ASSERT_OK(mod().prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a");
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(mod().apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
vector<int> combinedVec;
combineVec(docArray, /* a: [2, 3] */
@@ -1000,10 +1000,10 @@ namespace {
ASSERT_OK(mod().prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a");
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(mod().apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
vector<BSONObj> combinedVec;
combineAndSortVec(docArray, /* a: [] */
@@ -1054,10 +1054,10 @@ namespace {
ASSERT_OK(mod().prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a");
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(mod().apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
vector<BSONObj> combinedVec;
combineAndSortVec(docArray, /* a: [{a:2,b:3},{a:3,:b1}] */
diff --git a/src/mongo/db/ops/modifier_rename.cpp b/src/mongo/db/ops/modifier_rename.cpp
index af28f5f06e1..680195ece71 100644
--- a/src/mongo/db/ops/modifier_rename.cpp
+++ b/src/mongo/db/ops/modifier_rename.cpp
@@ -130,7 +130,7 @@ namespace mongo {
// If we can't find the full element in the from field then we can't do anything.
if (!status.isOK()) {
- execInfo->inPlace = execInfo->noOp = true;
+ execInfo->noOp = true;
_preparedState->fromElemFound = root.getDocument().end();
// TODO: remove this special case from existing behavior
@@ -183,7 +183,7 @@ namespace mongo {
execInfo->fieldRef[0] = &_fromFieldRef;
execInfo->fieldRef[1] = &_toFieldRef;
- execInfo->inPlace = execInfo->noOp = false;
+ execInfo->noOp = false;
return Status::OK();
}
diff --git a/src/mongo/db/ops/modifier_rename_test.cpp b/src/mongo/db/ops/modifier_rename_test.cpp
index 6c6065c2303..a63d0d5fedb 100644
--- a/src/mongo/db/ops/modifier_rename_test.cpp
+++ b/src/mongo/db/ops/modifier_rename_test.cpp
@@ -130,10 +130,10 @@ namespace {
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a");
ASSERT_EQUALS(execInfo.fieldRef[1]->dottedField(), "b");
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(setMod.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(doc, fromjson("{b:2}"));
Document logDoc;
@@ -152,10 +152,10 @@ namespace {
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a");
ASSERT_EQUALS(execInfo.fieldRef[1]->dottedField(), "b");
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(setMod.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(doc, fromjson("{b:2}"));
Document logDoc;
@@ -174,10 +174,10 @@ namespace {
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a.c");
ASSERT_EQUALS(execInfo.fieldRef[1]->dottedField(), "b");
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(setMod.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(doc, fromjson("{a: {}, b:{ d: 6}}"));
Document logDoc;
@@ -196,10 +196,10 @@ namespace {
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a");
ASSERT_EQUALS(execInfo.fieldRef[1]->dottedField(), "c.r.d");
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(setMod.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(doc, fromjson("{b:1, c: { r: { d: 2}}}"));
Document logDoc;
@@ -218,10 +218,10 @@ namespace {
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a");
ASSERT_EQUALS(execInfo.fieldRef[1]->dottedField(), "b.c.d");
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(setMod.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(doc, fromjson("{b: {c: {d: 2}}}"));
Document logDoc;
@@ -240,10 +240,10 @@ namespace {
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a");
ASSERT_EQUALS(execInfo.fieldRef[1]->dottedField(), "b.c.d");
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(setMod.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(doc, fromjson("{b: {c: {d: [ {a:2, b:1} ]}}}"));
Document logDoc;
diff --git a/src/mongo/db/ops/modifier_set.cpp b/src/mongo/db/ops/modifier_set.cpp
index 1a566d7b1c9..842cffd87c2 100644
--- a/src/mongo/db/ops/modifier_set.cpp
+++ b/src/mongo/db/ops/modifier_set.cpp
@@ -32,7 +32,6 @@ namespace mongo {
, idxFound(0)
, elemFound(doc.end())
, boundDollar("")
- , inPlace(false)
, noOp(false) {
}
@@ -48,9 +47,6 @@ namespace mongo {
// Value to bind to a $-positional field, if one is provided.
std::string boundDollar;
- // Could this mod be applied in place?
- bool inPlace;
-
// This $set is a no-op?
bool noOp;
@@ -167,14 +163,6 @@ namespace mongo {
return Status::OK();
}
- // We may allow this $set to be in place if the value being set and the existing one
- // have the same size.
- if (_val.isNumber() &&
- (_preparedState->elemFound != root.getDocument().end()) &&
- (_val.type() == _preparedState->elemFound.getType())) {
- execInfo->inPlace = _preparedState->inPlace = true;
- }
-
// If the value being $set is the same as the one already in the doc, than this is a
// noOp.
if (_preparedState->elemFound.ok() &&
@@ -196,8 +184,6 @@ namespace mongo {
return _preparedState->elemFound.setValueBSONElement(_val);
}
- dassert(!_preparedState->inPlace);
-
//
// Complete document path logic
//
diff --git a/src/mongo/db/ops/modifier_set_test.cpp b/src/mongo/db/ops/modifier_set_test.cpp
index daa2f1ae852..05351d7db9e 100644
--- a/src/mongo/db/ops/modifier_set_test.cpp
+++ b/src/mongo/db/ops/modifier_set_test.cpp
@@ -105,7 +105,6 @@ namespace {
ASSERT_OK(setMod.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a");
- ASSERT_TRUE(execInfo.inPlace);
ASSERT_TRUE(execInfo.noOp);
}
@@ -117,7 +116,6 @@ namespace {
ASSERT_OK(setMod.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a");
- ASSERT_TRUE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_EQUALS(execInfo.context, ModifierInterface::ExecInfo::INSERT_CONTEXT);
}
@@ -130,10 +128,10 @@ namespace {
ASSERT_OK(setMod.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a");
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(setMod.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson("{a: 2}"), doc);
}
@@ -145,10 +143,10 @@ namespace {
ASSERT_OK(setMod.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a");
- ASSERT_TRUE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(setMod.apply());
+ ASSERT_TRUE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson("{a: 2}"), doc);
}
@@ -160,10 +158,10 @@ namespace {
ASSERT_OK(setMod.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a");
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(setMod.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson("{a: 2}"), doc);
}
@@ -175,10 +173,10 @@ namespace {
ASSERT_OK(setMod.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a");
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(setMod.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson("{a: 2}"), doc);
}
@@ -190,10 +188,10 @@ namespace {
ASSERT_OK(setMod.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a");
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(setMod.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson("{b: 1, a: 2}"), doc);
}
@@ -224,7 +222,6 @@ namespace {
ASSERT_OK(setMod.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a.b");
- ASSERT_TRUE(execInfo.inPlace);
ASSERT_TRUE(execInfo.noOp);
}
@@ -252,10 +249,10 @@ namespace {
ASSERT_OK(setMod.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a.b");
- ASSERT_TRUE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(setMod.apply());
+ ASSERT_TRUE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson("{a: {b: 2}}"), doc);
}
@@ -267,10 +264,10 @@ namespace {
ASSERT_OK(setMod.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a.b");
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(setMod.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson("{a: {b: 2}}"), doc);
}
@@ -282,10 +279,10 @@ namespace {
ASSERT_OK(setMod.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a.b");
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(setMod.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson("{a: {b: 2}}"), doc);
}
@@ -297,10 +294,10 @@ namespace {
ASSERT_OK(setMod.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a.b");
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(setMod.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson("{a: {c: 1, b: 2}}"), doc);
}
@@ -312,10 +309,10 @@ namespace {
ASSERT_OK(setMod.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a.b");
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(setMod.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson("{c: 1, a: {b: 2}}"), doc);
}
@@ -327,10 +324,10 @@ namespace {
ASSERT_OK(setMod.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a.b");
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(setMod.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson("{a: {b: 2}}"), doc);
}
@@ -342,10 +339,10 @@ namespace {
ASSERT_OK(setMod.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a.b");
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(setMod.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson("{'a.b':4, a: {b: 2}}"), doc);
}
@@ -361,7 +358,6 @@ namespace {
ASSERT_OK(setMod.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a.2.b");
- ASSERT_TRUE(execInfo.inPlace);
ASSERT_TRUE(execInfo.noOp);
}
@@ -381,10 +377,10 @@ namespace {
ASSERT_OK(setMod.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a.2.b");
- ASSERT_TRUE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(setMod.apply());
+ ASSERT_TRUE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson("{a: [{b: 0},{b: 1},{b: 2}]}"), doc);
}
@@ -396,10 +392,10 @@ namespace {
ASSERT_OK(setMod.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a.2.b");
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(setMod.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson("{a: [{b: 0},{b: 1},{b: 2}]}"), doc);
}
@@ -411,10 +407,10 @@ namespace {
ASSERT_OK(setMod.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a.2.b");
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(setMod.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson("{a: [{b: 0},null,{b: 2}]}"), doc);
}
@@ -426,10 +422,10 @@ namespace {
ASSERT_OK(setMod.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a.2.b");
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(setMod.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson("{a: {b: 0, '2': {b: 2}}}"), doc);
}
@@ -441,10 +437,10 @@ namespace {
ASSERT_OK(setMod.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a.2.b");
- ASSERT_TRUE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(setMod.apply());
+ ASSERT_TRUE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson("{a: {'2': {b: 2}}}"), doc);
}
@@ -456,10 +452,10 @@ namespace {
ASSERT_OK(setMod.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a.2.b");
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(setMod.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson("{a: {'2': {c: 1, b: 2}}}"), doc);
}
@@ -471,10 +467,10 @@ namespace {
ASSERT_OK(setMod.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a.2.b");
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(setMod.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson("{a: {'2': {b: 2}}}"), doc);
}
@@ -486,10 +482,10 @@ namespace {
ASSERT_OK(setMod.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a.2.b");
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(setMod.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson("{a: [null, null, {b: 2}]}"), doc);
}
@@ -501,10 +497,10 @@ namespace {
ASSERT_OK(setMod.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a.2.b");
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(setMod.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson("{a: {'2': {b: 2}}}"), doc);
}
@@ -565,7 +561,6 @@ namespace {
ASSERT_OK(setMod.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a.1.b");
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_TRUE(execInfo.noOp);
}
@@ -577,7 +572,6 @@ namespace {
ASSERT_OK(setMod.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a.1.b");
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
}
diff --git a/src/mongo/db/ops/modifier_unset.cpp b/src/mongo/db/ops/modifier_unset.cpp
index 1a2fecec4d5..23feeaa60b6 100644
--- a/src/mongo/db/ops/modifier_unset.cpp
+++ b/src/mongo/db/ops/modifier_unset.cpp
@@ -31,7 +31,6 @@ namespace mongo {
, idxFound(0)
, elemFound(doc.end())
, boundDollar("")
- , inPlace(false)
, noOp(false) {
}
@@ -47,9 +46,6 @@ namespace mongo {
// Value to bind to a $-positional field, if one is provided.
std::string boundDollar;
- // Could this mod be applied in place?
- bool inPlace;
-
// This $set is a no-op?
bool noOp;
@@ -120,7 +116,6 @@ namespace mongo {
if (!status.isOK() ||
_preparedState->idxFound != (_fieldRef.numParts() -1)) {
execInfo->noOp = _preparedState->noOp = true;
- execInfo->inPlace = _preparedState->noOp = true;
execInfo->fieldRef[0] = &_fieldRef;
return Status::OK();
@@ -137,11 +132,9 @@ namespace mongo {
// field boundaries must change.
//
// TODO:
- // execInfo->inPlace = true;
// mutablebson::Element curr = _preparedState->elemFound;
// while (curr.ok()) {
// if (curr.rightSibling().ok()) {
- // execInfo->inPlace = false;
// }
// curr = curr.parent();
// }
diff --git a/src/mongo/db/ops/modifier_unset_test.cpp b/src/mongo/db/ops/modifier_unset_test.cpp
index f2a1416a111..20e522c21ee 100644
--- a/src/mongo/db/ops/modifier_unset_test.cpp
+++ b/src/mongo/db/ops/modifier_unset_test.cpp
@@ -86,7 +86,6 @@ namespace {
ASSERT_OK(modUnset.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a");
- ASSERT_TRUE(execInfo.inPlace);
ASSERT_TRUE(execInfo.noOp);
}
@@ -98,10 +97,10 @@ namespace {
ASSERT_OK(modUnset.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a");
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(modUnset.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson("{b: 2}"), doc);
}
@@ -113,10 +112,10 @@ namespace {
ASSERT_OK(modUnset.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a");
- ASSERT_FALSE(execInfo.inPlace); // TODO turn in-place on for this.
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(modUnset.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled()); // TODO turn in-place on for this.
ASSERT_EQUALS(fromjson("{x: 0}"), doc);
}
@@ -128,10 +127,10 @@ namespace {
ASSERT_OK(modUnset.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a");
- ASSERT_FALSE(execInfo.inPlace); // TODO turn in-place on for this.
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(modUnset.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled()); // TODO turn in-place on for this.
ASSERT_EQUALS(fromjson("{}"), doc);
}
@@ -143,10 +142,10 @@ namespace {
ASSERT_OK(modUnset.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a");
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(modUnset.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson("{c: 2}"), doc);
}
@@ -159,7 +158,6 @@ namespace {
ASSERT_OK(modUnset.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a");
- ASSERT_FALSE(execInfo.inPlace); // TODO turn in-place on for this.
ASSERT_FALSE(execInfo.noOp);
Document logDoc;
@@ -180,7 +178,6 @@ namespace {
ASSERT_OK(modUnset.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a.b");
- ASSERT_TRUE(execInfo.inPlace);
ASSERT_TRUE(execInfo.noOp);
}
@@ -192,10 +189,10 @@ namespace {
ASSERT_OK(modUnset.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a.b");
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(modUnset.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson("{a:{}, c:2}"), doc);
}
@@ -207,10 +204,10 @@ namespace {
ASSERT_OK(modUnset.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a.b");
- ASSERT_FALSE(execInfo.inPlace); // TODO turn in-place on for this.
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(modUnset.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled()); // TODO turn in-place on for this.
ASSERT_EQUALS(fromjson("{x: 0, a:{}}"), doc);
}
@@ -222,10 +219,10 @@ namespace {
ASSERT_OK(modUnset.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a.b");
- ASSERT_FALSE(execInfo.inPlace); // TODO turn in-place on for this.
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(modUnset.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled()); // TODO turn in-place on for this.
ASSERT_EQUALS(fromjson("{a: {}}"), doc);
}
@@ -241,7 +238,6 @@ namespace {
ASSERT_OK(modUnset.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a.0");
- ASSERT_TRUE(execInfo.inPlace);
ASSERT_TRUE(execInfo.noOp);
}
@@ -253,10 +249,10 @@ namespace {
ASSERT_OK(modUnset.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a.0");
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(modUnset.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson("{a:[null,1,2]}"), doc);
}
@@ -268,10 +264,10 @@ namespace {
ASSERT_OK(modUnset.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a.0");
- ASSERT_FALSE(execInfo.inPlace); // TODO turn in-place on for this.
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(modUnset.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled()); // TODO turn in-place on for this.
ASSERT_EQUALS(fromjson("{b:1, a:[null]}"), doc);
}
@@ -284,10 +280,10 @@ namespace {
ASSERT_OK(modUnset.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a.0");
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(modUnset.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson("{a:[null], b:1}"), doc);
}
@@ -299,10 +295,10 @@ namespace {
ASSERT_OK(modUnset.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a.0.b");
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(modUnset.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson("{a:[{}]}"), doc);
}
@@ -314,10 +310,10 @@ namespace {
ASSERT_OK(modUnset.prepare(doc.root(), "", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a.0");
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(modUnset.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson("{a:[null]}"), doc);
}
@@ -346,7 +342,6 @@ namespace {
ASSERT_OK(modUnset.prepare(doc.root(), "1", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a.1.b");
- ASSERT_TRUE(execInfo.inPlace);
ASSERT_TRUE(execInfo.noOp);
}
@@ -366,10 +361,10 @@ namespace {
ASSERT_OK(modUnset.prepare(doc.root(), "0", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a.0.b");
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(modUnset.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson("{a: [{}, {c:1}]}"), doc);
}
@@ -381,10 +376,10 @@ namespace {
ASSERT_OK(modUnset.prepare(doc.root(), "0", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a.0");
- ASSERT_FALSE(execInfo.inPlace);
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(modUnset.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled());
ASSERT_EQUALS(fromjson("{a: [null, {c:1}]}"), doc);
}
@@ -396,10 +391,10 @@ namespace {
ASSERT_OK(modUnset.prepare(doc.root(), "0", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a.0.b");
- ASSERT_FALSE(execInfo.inPlace); // TODO turn in-place on for this.
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(modUnset.apply());
+ ASSERT_FALSE(doc.isInPlaceModeEnabled()); // TODO turn in-place on for this.
ASSERT_EQUALS(fromjson("{b:1, a:[{}]}"), doc);
}
@@ -411,7 +406,6 @@ namespace {
ASSERT_OK(modUnset.prepare(doc.root(), "0", &execInfo));
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a.0.b");
- ASSERT_FALSE(execInfo.inPlace); // TODO turn in-place on for this.
ASSERT_FALSE(execInfo.noOp);
Document logDoc;