diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2022-03-27 14:05:51 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2022-03-27 14:05:51 +0000 |
commit | 3112b96dcd66e8aed0587d44288ca8e347cc31a2 (patch) | |
tree | d537c0d2135604a46feb767a7a7e1986f3813dfd /storage | |
parent | f1ca88107239ff1ba6bf0f7e142486352ffd90e4 (diff) |
Avoid need to copy/clone FieldUpdate
Diffstat (limited to 'storage')
4 files changed, 6 insertions, 14 deletions
diff --git a/storage/src/tests/distributor/externaloperationhandlertest.cpp b/storage/src/tests/distributor/externaloperationhandlertest.cpp index 27855091257..5aa5845ac4c 100644 --- a/storage/src/tests/distributor/externaloperationhandlertest.cpp +++ b/storage/src/tests/distributor/externaloperationhandlertest.cpp @@ -7,7 +7,6 @@ #include <vespa/document/update/assignvalueupdate.h> #include <vespa/document/update/documentupdate.h> #include <vespa/document/fieldvalue/stringfieldvalue.h> -#include <vespa/document/datatype/documenttype.h> #include <vespa/storage/common/reindexing_constants.h> #include <vespa/storage/distributor/top_level_distributor.h> #include <vespa/storage/distributor/distributor_bucket_space.h> @@ -597,7 +596,7 @@ TEST_F(ExternalOperationHandlerTest, non_trivial_updates_are_rejected_if_feed_is const auto* doc_type = _testDocMan.getTypeRepo().getDocumentType("testdoctype1"); document::FieldUpdate upd(doc_type->getField("title")); upd.addUpdate(document::AssignValueUpdate(document::StringFieldValue("new value"))); - cmd->getUpdate()->addUpdate(upd); + cmd->getUpdate()->addUpdate(std::move(upd)); ASSERT_NO_FATAL_FAILURE(start_operation_verify_rejected(std::move(cmd))); EXPECT_EQ("ReturnCode(NO_SPACE, External feed is blocked due to resource exhaustion: full disk)", diff --git a/storage/src/tests/distributor/twophaseupdateoperationtest.cpp b/storage/src/tests/distributor/twophaseupdateoperationtest.cpp index fae2a3d0982..7a7e53a1d2c 100644 --- a/storage/src/tests/distributor/twophaseupdateoperationtest.cpp +++ b/storage/src/tests/distributor/twophaseupdateoperationtest.cpp @@ -297,7 +297,7 @@ TwoPhaseUpdateOperationTest::sendUpdate(const std::string& bucketState, document::DocumentId("id:ns:" + _doc_type->getName() + "::1")); document::FieldUpdate fup(_doc_type->getField("headerval")); fup.addUpdate(ArithmeticValueUpdate(ArithmeticValueUpdate::Add, 10)); - update->addUpdate(fup); + update->addUpdate(std::move(fup)); } else { // Create an update to a different doctype than the one returned as // part of the Get. Just a sneaky way to force an eval error. @@ -307,7 +307,7 @@ TwoPhaseUpdateOperationTest::sendUpdate(const std::string& bucketState, document::DocumentId("id:ns:" + _doc_type->getName() + "::1")); document::FieldUpdate fup(badDocType->getField("onlyinchild")); fup.addUpdate(ArithmeticValueUpdate(ArithmeticValueUpdate::Add, 10)); - update->addUpdate(fup); + update->addUpdate(std::move(fup)); } update->setCreateIfNonExistent(options._createIfNonExistent); diff --git a/storage/src/tests/persistence/persistencetestutils.cpp b/storage/src/tests/persistence/persistencetestutils.cpp index 6974319dc72..0adeff5bc34 100644 --- a/storage/src/tests/persistence/persistencetestutils.cpp +++ b/storage/src/tests/persistence/persistencetestutils.cpp @@ -226,9 +226,7 @@ PersistenceTestUtils::createBodyUpdate(const document::DocumentId& docId, const const DocumentType* docType(getTypeRepo()->getDocumentType("testdoctype1")); auto update = std::make_shared<document::DocumentUpdate>(*getTypeRepo(), *docType, docId); auto assignUpdate = std::make_shared<document::AssignValueUpdate>(updateValue); - document::FieldUpdate fieldUpdate(docType->getField("content")); - fieldUpdate.addUpdate(*assignUpdate); - update->addUpdate(fieldUpdate); + update->addUpdate(std::move(document::FieldUpdate(docType->getField("content")).addUpdate(*assignUpdate))); return update; } @@ -238,9 +236,7 @@ PersistenceTestUtils::createHeaderUpdate(const document::DocumentId& docId, cons const DocumentType* docType(getTypeRepo()->getDocumentType("testdoctype1")); auto update = std::make_shared<document::DocumentUpdate>(*getTypeRepo(), *docType, docId); auto assignUpdate = std::make_shared<document::AssignValueUpdate>(updateValue); - document::FieldUpdate fieldUpdate(docType->getField("headerval")); - fieldUpdate.addUpdate(*assignUpdate); - update->addUpdate(fieldUpdate); + update->addUpdate(std::move(document::FieldUpdate(docType->getField("headerval")).addUpdate(*assignUpdate))); return update; } diff --git a/storage/src/tests/persistence/testandsettest.cpp b/storage/src/tests/persistence/testandsettest.cpp index 816fd7871d3..267569b0bc5 100644 --- a/storage/src/tests/persistence/testandsettest.cpp +++ b/storage/src/tests/persistence/testandsettest.cpp @@ -7,7 +7,6 @@ #include <vespa/document/fieldvalue/fieldvalues.h> #include <vespa/document/update/documentupdate.h> #include <vespa/document/update/assignvalueupdate.h> -#include <vespa/document/datatype/documenttype.h> #include <vespa/document/fieldset/fieldsets.h> #include <vespa/persistence/spi/test.h> #include <vespa/persistence/spi/persistenceprovider.h> @@ -160,9 +159,7 @@ std::shared_ptr<api::UpdateCommand> TestAndSetTest::conditional_update_test(bool createIfMissing, api::Timestamp updateTimestamp) { auto docUpdate = std::make_shared<document::DocumentUpdate>(_env->_testDocMan.getTypeRepo(), testDoc->getType(), testDocId); - auto fieldUpdate = document::FieldUpdate(testDoc->getField("content")); - fieldUpdate.addUpdate(document::AssignValueUpdate(NEW_CONTENT)); - docUpdate->addUpdate(fieldUpdate); + docUpdate->addUpdate(std::move(document::FieldUpdate(testDoc->getField("content")).addUpdate(document::AssignValueUpdate(NEW_CONTENT)))); docUpdate->setCreateIfNonExistent(createIfMissing); auto updateUp = std::make_unique<api::UpdateCommand>(BUCKET, docUpdate, updateTimestamp); |