aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib
diff options
context:
space:
mode:
authorTor Egge <Tor.Egge@broadpark.no>2021-03-15 14:47:35 +0100
committerTor Egge <Tor.Egge@broadpark.no>2021-03-15 14:47:35 +0100
commitaaf940f6431d007dfcb7048ca1658bb42ccf0779 (patch)
tree12cc784fd35e3bc1a0217148c27d731ee844f03f /searchlib
parent04c74ec36ee6546b4670be6311206d965cf9f2d5 (diff)
Add clear_all_posting_lists method to dictionary.
Diffstat (limited to 'searchlib')
-rw-r--r--searchlib/src/vespa/searchlib/attribute/enum_store_dictionary.cpp27
-rw-r--r--searchlib/src/vespa/searchlib/attribute/enum_store_dictionary.h1
-rw-r--r--searchlib/src/vespa/searchlib/attribute/i_enum_store_dictionary.h1
-rw-r--r--searchlib/src/vespa/searchlib/attribute/postinglistattribute.cpp19
4 files changed, 34 insertions, 14 deletions
diff --git a/searchlib/src/vespa/searchlib/attribute/enum_store_dictionary.cpp b/searchlib/src/vespa/searchlib/attribute/enum_store_dictionary.cpp
index e71aa98b725..f7a2a507aec 100644
--- a/searchlib/src/vespa/searchlib/attribute/enum_store_dictionary.cpp
+++ b/searchlib/src/vespa/searchlib/attribute/enum_store_dictionary.cpp
@@ -131,6 +131,33 @@ EnumStoreDictionary<DictionaryT>::find_matching_enums(const vespalib::datastore:
template <>
void
+EnumStoreDictionary<EnumTree>::clear_all_posting_lists(std::function<void(EntryRef)>)
+{
+ LOG_ABORT("should not be reached");
+}
+
+template <>
+void
+EnumStoreDictionary<EnumPostingTree>::clear_all_posting_lists(std::function<void(EntryRef)> clearer)
+{
+ auto& dict = this->_dict;
+ auto itr = dict.begin();
+ EntryRef prev;
+ while (itr.valid()) {
+ EntryRef ref(itr.getData());
+ if (ref.ref() != prev.ref()) {
+ if (ref.valid()) {
+ clearer(ref);
+ }
+ prev = ref;
+ }
+ itr.writeData(EntryRef().ref());
+ ++itr;
+ }
+}
+
+template <>
+void
EnumStoreDictionary<EnumTree>::update_posting_list(Index, const vespalib::datastore::EntryComparator&, std::function<EntryRef(EntryRef)>)
{
LOG_ABORT("should not be reached");
diff --git a/searchlib/src/vespa/searchlib/attribute/enum_store_dictionary.h b/searchlib/src/vespa/searchlib/attribute/enum_store_dictionary.h
index 363bd519538..67bbb1cd3e9 100644
--- a/searchlib/src/vespa/searchlib/attribute/enum_store_dictionary.h
+++ b/searchlib/src/vespa/searchlib/attribute/enum_store_dictionary.h
@@ -49,6 +49,7 @@ public:
std::vector<attribute::IAttributeVector::EnumHandle>
find_matching_enums(const vespalib::datastore::EntryComparator& cmp) const override;
+ void clear_all_posting_lists(std::function<void(EntryRef)> clearer) override;
void update_posting_list(Index idx, const vespalib::datastore::EntryComparator& cmp, std::function<EntryRef(EntryRef)> updater) override;
EnumPostingTree& get_posting_dictionary() override;
const EnumPostingTree& get_posting_dictionary() const override;
diff --git a/searchlib/src/vespa/searchlib/attribute/i_enum_store_dictionary.h b/searchlib/src/vespa/searchlib/attribute/i_enum_store_dictionary.h
index 7712cdd3dad..8bbd7677595 100644
--- a/searchlib/src/vespa/searchlib/attribute/i_enum_store_dictionary.h
+++ b/searchlib/src/vespa/searchlib/attribute/i_enum_store_dictionary.h
@@ -47,6 +47,7 @@ public:
virtual std::vector<attribute::IAttributeVector::EnumHandle>
find_matching_enums(const vespalib::datastore::EntryComparator& cmp) const = 0;
+ virtual void clear_all_posting_lists(std::function<void(EntryRef)> clearer) = 0;
virtual void update_posting_list(Index idx, const vespalib::datastore::EntryComparator& cmp, std::function<EntryRef(EntryRef)> updater) = 0;
virtual EnumPostingTree& get_posting_dictionary() = 0;
virtual const EnumPostingTree& get_posting_dictionary() const = 0;
diff --git a/searchlib/src/vespa/searchlib/attribute/postinglistattribute.cpp b/searchlib/src/vespa/searchlib/attribute/postinglistattribute.cpp
index f39a8c7503d..d3223901a71 100644
--- a/searchlib/src/vespa/searchlib/attribute/postinglistattribute.cpp
+++ b/searchlib/src/vespa/searchlib/attribute/postinglistattribute.cpp
@@ -29,20 +29,11 @@ PostingListAttributeBase<P>::clearAllPostings()
{
_postingList.clearBuilder();
_attr.incGeneration(); // Force freeze
- auto& dict = _dictionary.get_posting_dictionary();
- auto itr = dict.begin();
- EntryRef prev;
- while (itr.valid()) {
- EntryRef ref(itr.getData());
- if (ref.ref() != prev.ref()) {
- if (ref.valid()) {
- _postingList.clear(ref);
- }
- prev = ref;
- }
- itr.writeData(EntryRef().ref());
- ++itr;
- }
+ auto clearer = [this](EntryRef posting_idx)
+ {
+ _postingList.clear(posting_idx);
+ };
+ _dictionary.clear_all_posting_lists(clearer);
_attr.incGeneration(); // Force freeze
}