diff options
author | Geir Storli <geirst@verizonmedia.com> | 2019-09-10 07:43:49 +0000 |
---|---|---|
committer | Geir Storli <geirst@verizonmedia.com> | 2019-09-10 07:43:49 +0000 |
commit | 85ca293e655aef7cc00833349e37072768d1a071 (patch) | |
tree | 5866d6685457560a0dd69c17a4cd000ac566e7a3 /searchlib | |
parent | 4f3dab0a567010fab1d4629ee7297bf2b8776262 (diff) |
Delay instantiation of enum store dictionary to after unique store is instantiated.
This should ensure that it compiles using clang.
Diffstat (limited to 'searchlib')
-rw-r--r-- | searchlib/src/vespa/searchlib/attribute/enumstore.h | 18 | ||||
-rw-r--r-- | searchlib/src/vespa/searchlib/attribute/enumstore.hpp | 28 |
2 files changed, 24 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; } |