diff options
author | Tor Egge <Tor.Egge@yahoo-inc.com> | 2017-05-10 13:27:26 +0000 |
---|---|---|
committer | Tor Egge <Tor.Egge@yahoo-inc.com> | 2017-05-10 13:55:45 +0000 |
commit | 11c75d31a893557328edef999e81778352a93e2e (patch) | |
tree | 5336f729b7d26f6fec0cc00c4cfcae109b8ae8ff /searchcore | |
parent | 05129d164410cc0ca30c9d5a5cc0b3f2ead4c5d2 (diff) |
Add getEstimatedShrinkLidSpaceGain() to interface for compactable lid space.
Diffstat (limited to 'searchcore')
4 files changed, 23 insertions, 33 deletions
diff --git a/searchcore/src/vespa/searchcore/proton/attribute/flushableattribute.cpp b/searchcore/src/vespa/searchcore/proton/attribute/flushableattribute.cpp index e3c27c752b0..260d819bec5 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/flushableattribute.cpp +++ b/searchcore/src/vespa/searchcore/proton/attribute/flushableattribute.cpp @@ -202,30 +202,11 @@ IFlushTarget::MemoryGain FlushableAttribute::getApproxMemoryGain() const { int64_t used(_attr->getStatus().getUsed()); - int64_t canFree = 0; - if (_attr->canShrinkLidSpace()) { - uint32_t committedDocIdLimit = _attr->getCommittedDocIdLimit(); - uint32_t numDocs = _attr->getNumDocs(); - const attribute::Config &cfg = _attr->getConfig(); - if (committedDocIdLimit < numDocs) { - uint32_t elemSize = 4; - if (cfg.collectionType().isMultiValue()) { - if (cfg.huge()) { - elemSize = 8; - } - } else if (cfg.fastSearch()) { - // keep elemSize at 4 - } else { - elemSize = cfg.basicType().fixedSize(); - } - canFree = static_cast<int64_t>(elemSize) * - (numDocs - committedDocIdLimit); - if (canFree > used) - canFree = used; - } + int64_t canFree = _attr->getEstimatedShrinkLidSpaceGain(); + if (canFree > used) { + canFree = used; } - return MemoryGain(used, - used - canFree); + return MemoryGain(used, used - canFree); } IFlushTarget::DiskGain diff --git a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.cpp b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.cpp index 209d2cf07f3..03c0c1bd771 100644 --- a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.cpp +++ b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.cpp @@ -1019,6 +1019,21 @@ DocumentMetaStore::onShrinkLidSpace() setNumDocs(committedDocIdLimit); } +size_t +DocumentMetaStore::getEstimatedShrinkLidSpaceGain() const +{ + size_t canFree = 0; + if (canShrinkLidSpace()) { + uint32_t committedDocIdLimit = getCommittedDocIdLimit(); + uint32_t numDocs = getNumDocs(); + if (committedDocIdLimit < numDocs) { + canFree = sizeof(RawDocumentMetaData) * + (numDocs - committedDocIdLimit); + } + } + return canFree; +} + BucketId DocumentMetaStore::getBucketOf(const vespalib::GenerationHandler::Guard &, uint32_t lid) const { diff --git a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.h b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.h index 200535c7ae5..1f1f933700f 100644 --- a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.h +++ b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.h @@ -274,6 +274,7 @@ public: */ void unblockShrinkLidSpace(); void onShrinkLidSpace() override; + virtual size_t getEstimatedShrinkLidSpaceGain() const override; uint64_t getEstimatedSaveByteSize() const override; virtual uint32_t getVersion() const override; void setTrackDocumentSizes(bool trackDocumentSizes) { _trackDocumentSizes = trackDocumentSizes; } diff --git a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastoreflushtarget.cpp b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastoreflushtarget.cpp index 33c90819e33..e2fa972f926 100644 --- a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastoreflushtarget.cpp +++ b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastoreflushtarget.cpp @@ -209,16 +209,9 @@ IFlushTarget::MemoryGain DocumentMetaStoreFlushTarget::getApproxMemoryGain() const { int64_t used(_dms->getStatus().getUsed()); - int64_t canFree = 0; - if (_dms->canShrinkLidSpace()) { - uint32_t committedDocIdLimit = _dms->getCommittedDocIdLimit(); - uint32_t numDocs = _dms->getNumDocs(); - if (committedDocIdLimit < numDocs) { - canFree = sizeof(RawDocumentMetaData) * - (numDocs - committedDocIdLimit); - if (canFree > used) - canFree = used; - } + int64_t canFree = _dms->getEstimatedShrinkLidSpaceGain(); + if (canFree > used) { + canFree = used; } return MemoryGain(used, used - canFree); } |