// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once #include "i_enum_store_dictionary.h" #include namespace search { class IEnumStore; /** * Concrete dictionary for an enum store that extends the functionality of a unique store dictionary. */ template class EnumStoreDictionary : public vespalib::datastore::UniqueStoreDictionary { protected: using AtomicEntryRef = IEnumStoreDictionary::AtomicEntryRef; using EntryRef = IEnumStoreDictionary::EntryRef; using EntryRefFilter = IEnumStoreDictionary::EntryRefFilter; using Index = IEnumStoreDictionary::Index; using BTreeDictionaryType = BTreeDictionaryT; using EntryComparator = IEnumStoreDictionary::EntryComparator; private: using EnumVector = IEnumStoreDictionary::EnumVector; using IndexList = IEnumStoreDictionary::IndexList; using IndexVector = IEnumStoreDictionary::IndexVector; using ParentUniqueStoreDictionary = vespalib::datastore::UniqueStoreDictionary; using generation_t = IEnumStoreDictionary::generation_t; protected: using ParentUniqueStoreDictionary::has_btree_dictionary; using ParentUniqueStoreDictionary::has_hash_dictionary; private: IEnumStore& _enumStore; void remove_unused_values(const IndexList& unused, const EntryComparator& cmp); public: EnumStoreDictionary(IEnumStore& enumStore, std::unique_ptr compare); ~EnumStoreDictionary() override; void free_unused_values(const EntryComparator& cmp) override; void free_unused_values(const IndexList& to_remove, const EntryComparator& cmp) override; void remove(const EntryComparator& comp, EntryRef ref) override; bool find_index(const EntryComparator& cmp, Index& idx) const override; bool find_frozen_index(const EntryComparator& cmp, Index& idx) const override; std::vector find_matching_enums(const EntryComparator& cmp) const override; EntryRef get_frozen_root() const override; std::pair find_posting_list(const EntryComparator& cmp, EntryRef root) const override; void collect_folded(Index idx, EntryRef root, const std::function& callback) const override; Index remap_index(Index idx) override; void clear_all_posting_lists(std::function clearer) override; void update_posting_list(Index idx, const EntryComparator& cmp, std::function updater) override; bool normalize_posting_lists(std::function normalize) override; bool normalize_posting_lists(std::function&)> normalize, const EntryRefFilter& filter) override; void foreach_posting_list(std::function&)> callback, const EntryRefFilter& filter) override; const EnumPostingTree& get_posting_dictionary() const override; }; /** * Concrete dictionary for an enum store that extends the * functionality of a unique store dictionary. * * Special handling of value (posting list reference) is added to * ensure that entries with same folded key share a posting list * (e.g. case insensitive search) and posting list reference is found * for the first of these entries. */ class EnumStoreFoldedDictionary : public EnumStoreDictionary { private: std::unique_ptr _folded_compare; public: EnumStoreFoldedDictionary(IEnumStore& enumStore, std::unique_ptr compare, std::unique_ptr folded_compare); ~EnumStoreFoldedDictionary() override; vespalib::datastore::UniqueStoreAddResult add(const EntryComparator& comp, std::function insertEntry) override; void remove(const EntryComparator& comp, EntryRef ref) override; void collect_folded(Index idx, EntryRef root, const std::function& callback) const override; Index remap_index(Index idx) override; }; } namespace vespalib::btree { extern template class BTreeNodeT; extern template class BTreeNodeTT; extern template class BTreeNodeTT; extern template class BTreeInternalNode; extern template class BTreeLeafNode; extern template class BTreeLeafNode; extern template class BTreeLeafNodeTemp; extern template class BTreeLeafNodeTemp; extern template class BTreeNodeStore; extern template class BTreeNodeStore; extern template class BTreeRoot; extern template class BTreeRoot; extern template class BTreeRootT; extern template class BTreeRootT; extern template class BTreeRootBase; extern template class BTreeRootBase; extern template class BTreeNodeAllocator; extern template class BTreeNodeAllocator; extern template class BTreeIteratorBase; extern template class BTreeIteratorBase; extern template class BTreeConstIterator; extern template class BTreeConstIterator; extern template class BTreeIterator; extern template class BTreeIterator; extern template class BTree; extern template class BTree; }