diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2020-01-15 06:10:55 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2020-01-16 10:48:07 +0000 |
commit | f4ca1a66486f7e10f507b0c8054e403c7ff9c125 (patch) | |
tree | e509b81c89fb2f9eb5fdefaf79a6ebbde7a6444f /persistence | |
parent | b324c19e007a7a57ba731ed72a01d35cd6937ed7 (diff) |
Remove and indirection for document id, for less memory footprint, and better generated code.
Diffstat (limited to 'persistence')
-rw-r--r-- | persistence/src/vespa/persistence/spi/docentry.cpp | 41 | ||||
-rw-r--r-- | persistence/src/vespa/persistence/spi/docentry.h | 9 | ||||
-rw-r--r-- | persistence/src/vespa/persistence/spi/documentselection.h | 5 |
3 files changed, 11 insertions, 44 deletions
diff --git a/persistence/src/vespa/persistence/spi/docentry.cpp b/persistence/src/vespa/persistence/spi/docentry.cpp index dac3761c6d2..d482d144d73 100644 --- a/persistence/src/vespa/persistence/spi/docentry.cpp +++ b/persistence/src/vespa/persistence/spi/docentry.cpp @@ -5,8 +5,7 @@ #include <sstream> #include <cassert> -namespace storage { -namespace spi { +namespace storage::spi { DocEntry::DocEntry(Timestamp t, int metaFlags, DocumentUP doc) : _timestamp(t), @@ -47,17 +46,17 @@ DocEntry::DocEntry(Timestamp t, int metaFlags) _document() { } -DocEntry::~DocEntry() { } +DocEntry::~DocEntry() = default; DocEntry* DocEntry::clone() const { DocEntry* ret; - if (_documentId.get() != 0) { + if (_documentId) { ret = new DocEntry(_timestamp, _metaFlags, *_documentId); ret->setPersistedDocumentSize(_persistedDocumentSize); - } else if (_document.get()) { + } else if (_document) { ret = new DocEntry(_timestamp, _metaFlags, - DocumentUP(new Document(*_document)), + std::make_unique<Document>(*_document), _persistedDocumentSize); } else { ret = new DocEntry(_timestamp, _metaFlags); @@ -68,8 +67,7 @@ DocEntry::clone() const { const DocumentId* DocEntry::getDocumentId() const { - return (_document.get() != 0 ? &_document->getId() - : _documentId.get()); + return (_document ? &_document->getId() : _documentId.get()); } DocumentUP @@ -89,7 +87,7 @@ DocEntry::toString() const { std::ostringstream out; out << "DocEntry(" << _timestamp << ", " << _metaFlags << ", "; - if (_documentId.get() != 0) { + if (_documentId) { out << *_documentId; } else if (_document.get()) { out << "Doc(" << _document->getId() << ")"; @@ -100,26 +98,6 @@ DocEntry::toString() const return out.str(); } -void -DocEntry::prettyPrint(std::ostream& out) const -{ - std::string flags; - if (_metaFlags == REMOVE_ENTRY) { - flags = " (remove)"; - } - - out << "DocEntry(Timestamp: " << _timestamp - << ", size " << getPersistedDocumentSize() << ", "; - if (_documentId) { - out << *_documentId; - } else if (_document.get()) { - out << "Doc(" << _document->getId() << ")"; - } else { - out << "metadata only"; - } - out << flags << ")"; -} - std::ostream & operator << (std::ostream & os, const DocEntry & r) { return os << r.toString(); @@ -169,7 +147,4 @@ DocEntry::operator==(const DocEntry& entry) const { return true; } -} // spi -} // storage - - +} diff --git a/persistence/src/vespa/persistence/spi/docentry.h b/persistence/src/vespa/persistence/spi/docentry.h index 5ad2856cdef..aa9bf20a7f9 100644 --- a/persistence/src/vespa/persistence/spi/docentry.h +++ b/persistence/src/vespa/persistence/spi/docentry.h @@ -15,8 +15,7 @@ #include <persistence/spi/types.h> -namespace storage { -namespace spi { +namespace storage::spi { enum DocumentMetaFlags { NONE = 0x0, @@ -88,13 +87,9 @@ public: } vespalib::string toString() const; - void prettyPrint(std::ostream& out) const; bool operator==(const DocEntry& entry) const; }; std::ostream & operator << (std::ostream & os, const DocEntry & r); -} // spi -} // storage - - +} diff --git a/persistence/src/vespa/persistence/spi/documentselection.h b/persistence/src/vespa/persistence/spi/documentselection.h index 0957289446f..af734d2e16e 100644 --- a/persistence/src/vespa/persistence/spi/documentselection.h +++ b/persistence/src/vespa/persistence/spi/documentselection.h @@ -10,8 +10,7 @@ #include <persistence/spi/types.h> -namespace storage { -namespace spi { +namespace storage::spi { class DocumentSelection { @@ -28,5 +27,3 @@ class DocumentSelection }; } -} - |