diff options
author | Tor Egge <Tor.Egge@online.no> | 2021-04-20 14:18:40 +0200 |
---|---|---|
committer | Tor Egge <Tor.Egge@online.no> | 2021-04-20 14:18:40 +0200 |
commit | dc1230606e52ee691fa5784ddcfba33479bdaaa5 (patch) | |
tree | c6670860b3f028f7c800e5dd6da412eb4e93831c /searchlib | |
parent | ddd015ba597fcdadf0a8917a4192534d7ea86cfa (diff) |
Wire in compaction of posting lists.
Diffstat (limited to 'searchlib')
5 files changed, 43 insertions, 0 deletions
diff --git a/searchlib/src/vespa/searchlib/attribute/ipostinglistattributebase.h b/searchlib/src/vespa/searchlib/attribute/ipostinglistattributebase.h index 4876f43cd5d..3936ed381be 100644 --- a/searchlib/src/vespa/searchlib/attribute/ipostinglistattributebase.h +++ b/searchlib/src/vespa/searchlib/attribute/ipostinglistattributebase.h @@ -4,6 +4,8 @@ #include <vespa/searchcommon/attribute/iattributevector.h> +namespace search { class CompactionStrategy; } + namespace vespalib { class MemoryUsage; } namespace search::attribute { @@ -23,6 +25,8 @@ public: virtual void forwardedShrinkLidSpace(uint32_t newSize) = 0; virtual vespalib::MemoryUsage getMemoryUsage() const = 0; + virtual bool consider_compact_worst_btree_nodes(const CompactionStrategy& compaction_strategy) = 0; + virtual bool consider_compact_worst_buffers(const CompactionStrategy& compaction_strategy) = 0; }; } // namespace search::attribute diff --git a/searchlib/src/vespa/searchlib/attribute/multienumattribute.hpp b/searchlib/src/vespa/searchlib/attribute/multienumattribute.hpp index a512f707c23..6646446c3a7 100644 --- a/searchlib/src/vespa/searchlib/attribute/multienumattribute.hpp +++ b/searchlib/src/vespa/searchlib/attribute/multienumattribute.hpp @@ -7,6 +7,7 @@ #include "multienumattributesaver.h" #include "load_utils.h" #include "enum_store_loaders.h" +#include "ipostinglistattributebase.h" #include <vespa/vespalib/stllike/hashtable.hpp> #include <vespa/vespalib/datastore/unique_store_remapper.h> @@ -187,6 +188,17 @@ MultiValueEnumAttribute<B, M>::onCommit() this->incGeneration(); this->updateStat(true); } + auto *pab = this->getIPostingListAttributeBase(); + if (pab != nullptr) { + if (pab->consider_compact_worst_btree_nodes(this->getConfig().getCompactionStrategy())) { + this->incGeneration(); + this->updateStat(true); + } + if (pab->consider_compact_worst_buffers(this->getConfig().getCompactionStrategy())) { + this->incGeneration(); + this->updateStat(true); + } + } } template <typename B, typename M> diff --git a/searchlib/src/vespa/searchlib/attribute/postinglistattribute.cpp b/searchlib/src/vespa/searchlib/attribute/postinglistattribute.cpp index 5b57b577926..9a431be5a02 100644 --- a/searchlib/src/vespa/searchlib/attribute/postinglistattribute.cpp +++ b/searchlib/src/vespa/searchlib/attribute/postinglistattribute.cpp @@ -180,6 +180,20 @@ PostingListAttributeBase<P>::getMemoryUsage() const return _postingList.getMemoryUsage(); } +template <typename P> +bool +PostingListAttributeBase<P>::consider_compact_worst_btree_nodes(const CompactionStrategy& compaction_strategy) +{ + return _postingList.consider_compact_worst_btree_nodes(compaction_strategy); +} + +template <typename P> +bool +PostingListAttributeBase<P>::consider_compact_worst_buffers(const CompactionStrategy& compaction_strategy) +{ + return _postingList.consider_compact_worst_buffers(compaction_strategy); +} + template <typename P, typename LoadedVector, typename LoadedValueType, typename EnumStoreType> PostingListAttributeSubBase<P, LoadedVector, LoadedValueType, EnumStoreType>:: diff --git a/searchlib/src/vespa/searchlib/attribute/postinglistattribute.h b/searchlib/src/vespa/searchlib/attribute/postinglistattribute.h index 29c4846edd4..8cd9d1d6bbd 100644 --- a/searchlib/src/vespa/searchlib/attribute/postinglistattribute.h +++ b/searchlib/src/vespa/searchlib/attribute/postinglistattribute.h @@ -68,6 +68,8 @@ protected: void forwardedShrinkLidSpace(uint32_t newSize) override; vespalib::MemoryUsage getMemoryUsage() const override; + bool consider_compact_worst_btree_nodes(const CompactionStrategy& compaction_strategy) override; + bool consider_compact_worst_buffers(const CompactionStrategy& compaction_strategy) override; public: const PostingList & getPostingList() const { return _postingList; } diff --git a/searchlib/src/vespa/searchlib/attribute/singleenumattribute.hpp b/searchlib/src/vespa/searchlib/attribute/singleenumattribute.hpp index b72f2d16b15..39a12cb57d5 100644 --- a/searchlib/src/vespa/searchlib/attribute/singleenumattribute.hpp +++ b/searchlib/src/vespa/searchlib/attribute/singleenumattribute.hpp @@ -106,6 +106,17 @@ SingleValueEnumAttribute<B>::onCommit() this->incGeneration(); this->updateStat(true); } + auto *pab = this->getIPostingListAttributeBase(); + if (pab != nullptr) { + if (pab->consider_compact_worst_btree_nodes(this->getConfig().getCompactionStrategy())) { + this->incGeneration(); + this->updateStat(true); + } + if (pab->consider_compact_worst_buffers(this->getConfig().getCompactionStrategy())) { + this->incGeneration(); + this->updateStat(true); + } + } } template <typename B> |