diff options
author | Henning Baldersheim <balder@oath.com> | 2018-05-30 23:08:27 +0200 |
---|---|---|
committer | Henning Baldersheim <balder@oath.com> | 2018-05-31 13:49:27 +0200 |
commit | f6cc918be775094726aa3c241ab4340e8363342f (patch) | |
tree | 5b3719b0dfa3780027540d0eeea657f4f7d7f10a | |
parent | 343ece39072d3132885922b132dc57dcbebe3881 (diff) |
Hide implementation details.
4 files changed, 22 insertions, 30 deletions
diff --git a/document/src/vespa/document/update/documentupdate.h b/document/src/vespa/document/update/documentupdate.h index a1c6e855bfd..c84834e1a75 100644 --- a/document/src/vespa/document/update/documentupdate.h +++ b/document/src/vespa/document/update/documentupdate.h @@ -48,15 +48,6 @@ public: typedef std::shared_ptr<DocumentUpdate> SP; typedef std::vector<FieldUpdate> FieldUpdateV; typedef std::vector<FieldPathUpdate::CP> FieldPathUpdateV; - /** - * Enum class containing the legal serialization version for - * document updates. This version is not encoded in the serialized - * document update. - */ - enum class SerializeVersion { - SERIALIZE_42, // old style format, before vespa 5.0 - SERIALIZE_HEAD // new style format, since vespa 5.0 - }; /** * Create old style document update, no support for field path updates. @@ -80,16 +71,6 @@ public: */ DocumentUpdate(const DataType &type, const DocumentId& id); - /** - * Create a document update from a byte buffer containing a serialized - * document update. - * - * @param repo Document type repo used to find proper document type - * @param buffer The buffer containing the serialized document update - * @param serializeVersion Selector between serialization formats. - */ - DocumentUpdate(const DocumentTypeRepo &repo, ByteBuffer &buffer, SerializeVersion serializeVersion); - DocumentUpdate(const DocumentUpdate &) = delete; DocumentUpdate & operator = (const DocumentUpdate &) = delete; ~DocumentUpdate() override; @@ -164,6 +145,24 @@ private: bool _createIfNonExistent; int deserializeFlags(int sizeAndFlags); + /** + * Enum class containing the legal serialization version for + * document updates. This version is not encoded in the serialized + * document update. + */ + enum class SerializeVersion { + SERIALIZE_42, // old style format, before vespa 5.0 + SERIALIZE_HEAD // new style format, since vespa 5.0 + }; + /** + * Create a document update from a byte buffer containing a serialized + * document update. + * + * @param repo Document type repo used to find proper document type + * @param buffer The buffer containing the serialized document update + * @param serializeVersion Selector between serialization formats. + */ + DocumentUpdate(const DocumentTypeRepo &repo, ByteBuffer &buffer, SerializeVersion serializeVersion); }; } // document diff --git a/documentapi/src/vespa/documentapi/messagebus/routablefactories50.cpp b/documentapi/src/vespa/documentapi/messagebus/routablefactories50.cpp index a73d6901f91..33784faf497 100644 --- a/documentapi/src/vespa/documentapi/messagebus/routablefactories50.cpp +++ b/documentapi/src/vespa/documentapi/messagebus/routablefactories50.cpp @@ -887,10 +887,7 @@ RoutableFactories50::StatDocumentReplyFactory::doEncode(const DocumentReply &obj void RoutableFactories50::UpdateDocumentMessageFactory::decodeInto(UpdateDocumentMessage & msg, document::ByteBuffer & buf) const { - msg.setDocumentUpdate(make_shared<document::DocumentUpdate> - (_repo, buf, - document::DocumentUpdate::SerializeVersion:: - SERIALIZE_HEAD)); + msg.setDocumentUpdate(document::DocumentUpdate::createHEAD(_repo, buf)); msg.setOldTimestamp(static_cast<uint64_t>(decodeLong(buf))); msg.setNewTimestamp(static_cast<uint64_t>(decodeLong(buf))); } diff --git a/searchcore/src/vespa/searchcore/proton/feedoperation/updateoperation.cpp b/searchcore/src/vespa/searchcore/proton/feedoperation/updateoperation.cpp index de5c54bafa0..f5b583f7e90 100644 --- a/searchcore/src/vespa/searchcore/proton/feedoperation/updateoperation.cpp +++ b/searchcore/src/vespa/searchcore/proton/feedoperation/updateoperation.cpp @@ -57,9 +57,7 @@ void UpdateOperation::deserializeUpdate(vespalib::nbostream &is, const document::DocumentTypeRepo &repo) { document::ByteBuffer buf(is.peek(), is.size()); - using Version = DocumentUpdate::SerializeVersion; - Version version = ((getType() == FeedOperation::UPDATE_42) ? Version::SERIALIZE_42 : Version::SERIALIZE_HEAD); - DocumentUpdate::SP update(std::make_shared<DocumentUpdate>(repo, buf, version)); + DocumentUpdate::UP update = (getType() == FeedOperation::UPDATE_42) ? DocumentUpdate::create42(repo, buf) : DocumentUpdate::createHEAD(repo, buf); is.adjustReadPos(buf.getPos()); _upd = std::move(update); } @@ -74,8 +72,7 @@ UpdateOperation::serialize(vespalib::nbostream &os) const void -UpdateOperation::deserialize(vespalib::nbostream &is, - const DocumentTypeRepo &repo) +UpdateOperation::deserialize(vespalib::nbostream &is, const DocumentTypeRepo &repo) { DocumentOperation::deserialize(is, repo); try { diff --git a/storageapi/src/vespa/storageapi/mbusprot/protocolserialization5_0.cpp b/storageapi/src/vespa/storageapi/mbusprot/protocolserialization5_0.cpp index 3ae121a7e03..a1be0def20b 100644 --- a/storageapi/src/vespa/storageapi/mbusprot/protocolserialization5_0.cpp +++ b/storageapi/src/vespa/storageapi/mbusprot/protocolserialization5_0.cpp @@ -229,8 +229,7 @@ ProtocolSerialization5_0::onDecodeUpdateCommand(BBuf& buf) const if (size != 0) { document::ByteBuffer bbuf(buf.getBufferAtPos(), size); buf.incPos(size); - update = std::make_shared<document::DocumentUpdate>(getTypeRepo(), bbuf, - document::DocumentUpdate::SerializeVersion::SERIALIZE_HEAD); + update = document::DocumentUpdate::createHEAD(getTypeRepo(), bbuf); } document::Bucket bucket = getBucket(buf); |