diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2020-01-15 10:57:38 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2020-01-16 15:41:23 +0000 |
commit | 6abc05684fc3fe46da2b159b8944fae9adb086a4 (patch) | |
tree | 3d9d59fc6bad7c86ce8ee989f7cb315c59c32ff5 /document | |
parent | 878b95a5c82a299b5f5b453409c3837b48f7d206 (diff) |
GC unused constructors.
Diffstat (limited to 'document')
6 files changed, 22 insertions, 58 deletions
diff --git a/document/src/tests/documenttestcase.cpp b/document/src/tests/documenttestcase.cpp index d75a16ea1a6..60f2a1ae861 100644 --- a/document/src/tests/documenttestcase.cpp +++ b/document/src/tests/documenttestcase.cpp @@ -931,7 +931,7 @@ TEST(DocumentTest, testGetURIFromSerialized) std::unique_ptr<ByteBuffer> serialized = doc.serialize(); serialized->flip(); - Document doc2(test_repo.getTypeRepo(), *serialized, false, NULL); + Document doc2(test_repo.getTypeRepo(), *serialized); EXPECT_EQ(vespalib::string("id:ns:testdoctype1::1"), doc2.getId().toString()); EXPECT_EQ(vespalib::string("testdoctype1"), doc2.getType().getName()); } @@ -1054,7 +1054,8 @@ TEST(DocumentTest, testSplitSerialization) EXPECT_TRUE(!headerDoc.hasValue("content")); buf.setPos(0); - Document fullDoc(testDocMan.getTypeRepo(), buf, buf2); + Document fullDoc; + fullDoc.deserialize(testDocMan.getTypeRepo(), buf, buf2); EXPECT_TRUE(fullDoc.hasValue("headerval")); EXPECT_TRUE(fullDoc.hasValue("content")); diff --git a/document/src/tests/serialization/vespadocumentserializer_test.cpp b/document/src/tests/serialization/vespadocumentserializer_test.cpp index 7feea4e51d2..f680b3e6cff 100644 --- a/document/src/tests/serialization/vespadocumentserializer_test.cpp +++ b/document/src/tests/serialization/vespadocumentserializer_test.cpp @@ -912,7 +912,7 @@ void DeserializedTensorDoc::setup(const DocumentTypeRepo &docTypeRepo, const vespalib::nbostream &blob) { vespalib::nbostream wrapStream(blob.peek(), blob.size()); - _doc = std::make_unique<Document>(docTypeRepo, wrapStream, nullptr); + _doc = std::make_unique<Document>(docTypeRepo, wrapStream); _fieldValue = _doc->getValue(tensor_field_name); } diff --git a/document/src/vespa/document/fieldvalue/document.cpp b/document/src/vespa/document/fieldvalue/document.cpp index 29414c901f8..5b7314f0323 100644 --- a/document/src/vespa/document/fieldvalue/document.cpp +++ b/document/src/vespa/document/fieldvalue/document.cpp @@ -93,8 +93,8 @@ Document::Document(const DataType &type, DocumentId documentId) } } -Document::Document(const DocumentTypeRepo& repo, ByteBuffer& buffer, const DataType *anticipatedType) - : StructuredFieldValue(anticipatedType ? verifyDocumentType(anticipatedType) : *DataType::DOCUMENT), +Document::Document(const DocumentTypeRepo& repo, ByteBuffer& buffer) + : StructuredFieldValue(*DataType::DOCUMENT), _id(), _fields(static_cast<const DocumentType &>(getType()).getFieldsType()), _lastModified(0) @@ -107,8 +107,8 @@ void Document::setRepo(const DocumentTypeRepo& repo) _fields.setRepo(repo); } -Document::Document(const DocumentTypeRepo& repo, vespalib::nbostream & is, const DataType *anticipatedType) - : StructuredFieldValue(anticipatedType ? verifyDocumentType(anticipatedType) : *DataType::DOCUMENT), +Document::Document(const DocumentTypeRepo& repo, vespalib::nbostream & is) + : StructuredFieldValue(*DataType::DOCUMENT), _id(), _fields(static_cast<const DocumentType &>(getType()).getFieldsType()), _lastModified(0) @@ -116,33 +116,6 @@ Document::Document(const DocumentTypeRepo& repo, vespalib::nbostream & is, const deserialize(repo, is); } -Document::Document(const DocumentTypeRepo& repo, ByteBuffer& buffer, bool includeContent, const DataType *anticipatedType) - : StructuredFieldValue(anticipatedType ? verifyDocumentType(anticipatedType) : *DataType::DOCUMENT), - _id(), - _fields(static_cast<const DocumentType &>(getType()).getFieldsType()), - _lastModified(0) -{ - if (!includeContent) { - const DocumentType *newDocType = deserializeDocHeaderAndType(repo, buffer, _id, static_cast<const DocumentType*>(anticipatedType)); - if (newDocType) { - setType(*newDocType); - } - } else { - deserialize(repo, buffer); - } -} - - -Document::Document(const DocumentTypeRepo& repo, ByteBuffer& header, ByteBuffer& body, const DataType *anticipatedType) - : StructuredFieldValue(anticipatedType ? verifyDocumentType(anticipatedType) : *DataType::DOCUMENT), - _id(), - _fields(static_cast<const DocumentType &>(getType()).getFieldsType()), - _lastModified(0) -{ - deserializeHeader(repo, header); - deserializeBody(repo, body); -} - Document::~Document() = default; const DocumentType& @@ -188,7 +161,7 @@ Document::getDocTypeFromSerialized(const DocumentTypeRepo& repo, ByteBuffer& buf int position = buf.getPos(); DocumentId retVal; - const DocumentType *docType(deserializeDocHeaderAndType(repo, buf, retVal, nullptr)); + const DocumentType *docType(deserializeDocHeaderAndType(repo, buf, retVal)); buf.setPos(position); return docType; @@ -275,9 +248,7 @@ Document::calculateChecksum() const } const DocumentType * -Document::deserializeDocHeaderAndType( - const DocumentTypeRepo& repo, ByteBuffer& buffer, DocumentId& id, - const DocumentType * docType) +Document::deserializeDocHeaderAndType(const DocumentTypeRepo& repo, ByteBuffer& buffer, DocumentId& id) { deserializeDocHeader(buffer, id); @@ -289,11 +260,9 @@ Document::deserializeDocHeaderAndType( } const DocumentType *docTypeNew = nullptr; - if (! ((docType != nullptr) && (docType->getName() == docTypeName))) { - docTypeNew = repo.getDocumentType(docTypeName); - if (!docTypeNew) { - throw DocumentTypeNotFoundException(docTypeName, VESPA_STRLOC); - } + docTypeNew = repo.getDocumentType(docTypeName); + if (!docTypeNew) { + throw DocumentTypeNotFoundException(docTypeName, VESPA_STRLOC); } return docTypeNew; } diff --git a/document/src/vespa/document/fieldvalue/document.h b/document/src/vespa/document/fieldvalue/document.h index 3e1ec0da3e6..f0f86f75c4a 100644 --- a/document/src/vespa/document/fieldvalue/document.h +++ b/document/src/vespa/document/fieldvalue/document.h @@ -27,10 +27,11 @@ private: DocumentId _id; StructFieldValue _fields; - // To avoid having to return another container object out of docblocks - // the meta data has been added to document. This will not be serialized - // with the document and really doesn't belong here! + // To avoid having to return another container object out of docblocks + // the meta data has been added to document. This will not be serialized + // with the document and really doesn't belong here! int64_t _lastModified; + public: typedef std::unique_ptr<Document> UP; typedef std::shared_ptr<Document> SP; @@ -42,13 +43,8 @@ public: Document(); Document(const Document&); Document(const DataType &, DocumentId id); - Document(const DocumentTypeRepo& repo, ByteBuffer& buffer, const DataType *anticipatedType = nullptr); - Document(const DocumentTypeRepo& repo, vespalib::nbostream& stream, const DataType *anticipatedType = nullptr); - /** - Constructor to deserialize only document and type from a buffer. Only relevant if includeContent is false. - */ - Document(const DocumentTypeRepo& repo, ByteBuffer& buffer, bool includeContent, const DataType *anticipatedType); - Document(const DocumentTypeRepo& repo, ByteBuffer& header, ByteBuffer& body, const DataType *anticipatedType = nullptr); + Document(const DocumentTypeRepo& repo, vespalib::nbostream& stream); + Document(const DocumentTypeRepo& repo, ByteBuffer& buffer); ~Document() override; void setRepo(const DocumentTypeRepo & repo); @@ -146,9 +142,7 @@ private: StructuredIterator::UP getIterator(const Field* first) const override; static void deserializeDocHeader(ByteBuffer& buffer, DocumentId& id); - static const DocumentType *deserializeDocHeaderAndType( - const DocumentTypeRepo& repo, ByteBuffer& buffer, - DocumentId& id, const DocumentType * docType); + static const DocumentType *deserializeDocHeaderAndType(const DocumentTypeRepo& repo, ByteBuffer& buffer, DocumentId& id); }; } // document diff --git a/document/src/vespa/document/update/documentupdate.h b/document/src/vespa/document/update/documentupdate.h index a672d028f35..cb9113f5039 100644 --- a/document/src/vespa/document/update/documentupdate.h +++ b/document/src/vespa/document/update/documentupdate.h @@ -32,6 +32,7 @@ namespace document { +class ByteBuffer; class Document; class VespaDocumentSerializer; /** diff --git a/document/src/vespa/document/update/fieldpathupdate.h b/document/src/vespa/document/update/fieldpathupdate.h index 3e19420d0d0..0dbf8e5cc9e 100644 --- a/document/src/vespa/document/update/fieldpathupdate.h +++ b/document/src/vespa/document/update/fieldpathupdate.h @@ -7,7 +7,6 @@ namespace document { -class ByteBuffer; class DocumentTypeRepo; class Field; class FieldValue; @@ -35,7 +34,7 @@ public: using SP = std::shared_ptr<FieldPathUpdate>; using CP = vespalib::CloneablePtr<FieldPathUpdate>; - ~FieldPathUpdate(); + ~FieldPathUpdate() override; enum FieldPathUpdateType { Add = IDENTIFIABLE_CLASSID(AddFieldPathUpdate), |