summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--searchlib/src/vespa/searchlib/attribute/enumstore.h18
-rw-r--r--searchlib/src/vespa/searchlib/attribute/enumstore.hpp28
-rw-r--r--vespalib/src/vespa/vespalib/datastore/unique_store.h1
-rw-r--r--vespalib/src/vespa/vespalib/datastore/unique_store.hpp7
4 files changed, 32 insertions, 22 deletions
diff --git a/searchlib/src/vespa/searchlib/attribute/enumstore.h b/searchlib/src/vespa/searchlib/attribute/enumstore.h
index 7c651cbc3b3..c9784678340 100644
--- a/searchlib/src/vespa/searchlib/attribute/enumstore.h
+++ b/searchlib/src/vespa/searchlib/attribute/enumstore.h
@@ -52,7 +52,7 @@ public:
private:
UniqueStoreType _store;
- IEnumStoreDictionary& _dict;
+ IEnumStoreDictionary* _dict;
vespalib::MemoryUsage _cached_values_memory_usage;
vespalib::AddressSpace _cached_values_address_space_usage;
@@ -87,10 +87,10 @@ public:
get_entry_base(idx).set_ref_count(refCount);
}
- uint32_t getNumUniques() const override { return _dict.getNumUniques(); }
+ uint32_t getNumUniques() const override { return _dict->getNumUniques(); }
vespalib::MemoryUsage getValuesMemoryUsage() const override { return _store.get_allocator().get_data_store().getMemoryUsage(); }
- vespalib::MemoryUsage getDictionaryMemoryUsage() const override { return _dict.get_memory_usage(); }
+ vespalib::MemoryUsage getDictionaryMemoryUsage() const override { return _dict->get_memory_usage(); }
vespalib::AddressSpace getAddressSpaceUsage() const;
@@ -99,15 +99,15 @@ public:
ssize_t load_unique_values(const void* src, size_t available, IndexVector& idx) override;
- void fixupRefCounts(const EnumVector &hist) override { _dict.fixupRefCounts(hist); }
+ void fixupRefCounts(const EnumVector &hist) override { _dict->fixupRefCounts(hist); }
void freezeTree() { _store.freeze(); }
- IEnumStoreDictionary &getEnumStoreDict() override { return _dict; }
- const IEnumStoreDictionary &getEnumStoreDict() const override { return _dict; }
- EnumPostingTree &getPostingDictionary() { return _dict.getPostingDictionary(); }
+ IEnumStoreDictionary &getEnumStoreDict() override { return *_dict; }
+ const IEnumStoreDictionary &getEnumStoreDict() const override { return *_dict; }
+ EnumPostingTree &getPostingDictionary() { return _dict->getPostingDictionary(); }
const EnumPostingTree &getPostingDictionary() const {
- return _dict.getPostingDictionary();
+ return _dict->getPostingDictionary();
}
// TODO: Add API for getting compaction count instead.
@@ -153,7 +153,7 @@ public:
};
NonEnumeratedLoader make_non_enumerated_loader() {
- return NonEnumeratedLoader(_store.get_allocator(), _dict);
+ return NonEnumeratedLoader(_store.get_allocator(), *_dict);
}
class BatchUpdater {
diff --git a/searchlib/src/vespa/searchlib/attribute/enumstore.hpp b/searchlib/src/vespa/searchlib/attribute/enumstore.hpp
index 2660ad94e68..8c230457c0e 100644
--- a/searchlib/src/vespa/searchlib/attribute/enumstore.hpp
+++ b/searchlib/src/vespa/searchlib/attribute/enumstore.hpp
@@ -73,14 +73,16 @@ EnumStoreT<EntryType>::load_unique_value(const void* src, size_t available, Inde
template <typename EntryType>
EnumStoreT<EntryType>::EnumStoreT(bool has_postings)
- : _store(make_enum_store_dictionary(*this, has_postings,
- (has_string_type() ?
- std::make_unique<FoldedComparatorType>(_store.get_data_store()) :
- std::unique_ptr<datastore::EntryComparator>()))),
- _dict(static_cast<IEnumStoreDictionary&>(_store.get_dictionary())),
+ : _store(),
+ _dict(),
_cached_values_memory_usage(),
_cached_values_address_space_usage(0, 0, (1ull << 32))
{
+ _store.set_dictionary(make_enum_store_dictionary(*this, has_postings,
+ (has_string_type() ?
+ std::make_unique<FoldedComparatorType>(_store.get_data_store()) :
+ std::unique_ptr<datastore::EntryComparator>())));
+ _dict = static_cast<IEnumStoreDictionary*>(&_store.get_dictionary());
}
template <typename EntryType>
@@ -114,7 +116,7 @@ EnumStoreT<EntryType>::load_unique_values(const void* src, size_t available, Ind
{
ssize_t sz = load_unique_values_internal(src, available, idx);
if (sz >= 0) {
- _dict.build(idx);
+ _dict->build(idx);
}
return sz;
}
@@ -157,7 +159,7 @@ EnumStoreT<EntryType>::findEnum(EntryType value, IEnumStore::EnumHandle &e) cons
{
auto cmp = make_comparator(value);
Index idx;
- if (_dict.findFrozenIndex(cmp, idx)) {
+ if (_dict->findFrozenIndex(cmp, idx)) {
e = idx.ref();
return true;
}
@@ -169,7 +171,7 @@ std::vector<IEnumStore::EnumHandle>
EnumStoreT<EntryType>::findFoldedEnums(EntryType value) const
{
auto cmp = make_folded_comparator(value);
- return _dict.findMatchingEnums(cmp);
+ return _dict->findMatchingEnums(cmp);
}
template <typename EntryType>
@@ -177,7 +179,7 @@ bool
EnumStoreT<EntryType>::findIndex(EntryType value, Index &idx) const
{
auto cmp = make_comparator(value);
- return _dict.findIndex(cmp, idx);
+ return _dict->findIndex(cmp, idx);
}
template <typename EntryType>
@@ -185,7 +187,7 @@ void
EnumStoreT<EntryType>::freeUnusedEnums()
{
auto cmp = make_comparator();
- _dict.freeUnusedEnums(cmp);
+ _dict->freeUnusedEnums(cmp);
}
template <typename EntryType>
@@ -193,7 +195,7 @@ void
EnumStoreT<EntryType>::freeUnusedEnums(const IndexSet& toRemove)
{
auto cmp = make_comparator();
- _dict.freeUnusedEnums(toRemove, cmp);
+ _dict->freeUnusedEnums(toRemove, cmp);
}
template <typename EntryType>
@@ -201,7 +203,7 @@ void
EnumStoreT<EntryType>::addEnum(EntryType value, Index& newIdx)
{
auto cmp = make_comparator(value);
- auto add_result = _dict.add(cmp, [this, &value]() -> EntryRef { return _store.get_allocator().allocate(value); });
+ auto add_result = _dict->add(cmp, [this, &value]() -> EntryRef { return _store.get_allocator().allocate(value); });
newIdx = add_result.ref();
}
@@ -213,7 +215,7 @@ EnumStoreT<EntryType>::update_stat()
_cached_values_memory_usage = store.getMemoryUsage();
_cached_values_address_space_usage = store.getAddressSpaceUsage();
auto retval = _cached_values_memory_usage;
- retval.merge(_dict.get_memory_usage());
+ retval.merge(_dict->get_memory_usage());
return retval;
}
diff --git a/vespalib/src/vespa/vespalib/datastore/unique_store.h b/vespalib/src/vespa/vespalib/datastore/unique_store.h
index cbaa6aa7db0..5758c7e3481 100644
--- a/vespalib/src/vespa/vespalib/datastore/unique_store.h
+++ b/vespalib/src/vespa/vespalib/datastore/unique_store.h
@@ -49,6 +49,7 @@ public:
UniqueStore();
UniqueStore(std::unique_ptr<IUniqueStoreDictionary> dict);
~UniqueStore();
+ void set_dictionary(std::unique_ptr<IUniqueStoreDictionary> dict);
UniqueStoreAddResult add(EntryConstRefType value);
EntryRef find(EntryConstRefType value);
EntryConstRefType get(EntryRef ref) const { return _allocator.get(ref); }
diff --git a/vespalib/src/vespa/vespalib/datastore/unique_store.hpp b/vespalib/src/vespa/vespalib/datastore/unique_store.hpp
index abac2888a34..33830bbe4ab 100644
--- a/vespalib/src/vespa/vespalib/datastore/unique_store.hpp
+++ b/vespalib/src/vespa/vespalib/datastore/unique_store.hpp
@@ -45,6 +45,13 @@ template <typename EntryT, typename RefT, typename Compare, typename Allocator>
UniqueStore<EntryT, RefT, Compare, Allocator>::~UniqueStore() = default;
template <typename EntryT, typename RefT, typename Compare, typename Allocator>
+void
+UniqueStore<EntryT, RefT, Compare, Allocator>::set_dictionary(std::unique_ptr<IUniqueStoreDictionary> dict)
+{
+ _dict = std::move(dict);
+}
+
+template <typename EntryT, typename RefT, typename Compare, typename Allocator>
UniqueStoreAddResult
UniqueStore<EntryT, RefT, Compare, Allocator>::add(EntryConstRefType value)
{