summaryrefslogtreecommitdiffstats
path: root/searchlib
diff options
context:
space:
mode:
authorGeir Storli <geirst@verizonmedia.com>2019-09-11 13:42:11 +0000
committerGeir Storli <geirst@verizonmedia.com>2019-09-11 13:42:11 +0000
commit103d75ad8e42a1d2d7d84067d185bcacf5668f94 (patch)
treea0225477659a8cc2ed7f0335bcb7802a0077e03e /searchlib
parent5e39d873c236a2971ca67f53f5bcde40574e1e2d (diff)
Add unit tests for enum store loading and fix bug when loading from non-enumerated save files.
In this case the posting list reference was not written to the dictionary, the result being empty posting lists for all unique values. Loading from non-enumerated save files is only used when changing a numeric attribute to use fast-search.
Diffstat (limited to 'searchlib')
-rw-r--r--searchlib/src/tests/attribute/enumstore/enumstore_test.cpp124
-rw-r--r--searchlib/src/tests/attribute/postinglistattribute/postinglistattribute_test.cpp4
-rw-r--r--searchlib/src/vespa/searchlib/attribute/diversity.h3
-rw-r--r--searchlib/src/vespa/searchlib/attribute/enum_store_dictionary.cpp36
-rw-r--r--searchlib/src/vespa/searchlib/attribute/enum_store_dictionary.h24
-rw-r--r--searchlib/src/vespa/searchlib/attribute/i_enum_store_dictionary.h2
-rw-r--r--searchlib/src/vespa/searchlib/attribute/multinumericpostattribute.hpp2
-rw-r--r--searchlib/src/vespa/searchlib/attribute/multistringpostattribute.hpp2
-rw-r--r--searchlib/src/vespa/searchlib/attribute/postinglistattribute.cpp16
-rw-r--r--searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.cpp2
-rw-r--r--searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.hpp12
-rw-r--r--searchlib/src/vespa/searchlib/attribute/postingstore.cpp4
12 files changed, 179 insertions, 52 deletions
diff --git a/searchlib/src/tests/attribute/enumstore/enumstore_test.cpp b/searchlib/src/tests/attribute/enumstore/enumstore_test.cpp
index e1078e4f61d..cd02c099f1f 100644
--- a/searchlib/src/tests/attribute/enumstore/enumstore_test.cpp
+++ b/searchlib/src/tests/attribute/enumstore/enumstore_test.cpp
@@ -378,6 +378,130 @@ TEST_F(BatchUpdaterTest, unused_new_value_is_removed)
expect_value_not_in_store(7, i7);
}
+template <typename EnumStoreT>
+class LoaderTest : public ::testing::Test {
+public:
+ using EntryType = typename EnumStoreT::EntryType;
+ EnumStoreT store;
+ static std::vector<EntryType> values;
+
+ LoaderTest()
+ : store(true)
+ {}
+
+ void load_values(enumstore::EnumeratedLoaderBase& loader) const {
+ loader.load_unique_values(values.data(), values.size() * sizeof(EntryType));
+ }
+
+ EnumIndex find_index(size_t values_idx) const {
+ EnumIndex result;
+ EXPECT_TRUE(store.findIndex(values[values_idx], result));
+ return result;
+ }
+
+ void set_ref_count(size_t values_idx, uint32_t ref_count, enumstore::EnumeratedPostingsLoader& loader) const {
+ EnumIndex idx = find_index(values_idx);
+ loader.set_ref_count(idx, ref_count);
+ }
+
+ void expect_value_in_store(size_t values_idx, uint32_t exp_ref_count) const {
+ EnumIndex idx = find_index(values_idx);
+ EXPECT_EQ(exp_ref_count, store.getRefCount(idx));
+ }
+
+ void expect_value_not_in_store(size_t values_idx) const {
+ EnumIndex idx;
+ EXPECT_FALSE(store.findIndex(values[values_idx], idx));
+ }
+
+ void expect_values_in_store() {
+ expect_value_in_store(0, 1);
+ expect_value_in_store(1, 2);
+ expect_value_not_in_store(2);
+ expect_value_in_store(3, 4);
+ }
+
+ void expect_posting_idx(size_t values_idx, uint32_t exp_posting_idx) const {
+ auto cmp = store.make_comparator();
+ auto itr = store.getPostingDictionary().find(find_index(values_idx), cmp);
+ ASSERT_TRUE(itr.valid());
+ EXPECT_EQ(exp_posting_idx, itr.getData());
+ }
+
+};
+
+template <> std::vector<int32_t> LoaderTest<NumericEnumStore>::values{3, 5, 7, 9};
+template <> std::vector<float> LoaderTest<FloatEnumStore>::values{3.1, 5.2, 7.3, 9.4};
+template <> std::vector<const char *> LoaderTest<StringEnumStore>::values{"aa", "bbb", "ccc", "dd"};
+
+template <>
+void
+LoaderTest<StringEnumStore>::load_values(enumstore::EnumeratedLoaderBase& loader) const
+{
+ std::vector<char> raw_values;
+ for (auto value : values) {
+ for (auto c : std::string(value)) {
+ raw_values.push_back(c);
+ }
+ raw_values.push_back('\0');
+ }
+ loader.load_unique_values(raw_values.data(), raw_values.size());
+}
+
+// Disable warnings emitted by gtest generated files when using typed tests
+#pragma GCC diagnostic push
+#ifndef __clang__
+#pragma GCC diagnostic ignored "-Wsuggest-override"
+#endif
+
+using LoaderTestTypes = ::testing::Types<NumericEnumStore, FloatEnumStore, StringEnumStore>;
+TYPED_TEST_CASE(LoaderTest, LoaderTestTypes);
+
+TYPED_TEST(LoaderTest, store_is_instantiated_with_enumerated_loader)
+{
+ auto loader = this->store.make_enumerated_loader();
+ this->load_values(loader);
+ loader.allocate_enums_histogram();
+ loader.get_enums_histogram()[0] = 1;
+ loader.get_enums_histogram()[1] = 2;
+ loader.get_enums_histogram()[3] = 4;
+ loader.set_ref_counts();
+
+ this->expect_values_in_store();
+}
+
+TYPED_TEST(LoaderTest, store_is_instantiated_with_enumerated_postings_loader)
+{
+ auto loader = this->store.make_enumerated_postings_loader();
+ this->load_values(loader);
+ this->set_ref_count(0, 1, loader);
+ this->set_ref_count(1, 2, loader);
+ this->set_ref_count(3, 4, loader);
+ loader.free_unused_enums();
+
+ this->expect_values_in_store();
+}
+
+TYPED_TEST(LoaderTest, store_is_instantiated_with_non_enumerated_loader)
+{
+ auto loader = this->store.make_non_enumerated_loader();
+ loader.insert(this->values[0], 100);
+ loader.set_ref_count_for_last_value(1);
+ loader.insert(this->values[1], 101);
+ loader.set_ref_count_for_last_value(2);
+ loader.insert(this->values[3], 103);
+ loader.set_ref_count_for_last_value(4);
+ loader.build_dictionary();
+
+ this->expect_values_in_store();
+
+ this->expect_posting_idx(0, 100);
+ this->expect_posting_idx(1, 101);
+ this->expect_posting_idx(3, 103);
+}
+
+#pragma GCC diagnostic pop
+
}
GTEST_MAIN_RUN_ALL_TESTS()
diff --git a/searchlib/src/tests/attribute/postinglistattribute/postinglistattribute_test.cpp b/searchlib/src/tests/attribute/postinglistattribute/postinglistattribute_test.cpp
index e94279ddb72..2be779cb41d 100644
--- a/searchlib/src/tests/attribute/postinglistattribute/postinglistattribute_test.cpp
+++ b/searchlib/src/tests/attribute/postinglistattribute/postinglistattribute_test.cpp
@@ -457,7 +457,7 @@ PostingListAttributeTest::checkPostingList(const VectorType & vec, const std::ve
ASSERT_TRUE(itr.valid());
typename VectorType::PostingList::Iterator postings;
- postings = postingList.begin(itr.getData());
+ postings = postingList.begin(datastore::EntryRef(itr.getData()));
uint32_t doc = docBegin;
uint32_t numHits(0);
@@ -676,7 +676,7 @@ PostingListAttributeTest::checkPostingList(AttributeType & vec, ValueType value,
ASSERT_TRUE(itr.valid());
typename AttributeType::PostingList::Iterator postings;
- postings = postingList.begin(itr.getData());
+ postings = postingList.begin(datastore::EntryRef(itr.getData()));
DocSet::iterator docBegin = expected.begin();
DocSet::iterator docEnd = expected.end();
diff --git a/searchlib/src/vespa/searchlib/attribute/diversity.h b/searchlib/src/vespa/searchlib/attribute/diversity.h
index da5df19f9e8..e42ad04ceb6 100644
--- a/searchlib/src/vespa/searchlib/attribute/diversity.h
+++ b/searchlib/src/vespa/searchlib/attribute/diversity.h
@@ -4,6 +4,7 @@
#include <vespa/searchcommon/attribute/iattributevector.h>
#include <vespa/searchlib/queryeval/idiversifier.h>
+#include <vespa/vespalib/datastore/entryref.h>
/**
* This file contains low-level code used to implement diversified
@@ -99,7 +100,7 @@ void diversify_2(const DictRange &range_in, const PostingStore &posting, Diversi
using KeyDataType = typename PostingStore::KeyDataType;
while (range.has_next() && (result.size() < filter.getMaxTotal())) {
typename DictRange::Next dict_entry(range);
- posting.foreach_frozen(dict_entry.get().getData(),
+ posting.foreach_frozen(datastore::EntryRef(dict_entry.get().getData()),
[&](uint32_t key, const DataType &data)
{ recorder.push_back(KeyDataType(key, data)); });
if (fragments.back() < result.size()) {
diff --git a/searchlib/src/vespa/searchlib/attribute/enum_store_dictionary.cpp b/searchlib/src/vespa/searchlib/attribute/enum_store_dictionary.cpp
index dd58909ac7b..3e85b8021b7 100644
--- a/searchlib/src/vespa/searchlib/attribute/enum_store_dictionary.cpp
+++ b/searchlib/src/vespa/searchlib/attribute/enum_store_dictionary.cpp
@@ -182,16 +182,16 @@ EnumStoreFoldedDictionary::add(const EntryComparator &comp, std::function<EntryR
return UniqueStoreAddResult(it.getKey(), false);
}
EntryRef newRef = insertEntry();
- _dict.insert(it, newRef, EntryRef());
+ _dict.insert(it, newRef, EntryRef().ref());
// Maybe move posting list reference from next entry
++it;
- if (it.valid() && it.getData().valid() && !(*_folded_compare)(newRef, it.getKey())) {
+ if (it.valid() && EntryRef(it.getData()).valid() && !(*_folded_compare)(newRef, it.getKey())) {
EntryRef posting_list_ref(it.getData());
_dict.thaw(it);
- it.writeData(EntryRef());
+ it.writeData(EntryRef().ref());
--it;
assert(it.valid() && it.getKey() == newRef);
- it.writeData(posting_list_ref);
+ it.writeData(posting_list_ref.ref());
}
return UniqueStoreAddResult(newRef, true);
}
@@ -205,9 +205,9 @@ 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() && !it.getData().valid() && !(*_folded_compare)(ref, it.getKey())) {
+ 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);
+ it.writeData(posting_list_ref.ref());
}
}
@@ -219,7 +219,7 @@ template
class btree::BTreeNodeT<IEnumStore::Index, EnumTreeTraits::INTERNAL_SLOTS>;
template
-class btree::BTreeNodeTT<IEnumStore::Index, datastore::EntryRef, btree::NoAggregated, EnumTreeTraits::INTERNAL_SLOTS>;
+class btree::BTreeNodeTT<IEnumStore::Index, uint32_t, btree::NoAggregated, EnumTreeTraits::INTERNAL_SLOTS>;
template
class btree::BTreeNodeTT<IEnumStore::Index, btree::BTreeNoLeafData, btree::NoAggregated, EnumTreeTraits::LEAF_SLOTS>;
@@ -231,20 +231,20 @@ template
class btree::BTreeLeafNode<IEnumStore::Index, btree::BTreeNoLeafData, btree::NoAggregated, EnumTreeTraits::LEAF_SLOTS>;
template
-class btree::BTreeLeafNode<IEnumStore::Index, datastore::EntryRef, btree::NoAggregated, EnumTreeTraits::LEAF_SLOTS>;
+class btree::BTreeLeafNode<IEnumStore::Index, uint32_t, btree::NoAggregated, EnumTreeTraits::LEAF_SLOTS>;
template
class btree::BTreeLeafNodeTemp<IEnumStore::Index, btree::BTreeNoLeafData, btree::NoAggregated, EnumTreeTraits::LEAF_SLOTS>;
template
-class btree::BTreeLeafNodeTemp<IEnumStore::Index, datastore::EntryRef, btree::NoAggregated, EnumTreeTraits::LEAF_SLOTS>;
+class btree::BTreeLeafNodeTemp<IEnumStore::Index, uint32_t, btree::NoAggregated, EnumTreeTraits::LEAF_SLOTS>;
template
class btree::BTreeNodeStore<IEnumStore::Index, btree::BTreeNoLeafData, btree::NoAggregated,
EnumTreeTraits::INTERNAL_SLOTS, EnumTreeTraits::LEAF_SLOTS>;
template
-class btree::BTreeNodeStore<IEnumStore::Index, datastore::EntryRef, btree::NoAggregated,
+class btree::BTreeNodeStore<IEnumStore::Index, uint32_t, btree::NoAggregated,
EnumTreeTraits::INTERNAL_SLOTS, EnumTreeTraits::LEAF_SLOTS>;
template
@@ -252,7 +252,7 @@ class btree::BTreeRoot<IEnumStore::Index, btree::BTreeNoLeafData, btree::NoAggre
const datastore::EntryComparatorWrapper, EnumTreeTraits>;
template
-class btree::BTreeRoot<IEnumStore::Index, datastore::EntryRef, btree::NoAggregated,
+class btree::BTreeRoot<IEnumStore::Index, uint32_t, btree::NoAggregated,
const datastore::EntryComparatorWrapper, EnumTreeTraits>;
template
@@ -260,7 +260,7 @@ class btree::BTreeRootT<IEnumStore::Index, btree::BTreeNoLeafData, btree::NoAggr
const datastore::EntryComparatorWrapper, EnumTreeTraits>;
template
-class btree::BTreeRootT<IEnumStore::Index, datastore::EntryRef, btree::NoAggregated,
+class btree::BTreeRootT<IEnumStore::Index, uint32_t, btree::NoAggregated,
const datastore::EntryComparatorWrapper, EnumTreeTraits>;
template
@@ -268,7 +268,7 @@ class btree::BTreeRootBase<IEnumStore::Index, btree::BTreeNoLeafData, btree::NoA
EnumTreeTraits::INTERNAL_SLOTS, EnumTreeTraits::LEAF_SLOTS>;
template
-class btree::BTreeRootBase<IEnumStore::Index, datastore::EntryRef, btree::NoAggregated,
+class btree::BTreeRootBase<IEnumStore::Index, uint32_t, btree::NoAggregated,
EnumTreeTraits::INTERNAL_SLOTS, EnumTreeTraits::LEAF_SLOTS>;
template
@@ -276,34 +276,34 @@ class btree::BTreeNodeAllocator<IEnumStore::Index, btree::BTreeNoLeafData, btree
EnumTreeTraits::INTERNAL_SLOTS, EnumTreeTraits::LEAF_SLOTS>;
template
-class btree::BTreeNodeAllocator<IEnumStore::Index, datastore::EntryRef, btree::NoAggregated,
+class btree::BTreeNodeAllocator<IEnumStore::Index, uint32_t, btree::NoAggregated,
EnumTreeTraits::INTERNAL_SLOTS, EnumTreeTraits::LEAF_SLOTS>;
template
class btree::BTreeIteratorBase<IEnumStore::Index, btree::BTreeNoLeafData, btree::NoAggregated,
EnumTreeTraits::INTERNAL_SLOTS, EnumTreeTraits::LEAF_SLOTS, EnumTreeTraits::PATH_SIZE>;
template
-class btree::BTreeIteratorBase<IEnumStore::Index, datastore::EntryRef, btree::NoAggregated,
+class btree::BTreeIteratorBase<IEnumStore::Index, uint32_t, btree::NoAggregated,
EnumTreeTraits::INTERNAL_SLOTS, EnumTreeTraits::LEAF_SLOTS, EnumTreeTraits::PATH_SIZE>;
template class btree::BTreeConstIterator<IEnumStore::Index, btree::BTreeNoLeafData, btree::NoAggregated,
const datastore::EntryComparatorWrapper, EnumTreeTraits>;
-template class btree::BTreeConstIterator<IEnumStore::Index, datastore::EntryRef, btree::NoAggregated,
+template class btree::BTreeConstIterator<IEnumStore::Index, uint32_t, btree::NoAggregated,
const datastore::EntryComparatorWrapper, EnumTreeTraits>;
template
class btree::BTreeIterator<IEnumStore::Index, btree::BTreeNoLeafData, btree::NoAggregated,
const datastore::EntryComparatorWrapper, EnumTreeTraits>;
template
-class btree::BTreeIterator<IEnumStore::Index, datastore::EntryRef, btree::NoAggregated,
+class btree::BTreeIterator<IEnumStore::Index, uint32_t, btree::NoAggregated,
const datastore::EntryComparatorWrapper, EnumTreeTraits>;
template
class btree::BTree<IEnumStore::Index, btree::BTreeNoLeafData, btree::NoAggregated,
const datastore::EntryComparatorWrapper, EnumTreeTraits>;
template
-class btree::BTree<IEnumStore::Index, datastore::EntryRef, btree::NoAggregated,
+class btree::BTree<IEnumStore::Index, uint32_t, btree::NoAggregated,
const datastore::EntryComparatorWrapper, EnumTreeTraits>;
}
diff --git a/searchlib/src/vespa/searchlib/attribute/enum_store_dictionary.h b/searchlib/src/vespa/searchlib/attribute/enum_store_dictionary.h
index 291b92fd0f7..05c3366b1d1 100644
--- a/searchlib/src/vespa/searchlib/attribute/enum_store_dictionary.h
+++ b/searchlib/src/vespa/searchlib/attribute/enum_store_dictionary.h
@@ -81,7 +81,7 @@ extern template
class btree::BTreeNodeT<IEnumStore::Index, EnumTreeTraits::INTERNAL_SLOTS>;
extern template
-class btree::BTreeNodeTT<IEnumStore::Index, datastore::EntryRef, btree::NoAggregated, EnumTreeTraits::INTERNAL_SLOTS>;
+class btree::BTreeNodeTT<IEnumStore::Index, uint32_t, btree::NoAggregated, EnumTreeTraits::INTERNAL_SLOTS>;
extern template
class btree::BTreeNodeTT<IEnumStore::Index, btree::BTreeNoLeafData, btree::NoAggregated, EnumTreeTraits::LEAF_SLOTS>;
@@ -93,20 +93,20 @@ extern template
class btree::BTreeLeafNode<IEnumStore::Index, btree::BTreeNoLeafData, btree::NoAggregated, EnumTreeTraits::LEAF_SLOTS>;
extern template
-class btree::BTreeLeafNode<IEnumStore::Index, datastore::EntryRef, btree::NoAggregated, EnumTreeTraits::LEAF_SLOTS>;
+class btree::BTreeLeafNode<IEnumStore::Index, uint32_t, btree::NoAggregated, EnumTreeTraits::LEAF_SLOTS>;
extern template
class btree::BTreeLeafNodeTemp<IEnumStore::Index, btree::BTreeNoLeafData, btree::NoAggregated, EnumTreeTraits::LEAF_SLOTS>;
extern template
-class btree::BTreeLeafNodeTemp<IEnumStore::Index, datastore::EntryRef, btree::NoAggregated, EnumTreeTraits::LEAF_SLOTS>;
+class btree::BTreeLeafNodeTemp<IEnumStore::Index, uint32_t, btree::NoAggregated, EnumTreeTraits::LEAF_SLOTS>;
extern template
class btree::BTreeNodeStore<IEnumStore::Index, btree::BTreeNoLeafData, btree::NoAggregated,
EnumTreeTraits::INTERNAL_SLOTS, EnumTreeTraits::LEAF_SLOTS>;
extern template
-class btree::BTreeNodeStore<IEnumStore::Index, datastore::EntryRef, btree::NoAggregated,
+class btree::BTreeNodeStore<IEnumStore::Index, uint32_t, btree::NoAggregated,
EnumTreeTraits::INTERNAL_SLOTS, EnumTreeTraits::LEAF_SLOTS>;
extern template
@@ -114,7 +114,7 @@ class btree::BTreeRoot<IEnumStore::Index, btree::BTreeNoLeafData, btree::NoAggre
const datastore::EntryComparatorWrapper, EnumTreeTraits>;
extern template
-class btree::BTreeRoot<IEnumStore::Index, datastore::EntryRef, btree::NoAggregated,
+class btree::BTreeRoot<IEnumStore::Index, uint32_t, btree::NoAggregated,
const datastore::EntryComparatorWrapper, EnumTreeTraits>;
extern template
@@ -122,7 +122,7 @@ class btree::BTreeRootT<IEnumStore::Index, btree::BTreeNoLeafData, btree::NoAggr
const datastore::EntryComparatorWrapper, EnumTreeTraits>;
extern template
-class btree::BTreeRootT<IEnumStore::Index, datastore::EntryRef, btree::NoAggregated,
+class btree::BTreeRootT<IEnumStore::Index, uint32_t, btree::NoAggregated,
const datastore::EntryComparatorWrapper, EnumTreeTraits>;
extern template
@@ -130,7 +130,7 @@ class btree::BTreeRootBase<IEnumStore::Index, btree::BTreeNoLeafData, btree::NoA
EnumTreeTraits::INTERNAL_SLOTS, EnumTreeTraits::LEAF_SLOTS>;
extern template
-class btree::BTreeRootBase<IEnumStore::Index, datastore::EntryRef, btree::NoAggregated,
+class btree::BTreeRootBase<IEnumStore::Index, uint32_t, btree::NoAggregated,
EnumTreeTraits::INTERNAL_SLOTS, EnumTreeTraits::LEAF_SLOTS>;
extern template
@@ -138,7 +138,7 @@ class btree::BTreeNodeAllocator<IEnumStore::Index, btree::BTreeNoLeafData, btree
EnumTreeTraits::INTERNAL_SLOTS, EnumTreeTraits::LEAF_SLOTS>;
extern template
-class btree::BTreeNodeAllocator<IEnumStore::Index, datastore::EntryRef, btree::NoAggregated,
+class btree::BTreeNodeAllocator<IEnumStore::Index, uint32_t, btree::NoAggregated,
EnumTreeTraits::INTERNAL_SLOTS, EnumTreeTraits::LEAF_SLOTS>;
@@ -146,27 +146,27 @@ extern template
class btree::BTreeIteratorBase<IEnumStore::Index, btree::BTreeNoLeafData, btree::NoAggregated,
EnumTreeTraits::INTERNAL_SLOTS, EnumTreeTraits::LEAF_SLOTS, EnumTreeTraits::PATH_SIZE>;
extern template
-class btree::BTreeIteratorBase<IEnumStore::Index, datastore::EntryRef, btree::NoAggregated,
+class btree::BTreeIteratorBase<IEnumStore::Index, uint32_t, btree::NoAggregated,
EnumTreeTraits::INTERNAL_SLOTS, EnumTreeTraits::LEAF_SLOTS, EnumTreeTraits::PATH_SIZE>;
extern template class btree::BTreeConstIterator<IEnumStore::Index, btree::BTreeNoLeafData, btree::NoAggregated,
const datastore::EntryComparatorWrapper, EnumTreeTraits>;
-extern template class btree::BTreeConstIterator<IEnumStore::Index, datastore::EntryRef, btree::NoAggregated,
+extern template class btree::BTreeConstIterator<IEnumStore::Index, uint32_t, btree::NoAggregated,
const datastore::EntryComparatorWrapper, EnumTreeTraits>;
extern template
class btree::BTreeIterator<IEnumStore::Index, btree::BTreeNoLeafData, btree::NoAggregated,
const datastore::EntryComparatorWrapper, EnumTreeTraits>;
extern template
-class btree::BTreeIterator<IEnumStore::Index, datastore::EntryRef, btree::NoAggregated,
+class btree::BTreeIterator<IEnumStore::Index, uint32_t, btree::NoAggregated,
const datastore::EntryComparatorWrapper, EnumTreeTraits>;
extern template
class btree::BTree<IEnumStore::Index, btree::BTreeNoLeafData, btree::NoAggregated,
const datastore::EntryComparatorWrapper, EnumTreeTraits>;
extern template
-class btree::BTree<IEnumStore::Index, datastore::EntryRef, btree::NoAggregated,
+class btree::BTree<IEnumStore::Index, uint32_t, btree::NoAggregated,
const datastore::EntryComparatorWrapper, EnumTreeTraits>;
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 72e90da28fa..15b351b7b33 100644
--- a/searchlib/src/vespa/searchlib/attribute/i_enum_store_dictionary.h
+++ b/searchlib/src/vespa/searchlib/attribute/i_enum_store_dictionary.h
@@ -18,7 +18,7 @@ using EnumTree = btree::BTree<IEnumStore::Index, btree::BTreeNoLeafData,
const datastore::EntryComparatorWrapper,
EnumTreeTraits>;
-using EnumPostingTree = btree::BTree<IEnumStore::Index, datastore::EntryRef,
+using EnumPostingTree = btree::BTree<IEnumStore::Index, uint32_t,
btree::NoAggregated,
const datastore::EntryComparatorWrapper,
EnumTreeTraits>;
diff --git a/searchlib/src/vespa/searchlib/attribute/multinumericpostattribute.hpp b/searchlib/src/vespa/searchlib/attribute/multinumericpostattribute.hpp
index fb44b318f30..7a8a2ff132a 100644
--- a/searchlib/src/vespa/searchlib/attribute/multinumericpostattribute.hpp
+++ b/searchlib/src/vespa/searchlib/attribute/multinumericpostattribute.hpp
@@ -97,7 +97,7 @@ MultiValueNumericPostingAttribute<B, M>::DocumentWeightAttributeAdapter::lookup(
dictItr.lower_bound(frozenDictionary.getRoot(), EnumIndex(), comp);
if (dictItr.valid() && !comp(EnumIndex(), dictItr.getKey())) {
- datastore::EntryRef pidx = dictItr.getData();
+ datastore::EntryRef pidx(dictItr.getData());
if (pidx.valid()) {
const PostingList &plist = self.getPostingList();
auto minmax = plist.getAggregated(pidx);
diff --git a/searchlib/src/vespa/searchlib/attribute/multistringpostattribute.hpp b/searchlib/src/vespa/searchlib/attribute/multistringpostattribute.hpp
index 0e75ea8e061..297261877d9 100644
--- a/searchlib/src/vespa/searchlib/attribute/multistringpostattribute.hpp
+++ b/searchlib/src/vespa/searchlib/attribute/multistringpostattribute.hpp
@@ -109,7 +109,7 @@ MultiValueStringPostingAttributeT<B, T>::DocumentWeightAttributeAdapter::lookup(
dictItr.lower_bound(frozenDictionary.getRoot(), EnumIndex(), comp);
if (dictItr.valid() && !comp(EnumIndex(), dictItr.getKey())) {
- datastore::EntryRef pidx = dictItr.getData();
+ datastore::EntryRef pidx(dictItr.getData());
if (pidx.valid()) {
const PostingList &plist = self.getPostingList();
auto minmax = plist.getAggregated(pidx);
diff --git a/searchlib/src/vespa/searchlib/attribute/postinglistattribute.cpp b/searchlib/src/vespa/searchlib/attribute/postinglistattribute.cpp
index a7d001d9fdb..879706dc09d 100644
--- a/searchlib/src/vespa/searchlib/attribute/postinglistattribute.cpp
+++ b/searchlib/src/vespa/searchlib/attribute/postinglistattribute.cpp
@@ -33,14 +33,14 @@ PostingListAttributeBase<P>::clearAllPostings()
auto itr = _dict.begin();
EntryRef prev;
while (itr.valid()) {
- EntryRef ref = itr.getData();
+ EntryRef ref(itr.getData());
if (ref.ref() != prev.ref()) {
if (ref.valid()) {
_postingList.clear(ref);
}
prev = ref;
}
- itr.writeData(EntryRef());
+ itr.writeData(EntryRef().ref());
++itr;
}
_attr.incGeneration(); // Force freeze
@@ -86,7 +86,7 @@ PostingListAttributeBase<P>::handle_load_posting_lists_and_update_enum_store(enu
&postings._removals[0],
&postings._removals[0] +
postings._removals.size());
- posting_itr.writeData(newIndex);
+ posting_itr.writeData(newIndex.ref());
while (posting_itr != itr) {
++posting_itr;
}
@@ -107,7 +107,7 @@ PostingListAttributeBase<P>::handle_load_posting_lists_and_update_enum_store(enu
&postings._additions[0] + postings._additions.size(),
&postings._removals[0],
&postings._removals[0] + postings._removals.size());
- posting_itr.writeData(newIndex);
+ posting_itr.writeData(newIndex.ref());
loader.free_unused_enums();
}
@@ -121,7 +121,7 @@ PostingListAttributeBase<P>::updatePostings(PostingMap &changePost,
EnumIndex idx = elem.first.getEnumIdx();
auto dictItr = _dict.lowerBound(idx, cmp);
assert(dictItr.valid() && dictItr.getKey() == idx);
- EntryRef newPosting = dictItr.getData();
+ EntryRef newPosting(dictItr.getData());
change.removeDups();
_postingList.apply(newPosting,
@@ -131,7 +131,7 @@ PostingListAttributeBase<P>::updatePostings(PostingMap &changePost,
&change._removals[0] + change._removals.size());
_dict.thaw(dictItr);
- dictItr.writeData(newPosting);
+ dictItr.writeData(newPosting.ref());
}
}
@@ -171,7 +171,7 @@ clearPostings(attribute::IAttributeVector::EnumHandle eidx,
auto itr = _dict.lowerBound(er, cmp);
assert(itr.valid());
- EntryRef newPosting = itr.getData();
+ EntryRef newPosting(itr.getData());
assert(newPosting.valid());
_postingList.apply(newPosting,
@@ -182,7 +182,7 @@ clearPostings(attribute::IAttributeVector::EnumHandle eidx,
&postings._removals[0] +
postings._removals.size());
_dict.thaw(itr);
- itr.writeData(newPosting);
+ itr.writeData(newPosting.ref());
}
template <typename P>
diff --git a/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.cpp b/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.cpp
index 70cf5f00edb..812523a3306 100644
--- a/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.cpp
+++ b/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.cpp
@@ -72,7 +72,7 @@ void
PostingListSearchContext::lookupSingle()
{
if (_lowerDictItr.valid()) {
- _pidx = _lowerDictItr.getData();
+ _pidx = datastore::EntryRef(_lowerDictItr.getData());
}
}
diff --git a/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.hpp b/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.hpp
index e2ac4069172..ed6a4a06478 100644
--- a/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.hpp
+++ b/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.hpp
@@ -77,7 +77,7 @@ PostingListSearchContextT<DataT>::countHits() const
size_t sum(0);
for (auto it(_lowerDictItr); it != _upperDictItr; ++it) {
if (useThis(it)) {
- sum += _postingList.frozenSize(it.getData());
+ sum += _postingList.frozenSize(EntryRef(it.getData()));
}
}
return sum;
@@ -90,7 +90,8 @@ PostingListSearchContextT<DataT>::fillArray()
{
for (auto it(_lowerDictItr); it != _upperDictItr; ++it) {
if (useThis(it)) {
- _merger.addToArray(PostingListTraverser<PostingList>(_postingList, it.getData()));
+ _merger.addToArray(PostingListTraverser<PostingList>(_postingList,
+ datastore::EntryRef(it.getData())));
}
}
_merger.merge();
@@ -103,7 +104,8 @@ PostingListSearchContextT<DataT>::fillBitVector()
{
for (auto it(_lowerDictItr); it != _upperDictItr; ++it) {
if (useThis(it)) {
- _merger.addToBitVector(PostingListTraverser<PostingList>(_postingList, it.getData()));
+ _merger.addToBitVector(PostingListTraverser<PostingList>(_postingList,
+ datastore::EntryRef(it.getData())));
}
}
}
@@ -266,7 +268,7 @@ PostingListSearchContextT<DataT>::applyRangeLimit(int rangeLimit)
if (rangeLimit > 0) {
DictionaryConstIterator middle = _lowerDictItr;
for (int n(0); (n < rangeLimit) && (middle != _upperDictItr); ++middle) {
- n += _postingList.frozenSize(middle.getData());
+ n += _postingList.frozenSize(EntryRef(middle.getData()));
}
_upperDictItr = middle;
_uniqueValues = _upperDictItr - _lowerDictItr;
@@ -275,7 +277,7 @@ PostingListSearchContextT<DataT>::applyRangeLimit(int rangeLimit)
DictionaryConstIterator middle = _upperDictItr;
for (int n(0); (n < rangeLimit) && (middle != _lowerDictItr); ) {
--middle;
- n += _postingList.frozenSize(middle.getData());
+ n += _postingList.frozenSize(EntryRef(middle.getData()));
}
_lowerDictItr = middle;
_uniqueValues = _upperDictItr - _lowerDictItr;
diff --git a/searchlib/src/vespa/searchlib/attribute/postingstore.cpp b/searchlib/src/vespa/searchlib/attribute/postingstore.cpp
index 848e4055fdf..9c736a16069 100644
--- a/searchlib/src/vespa/searchlib/attribute/postingstore.cpp
+++ b/searchlib/src/vespa/searchlib/attribute/postingstore.cpp
@@ -125,7 +125,7 @@ PostingStore<DataT>::removeSparseBitVectors()
if (needscan) {
typedef EnumPostingTree::Iterator EnumIterator;
for (EnumIterator dictItr = _dict.begin(); dictItr.valid(); ++dictItr) {
- if (!isBitVector(getTypeId(dictItr.getData())))
+ if (!isBitVector(getTypeId(EntryRef(dictItr.getData()))))
continue;
EntryRef ref(dictItr.getData());
RefType iRef(ref);
@@ -153,7 +153,7 @@ PostingStore<DataT>::removeSparseBitVectors()
}
}
_dict.thaw(dictItr);
- dictItr.writeData(ref);
+ dictItr.writeData(ref.ref());
res = true;
}
}