diff options
author | Geir Storli <geirst@oath.com> | 2018-04-12 11:21:18 +0000 |
---|---|---|
committer | Geir Storli <geirst@oath.com> | 2018-04-12 11:21:18 +0000 |
commit | d573e3455d81acc073459a3faa9aada1d9d3ab7f (patch) | |
tree | aa51cc0ac870de25e81eabf6db448a841149ccd9 /storageapi | |
parent | fa78c43fbd55b2afa6263572549729dbeaaaf8fd (diff) |
Rename getMemoryFootprint() -> getApproxByteSize() in StorageMessage and make it non-virtual.
This is in preparation of using serialized size as approx size.
Diffstat (limited to 'storageapi')
10 files changed, 14 insertions, 40 deletions
diff --git a/storageapi/src/vespa/storageapi/message/batch.h b/storageapi/src/vespa/storageapi/message/batch.h index 8d67c7813fa..56cca3cfe38 100644 --- a/storageapi/src/vespa/storageapi/message/batch.h +++ b/storageapi/src/vespa/storageapi/message/batch.h @@ -106,11 +106,6 @@ public: */ Operation& getOperation(uint32_t index) { return *_operations[index]; } - /** - Returns an approximate size of this message. - */ - uint32_t getMemoryFootprint() const override { return _approxSize + 20; } - void print(std::ostream& out, bool verbose, const std::string& indent) const override; DECLARE_STORAGECOMMAND(BatchPutRemoveCommand, onBatchPutRemove) diff --git a/storageapi/src/vespa/storageapi/message/bucket.cpp b/storageapi/src/vespa/storageapi/message/bucket.cpp index 0961a8f6edc..afceac0f78d 100644 --- a/storageapi/src/vespa/storageapi/message/bucket.cpp +++ b/storageapi/src/vespa/storageapi/message/bucket.cpp @@ -521,12 +521,6 @@ RequestBucketInfoReply::RequestBucketInfoReply( RequestBucketInfoReply::~RequestBucketInfoReply() { } -uint32_t -RequestBucketInfoReply::getMemoryFootprint() const -{ - return sizeof(Entry) * _buckets.capacity(); -} - void RequestBucketInfoReply::print(std::ostream& out, bool verbose, const std::string& indent) const diff --git a/storageapi/src/vespa/storageapi/message/bucket.h b/storageapi/src/vespa/storageapi/message/bucket.h index 5fba1a3bf65..c0f65a0006a 100644 --- a/storageapi/src/vespa/storageapi/message/bucket.h +++ b/storageapi/src/vespa/storageapi/message/bucket.h @@ -400,7 +400,6 @@ public: ~RequestBucketInfoReply(); const EntryVector & getBucketInfo() const { return _buckets; } EntryVector & getBucketInfo() { return _buckets; } - uint32_t getMemoryFootprint() const override; void print(std::ostream& out, bool verbose, const std::string& indent) const override; DECLARE_STORAGEREPLY(RequestBucketInfoReply, onRequestBucketInfoReply) }; diff --git a/storageapi/src/vespa/storageapi/message/documentsummary.h b/storageapi/src/vespa/storageapi/message/documentsummary.h index 257a59cbc64..1cf24d6a4cb 100644 --- a/storageapi/src/vespa/storageapi/message/documentsummary.h +++ b/storageapi/src/vespa/storageapi/message/documentsummary.h @@ -19,9 +19,6 @@ class DocumentSummaryCommand : public StorageCommand, public: explicit DocumentSummaryCommand(); void print(std::ostream& out, bool verbose, const std::string& indent) const override; - uint32_t getMemoryFootprint() const override { - return getSerializedSize(); - } DECLARE_STORAGECOMMAND(DocumentSummaryCommand, onDocumentSummary) }; diff --git a/storageapi/src/vespa/storageapi/message/persistence.h b/storageapi/src/vespa/storageapi/message/persistence.h index 7d18a01d748..60d10c40648 100644 --- a/storageapi/src/vespa/storageapi/message/persistence.h +++ b/storageapi/src/vespa/storageapi/message/persistence.h @@ -64,9 +64,6 @@ public: const document::DocumentId& getDocumentId() const override { return _doc->getId(); } Timestamp getTimestamp() const { return _timestamp; } - uint32_t getMemoryFootprint() const override { - return (_doc.get() ? 4096 : 0) + 20; - } vespalib::string getSummary() const override; void print(std::ostream& out, bool verbose, const std::string& indent) const override; @@ -129,10 +126,6 @@ public: Timestamp getTimestamp() const { return _timestamp; } Timestamp getOldTimestamp() const { return _oldTimestamp; } - uint32_t getMemoryFootprint() const override { - return (_update.get() ? 1024 : 0) + 30; - } - vespalib::string getSummary() const override; void print(std::ostream& out, bool verbose, const std::string& indent) const override; @@ -236,9 +229,6 @@ public: Timestamp getBeforeTimestamp() const { return _beforeTimestamp; } bool wasFound() const { return (_doc.get() != 0); } - uint32_t getMemoryFootprint() const override { - return (_doc.get() ? 4096 : 0) + 30; - } void print(std::ostream& out, bool verbose, const std::string& indent) const override; DECLARE_STORAGEREPLY(GetReply, onGetReply) }; diff --git a/storageapi/src/vespa/storageapi/message/queryresult.h b/storageapi/src/vespa/storageapi/message/queryresult.h index 4062e3e6dee..0e30a3addf8 100644 --- a/storageapi/src/vespa/storageapi/message/queryresult.h +++ b/storageapi/src/vespa/storageapi/message/queryresult.h @@ -20,9 +20,6 @@ public: void print(std::ostream& out, bool verbose, const std::string& indent) const override; - uint32_t getMemoryFootprint() const override { - return getSearchResult().getSerializedSize() + getDocumentSummary().getSerializedSize(); - } const vdslib::SearchResult & getSearchResult() const { return _searchResult; } vdslib::SearchResult & getSearchResult() { return _searchResult; } const vdslib::DocumentSummary & getDocumentSummary() const { return _summary; } diff --git a/storageapi/src/vespa/storageapi/message/removelocation.h b/storageapi/src/vespa/storageapi/message/removelocation.h index 55b2d1eb75e..54edbc5916e 100644 --- a/storageapi/src/vespa/storageapi/message/removelocation.h +++ b/storageapi/src/vespa/storageapi/message/removelocation.h @@ -14,9 +14,6 @@ public: ~RemoveLocationCommand(); void print(std::ostream& out, bool verbose, const std::string& indent) const override; - uint32_t getMemoryFootprint() const override { - return _documentSelection.length(); - } const vespalib::string& getDocumentSelection() const { return _documentSelection; } DECLARE_STORAGECOMMAND(RemoveLocationCommand, onRemoveLocation); private: diff --git a/storageapi/src/vespa/storageapi/message/searchresult.h b/storageapi/src/vespa/storageapi/message/searchresult.h index 75ed3d9db80..466b60cc0d7 100644 --- a/storageapi/src/vespa/storageapi/message/searchresult.h +++ b/storageapi/src/vespa/storageapi/message/searchresult.h @@ -17,7 +17,6 @@ class SearchResultCommand : public StorageCommand, public vdslib::SearchResult { public: SearchResultCommand(); void print(std::ostream& out, bool verbose, const std::string& indent) const override; - uint32_t getMemoryFootprint() const override { return getSerializedSize(); } DECLARE_STORAGECOMMAND(SearchResultCommand, onSearchResult) }; diff --git a/storageapi/src/vespa/storageapi/messageapi/storagemessage.cpp b/storageapi/src/vespa/storageapi/messageapi/storagemessage.cpp index 22195466dd2..f970091f695 100644 --- a/storageapi/src/vespa/storageapi/messageapi/storagemessage.cpp +++ b/storageapi/src/vespa/storageapi/messageapi/storagemessage.cpp @@ -273,7 +273,8 @@ StorageMessage::StorageMessage(const MessageType& type, Id id) _msgId(id), _priority(NORMAL), _address(), - _loadType(documentapi::LoadType::DEFAULT) + _loadType(documentapi::LoadType::DEFAULT), + _approxByteSize(50) { } @@ -282,7 +283,8 @@ StorageMessage::StorageMessage(const StorageMessage& other, Id id) _msgId(id), _priority(other._priority), _address(), - _loadType(other._loadType) + _loadType(other._loadType), + _approxByteSize(other._approxByteSize) { } diff --git a/storageapi/src/vespa/storageapi/messageapi/storagemessage.h b/storageapi/src/vespa/storageapi/messageapi/storagemessage.h index ff53c222521..e8474fed89a 100644 --- a/storageapi/src/vespa/storageapi/messageapi/storagemessage.h +++ b/storageapi/src/vespa/storageapi/messageapi/storagemessage.h @@ -340,6 +340,7 @@ protected: std::unique_ptr<StorageMessageAddress> _address; documentapi::LoadType _loadType; mbus::Trace _trace; + uint32_t _approxByteSize; StorageMessage(const MessageType& code, Id id); StorageMessage(const StorageMessage&, Id id); @@ -370,12 +371,15 @@ public: { _address.reset(new StorageMessageAddress(address)); } /** - Returns the approximate memory footprint of a storage message. - By default, returns 50 bytes. This only needs to be overriden if the - message potentially can be much larger than this. - */ - virtual uint32_t getMemoryFootprint() const { - return 50; + * Returns the approximate memory footprint (in bytes) of a storage message. + * By default, returns 50 bytes. + */ + uint32_t getApproxByteSize() const noexcept { + return _approxByteSize; + } + + void setApproxByteSize(uint32_t value) { + _approxByteSize = value; } /** |