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 /searchcore | |
parent | f1ca88107239ff1ba6bf0f7e142486352ffd90e4 (diff) |
Avoid need to copy/clone FieldUpdate
Diffstat (limited to 'searchcore')
5 files changed, 35 insertions, 41 deletions
diff --git a/searchcore/src/tests/proton/attribute/attribute_test.cpp b/searchcore/src/tests/proton/attribute/attribute_test.cpp index fdf75bbd726..a95d3f7ccca 100644 --- a/searchcore/src/tests/proton/attribute/attribute_test.cpp +++ b/searchcore/src/tests/proton/attribute/attribute_test.cpp @@ -482,10 +482,10 @@ TEST_F(AttributeWriterTest, handles_update) DocBuilder idb(schema); const document::DocumentType &dt(idb.getDocumentType()); DocumentUpdate upd(*idb.getDocumentTypeRepo(), dt, DocumentId("id:ns:searchdocument::1")); - upd.addUpdate(FieldUpdate(upd.getType().getField("a1")) - .addUpdate(ArithmeticValueUpdate(ArithmeticValueUpdate::Add, 5))); - upd.addUpdate(FieldUpdate(upd.getType().getField("a2")) - .addUpdate(ArithmeticValueUpdate(ArithmeticValueUpdate::Add, 10))); + upd.addUpdate(std::move(FieldUpdate(upd.getType().getField("a1")) + .addUpdate(ArithmeticValueUpdate(ArithmeticValueUpdate::Add, 5)))); + upd.addUpdate(std::move(FieldUpdate(upd.getType().getField("a2")) + .addUpdate(ArithmeticValueUpdate(ArithmeticValueUpdate::Add, 10)))); DummyFieldUpdateCallback onUpdate; update(2, upd, 1, onUpdate); @@ -527,8 +527,8 @@ TEST_F(AttributeWriterTest, handles_predicate_update) const document::DocumentType &dt(idb.getDocumentType()); DocumentUpdate upd(*idb.getDocumentTypeRepo(), dt, DocumentId("id:ns:searchdocument::1")); PredicateFieldValue new_value(builder.feature("foo").value("bar").build()); - upd.addUpdate(FieldUpdate(upd.getType().getField("a1")) - .addUpdate(AssignValueUpdate(new_value))); + upd.addUpdate(std::move(FieldUpdate(upd.getType().getField("a1")) + .addUpdate(AssignValueUpdate(new_value)))); PredicateIndex &index = static_cast<PredicateAttribute &>(*a1).getIndex(); EXPECT_EQ(1u, index.getZeroConstraintDocs().size()); @@ -728,8 +728,8 @@ TEST_F(AttributeWriterTest, handles_tensor_assign_update) TensorDataType xySparseTensorDataType(vespalib::eval::ValueType::from_spec(sparse_tensor)); TensorFieldValue new_value(xySparseTensorDataType); new_value = SimpleValue::from_value(*new_tensor); - upd.addUpdate(FieldUpdate(upd.getType().getField("a1")) - .addUpdate(AssignValueUpdate(new_value))); + upd.addUpdate(std::move(FieldUpdate(upd.getType().getField("a1")) + .addUpdate(AssignValueUpdate(new_value)))); DummyFieldUpdateCallback onUpdate; update(2, upd, 1, onUpdate); EXPECT_EQ(2u, a1->getNumDocs()); @@ -938,7 +938,7 @@ public: TensorDataType tensor_type(vespalib::eval::ValueType::from_spec(dense_tensor)); TensorFieldValue tensor_value(tensor_type); tensor_value= SimpleValue::from_value(*tensor); - upd->addUpdate(FieldUpdate(upd->getType().getField("a1")).addUpdate(AssignValueUpdate(tensor_value))); + upd->addUpdate(std::move(FieldUpdate(upd->getType().getField("a1")).addUpdate(AssignValueUpdate(tensor_value)))); return upd; } void expect_shared_executor_tasks(size_t exp_accepted_tasks) { diff --git a/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp b/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp index 4040d69270f..c3275d51a1e 100644 --- a/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp +++ b/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp @@ -346,9 +346,7 @@ struct UpdateContext { fieldValue->assign(document::StringFieldValue("new value")); } document::AssignValueUpdate assignValueUpdate(*fieldValue); - document::FieldUpdate fieldUpdate(field); - fieldUpdate.addUpdate(assignValueUpdate); - update->addUpdate(fieldUpdate); + update->addUpdate(std::move(document::FieldUpdate(field).addUpdate(assignValueUpdate))); } }; @@ -773,11 +771,11 @@ TEST_F("require that update with a fieldpath update will be rejected", SchemaCon TEST_F("require that all value updates will be inspected before rejected", SchemaContext) { const DocumentType *docType = f.getRepo()->getDocumentType(f.getDocType().getName()); auto docUpdate = std::make_unique<DocumentUpdate>(*f.getRepo(), *docType, DocumentId("id:ns:" + docType->getName() + "::1")); - docUpdate->addUpdate(FieldUpdate(docType->getField("i1")).addUpdate(ClearValueUpdate())); + docUpdate->addUpdate(std::move(FieldUpdate(docType->getField("i1")).addUpdate(ClearValueUpdate()))); EXPECT_FALSE(FeedRejectHelper::mustReject(*docUpdate)); - docUpdate->addUpdate(FieldUpdate(docType->getField("i1")).addUpdate(ClearValueUpdate())); + docUpdate->addUpdate(std::move(FieldUpdate(docType->getField("i1")).addUpdate(ClearValueUpdate()))); EXPECT_FALSE(FeedRejectHelper::mustReject(*docUpdate)); - docUpdate->addUpdate(FieldUpdate(docType->getField("i1")).addUpdate(AssignValueUpdate(StringFieldValue()))); + docUpdate->addUpdate(std::move(FieldUpdate(docType->getField("i1")).addUpdate(AssignValueUpdate(StringFieldValue())))); EXPECT_TRUE(FeedRejectHelper::mustReject(*docUpdate)); } diff --git a/searchcore/src/tests/proton/feedoperation/feedoperation_test.cpp b/searchcore/src/tests/proton/feedoperation/feedoperation_test.cpp index d79b46b2e08..2490fac783a 100644 --- a/searchcore/src/tests/proton/feedoperation/feedoperation_test.cpp +++ b/searchcore/src/tests/proton/feedoperation/feedoperation_test.cpp @@ -16,7 +16,6 @@ #include <vespa/searchlib/query/base.h> #include <persistence/spi/types.h> #include <vespa/document/base/documentid.h> -#include <vespa/document/config/documenttypes_config_fwd.h> #include <vespa/document/datatype/datatype.h> #include <vespa/document/fieldvalue/document.h> #include <vespa/document/update/documentupdate.h> @@ -122,8 +121,8 @@ public: auto makeUpdate() { auto upd(std::make_shared<DocumentUpdate>(*_repo, _docType, docId)); - upd->addUpdate(FieldUpdate(upd->getType().getField("string")). - addUpdate(AssignValueUpdate(StringFieldValue("newval")))); + upd->addUpdate(std::move(FieldUpdate(upd->getType().getField("string")). + addUpdate(AssignValueUpdate(StringFieldValue("newval"))))); return upd; } auto makeDoc() { diff --git a/searchcore/src/tests/proton/persistenceengine/persistenceengine_test.cpp b/searchcore/src/tests/proton/persistenceengine/persistenceengine_test.cpp index 95593307ba2..2c72b37bc8d 100644 --- a/searchcore/src/tests/proton/persistenceengine/persistenceengine_test.cpp +++ b/searchcore/src/tests/proton/persistenceengine/persistenceengine_test.cpp @@ -25,6 +25,8 @@ using document::BucketSpace; using document::Document; using document::DocumentId; using document::DocumentType; +using document::DocumentTypeRepo; +using document::DocumentUpdate; using document::test::makeBucketSpace; using search::DocumentMetaData; using storage::spi::Bucket; @@ -56,19 +58,19 @@ createDocType(const vespalib::string &name, int32_t id) } -document::Document::SP +Document::SP createDoc(const DocumentType &docType, const DocumentId &docId) { - return std::make_shared<document::Document>(docType, docId); + return std::make_shared<Document>(docType, docId); } -document::DocumentUpdate::SP +DocumentUpdate::SP createUpd(const DocumentType& docType, const DocumentId &docId) { - static std::vector<std::unique_ptr<document::DocumentTypeRepo>> repoList; - repoList.emplace_back(std::make_unique<document::DocumentTypeRepo>(docType)); - return std::make_shared<document::DocumentUpdate>(*repoList.back(), docType, docId); + static std::vector<std::unique_ptr<DocumentTypeRepo>> repoList; + repoList.emplace_back(std::make_unique<DocumentTypeRepo>(docType)); + return std::make_shared<DocumentUpdate>(*repoList.back(), docType, docId); } storage::spi::ClusterState @@ -105,14 +107,14 @@ createClusterState(const storage::lib::State& nodeState = storage::lib::State::U struct MyDocumentRetriever : DocumentRetrieverBaseForTest { - document::DocumentTypeRepo repo; + DocumentTypeRepo repo; const Document *document; Timestamp timestamp; DocumentId &last_doc_id; MyDocumentRetriever(const Document *d, Timestamp ts, DocumentId &last_id) : repo(), document(d), timestamp(ts), last_doc_id(last_id) {} - const document::DocumentTypeRepo &getDocumentTypeRepo() const override { + const DocumentTypeRepo &getDocumentTypeRepo() const override { return repo; } void getBucketMetaData(const storage::spi::Bucket &, search::DocumentMetaData::Vector &v) const override { @@ -123,11 +125,11 @@ struct MyDocumentRetriever : DocumentRetrieverBaseForTest { DocumentMetaData getDocumentMetaData(const DocumentId &id) const override { last_doc_id = id; if (document != nullptr) { - return DocumentMetaData(1, timestamp, document::BucketId(1), document->getId().getGlobalId()); + return DocumentMetaData(1, timestamp, BucketId(1), document->getId().getGlobalId()); } return DocumentMetaData(); } - document::Document::UP getFullDocument(search::DocumentIdT) const override { + Document::UP getFullDocument(search::DocumentIdT) const override { if (document != nullptr) { return Document::UP(document->clone()); } @@ -271,7 +273,7 @@ struct MyHandler : public IPersistenceHandler, IBucketFreezer { resultHandler.handle(BucketIdListResult()); } - void handlePopulateActiveBuckets(document::BucketId::List buckets, IGenericResultHandler &resultHandler) override { + void handlePopulateActiveBuckets(BucketId::List buckets, IGenericResultHandler &resultHandler) override { (void) buckets; resultHandler.handle(Result()); } @@ -317,10 +319,10 @@ DocumentId docId3("id:type3:type3::1"); Document::SP doc1(createDoc(type1, docId1)); Document::SP doc2(createDoc(type2, docId2)); Document::SP doc3(createDoc(type3, docId3)); -document::DocumentUpdate::SP upd1(createUpd(type1, docId1)); -document::DocumentUpdate::SP upd2(createUpd(type2, docId2)); -document::DocumentUpdate::SP upd3(createUpd(type3, docId3)); -document::DocumentUpdate::SP bad_id_upd(createUpd(type1, docId2)); +DocumentUpdate::SP upd1(createUpd(type1, docId1)); +DocumentUpdate::SP upd2(createUpd(type2, docId2)); +DocumentUpdate::SP upd3(createUpd(type3, docId3)); +DocumentUpdate::SP bad_id_upd(createUpd(type1, docId2)); BucketId bckId1(1); BucketId bckId2(2); BucketId bckId3(3); @@ -518,10 +520,8 @@ TEST_F("require that update is rejected if resource limit is reached", SimpleFix DocumentType type(createDocType("type_with_one_string", 1)); document::Field field("string", 1, *document::DataType::STRING); type.addField(field); - document::DocumentUpdate::SP upd = createUpd(type, docId1); - document::FieldUpdate fUpd(field); - fUpd.addUpdate(document::AssignValueUpdate(document::StringFieldValue("new value"))); - upd->addUpdate(fUpd); + DocumentUpdate::SP upd = createUpd(type, docId1); + upd->addUpdate(std::move(document::FieldUpdate(field).addUpdate(document::AssignValueUpdate(document::StringFieldValue("new value"))))); EXPECT_EQUAL( Result(Result::ErrorType::RESOURCE_EXHAUSTED, diff --git a/searchcore/src/vespa/searchcore/bmcluster/bm_feed.cpp b/searchcore/src/vespa/searchcore/bmcluster/bm_feed.cpp index 56cea8db741..ae1b9ec7fe3 100644 --- a/searchcore/src/vespa/searchcore/bmcluster/bm_feed.cpp +++ b/searchcore/src/vespa/searchcore/bmcluster/bm_feed.cpp @@ -1,17 +1,14 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "bm_feed.h" -#include "avg_sampler.h" #include "bm_feed_operation.h" #include "bm_feed_params.h" #include "bm_range.h" #include "bucket_selector.h" -#include "pending_tracker.h" #include "i_bm_feed_handler.h" #include <vespa/document/base/documentid.h> #include <vespa/document/bucket/bucketid.h> #include <vespa/document/datatype/documenttype.h> -#include <vespa/document/fieldset/fieldsets.h> #include <vespa/document/fieldvalue/document.h> #include <vespa/document/fieldvalue/intfieldvalue.h> #include <vespa/document/repo/documenttyperepo.h> @@ -74,7 +71,7 @@ BmFeed::make_document_update(uint32_t n, uint32_t i) const { auto id = make_document_id(n, i); auto document_update = std::make_unique<DocumentUpdate>(*_repo, *_document_type, id); - document_update->addUpdate(FieldUpdate(_field).addUpdate(AssignValueUpdate(IntFieldValue(15)))); + document_update->addUpdate(std::move(FieldUpdate(_field).addUpdate(AssignValueUpdate(IntFieldValue(15))))); return document_update; } |