summaryrefslogtreecommitdiffstats
path: root/searchlib
diff options
context:
space:
mode:
authorTor Egge <Tor.Egge@broadpark.no>2019-09-23 13:52:09 +0200
committerTor Egge <Tor.Egge@broadpark.no>2019-09-23 13:52:09 +0200
commitab7dd8723943a46c880d858d81cb4d47e0cac5f8 (patch)
treeaa39603c59e1231ded01342372b2af972a10df64 /searchlib
parent97deff8278c8bed1ec448b9c30b8999c6a62fe03 (diff)
Verify that corresponding posting list is empty before removing
enum store entry.
Diffstat (limited to 'searchlib')
-rw-r--r--searchlib/src/vespa/searchlib/attribute/enum_store_dictionary.cpp23
-rw-r--r--searchlib/src/vespa/searchlib/attribute/enum_store_dictionary.h1
2 files changed, 21 insertions, 3 deletions
diff --git a/searchlib/src/vespa/searchlib/attribute/enum_store_dictionary.cpp b/searchlib/src/vespa/searchlib/attribute/enum_store_dictionary.cpp
index 2a544814710..1299accbfc1 100644
--- a/searchlib/src/vespa/searchlib/attribute/enum_store_dictionary.cpp
+++ b/searchlib/src/vespa/searchlib/attribute/enum_store_dictionary.cpp
@@ -78,6 +78,19 @@ EnumStoreDictionary<DictionaryT>::free_unused_values(const IndexSet& to_remove,
}
template <typename DictionaryT>
+void
+EnumStoreDictionary<DictionaryT>::remove(const EntryComparator &comp, EntryRef ref)
+{
+ assert(ref.valid());
+ auto itr = this->_dict.lowerBound(ref, comp);
+ assert(itr.valid() && itr.getKey() == ref);
+ if constexpr (std::is_same_v<DictionaryT, EnumPostingTree>) {
+ assert(EntryRef(itr.getData()) == EntryRef());
+ }
+ this->_dict.remove(itr);
+}
+
+template <typename DictionaryT>
bool
EnumStoreDictionary<DictionaryT>::find_index(const datastore::EntryComparator& cmp,
Index& idx) const
@@ -184,9 +197,13 @@ EnumStoreFoldedDictionary::remove(const EntryComparator& comp, EntryRef ref)
EntryRef posting_list_ref(it.getData());
_dict.remove(it);
// Maybe copy posting list reference to next entry
- if (posting_list_ref.valid() && it.valid() && !EntryRef(it.getData()).valid() && !(*_folded_compare)(ref, it.getKey())) {
- this->_dict.thaw(it);
- it.writeData(posting_list_ref.ref());
+ if (posting_list_ref.valid()) {
+ if (it.valid() && !EntryRef(it.getData()).valid() && !(*_folded_compare)(ref, it.getKey())) {
+ this->_dict.thaw(it);
+ it.writeData(posting_list_ref.ref());
+ } else {
+ LOG_ABORT("Posting list not cleared for removed unique value");
+ }
}
}
diff --git a/searchlib/src/vespa/searchlib/attribute/enum_store_dictionary.h b/searchlib/src/vespa/searchlib/attribute/enum_store_dictionary.h
index 5e7a63e68b4..c2c4c96c2d9 100644
--- a/searchlib/src/vespa/searchlib/attribute/enum_store_dictionary.h
+++ b/searchlib/src/vespa/searchlib/attribute/enum_store_dictionary.h
@@ -41,6 +41,7 @@ public:
void free_unused_values(const IndexSet& to_remove,
const datastore::EntryComparator& cmp) override;
+ void remove(const datastore::EntryComparator& comp, datastore::EntryRef ref) override;
bool find_index(const datastore::EntryComparator& cmp, Index& idx) const override;
bool find_frozen_index(const datastore::EntryComparator& cmp, Index& idx) const override;
std::vector<attribute::IAttributeVector::EnumHandle>