diff options
author | Tor Brede Vekterli <vekterli@yahooinc.com> | 2022-12-09 16:30:17 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-09 16:30:17 +0100 |
commit | 52288cca283f675435a74e1273a3eca165c2127d (patch) | |
tree | 22249606f79974c03153be829527ab43354ad0ca | |
parent | dfd30fb55d133a49d1528f67eb60e5a4a3184c2c (diff) | |
parent | 438129e8b3bf490226e19b6d9c09261024c126fd (diff) |
Merge pull request #25199 from vespa-engine/vekterli/propagate-update-internal-doc-repo-to-auto-created-doc
Propagate doc repo in update to auto-created blank document instance [run-systemtest]
3 files changed, 12 insertions, 4 deletions
diff --git a/document/src/vespa/document/update/documentupdate.cpp b/document/src/vespa/document/update/documentupdate.cpp index 7a3eb85d3d5..6ab01a4d3ff 100644 --- a/document/src/vespa/document/update/documentupdate.cpp +++ b/document/src/vespa/document/update/documentupdate.cpp @@ -87,7 +87,7 @@ DocumentUpdate::operator==(const DocumentUpdate& other) const } const DocumentType& -DocumentUpdate::getType() const { +DocumentUpdate::getType() const noexcept { return static_cast<const DocumentType &> (*_type); } @@ -261,6 +261,7 @@ DocumentUpdate::initHEAD(const DocumentTypeRepo & repo, vespalib::nbostream && s void DocumentUpdate::initHEAD(const DocumentTypeRepo & repo, vespalib::nbostream & stream) { + _repo = &repo; size_t startPos = stream.rp(); vespalib::stringref docId; _type = deserializeHeader(repo, stream, docId); diff --git a/document/src/vespa/document/update/documentupdate.h b/document/src/vespa/document/update/documentupdate.h index 192569ba6ee..d554e66bd1a 100644 --- a/document/src/vespa/document/update/documentupdate.h +++ b/document/src/vespa/document/update/documentupdate.h @@ -60,7 +60,7 @@ public: * The document type is not strictly needed, as we know this at applyTo() * time, but search does not use applyTo() code to do the update, and don't * know the document type of their objects, so this is supplied for - * convinience. It also makes it possible to check updates for sanity at + * convenience. It also makes it possible to check updates for sanity at * creation time. * * @param type The document type that this update is applicable for. @@ -99,7 +99,12 @@ public: void eagerDeserialize() const; /** @return The type of document this update is for. */ - const DocumentType& getType() const; + const DocumentType& getType() const noexcept; + + // Returns pointer to repo used for underlying update, or nullptr if default-constructed + const DocumentTypeRepo* getRepoPtr() const noexcept { + return _repo; + } void serializeHEAD(vespalib::nbostream &stream) const; diff --git a/storage/src/vespa/storage/distributor/operations/external/twophaseupdateoperation.cpp b/storage/src/vespa/storage/distributor/operations/external/twophaseupdateoperation.cpp index 7c04636dc50..59f52465b93 100644 --- a/storage/src/vespa/storage/distributor/operations/external/twophaseupdateoperation.cpp +++ b/storage/src/vespa/storage/distributor/operations/external/twophaseupdateoperation.cpp @@ -674,7 +674,9 @@ std::shared_ptr<document::Document> TwoPhaseUpdateOperation::createBlankDocument() const { const document::DocumentUpdate& up(*_updateCmd->getUpdate()); - return std::make_shared<document::Document>(up.getType(), up.getId()); + auto doc = std::make_shared<document::Document>(up.getType(), up.getId()); + doc->setRepo(*up.getRepoPtr()); + return doc; } void |