diff options
author | Tor Egge <Tor.Egge@broadpark.no> | 2021-03-19 15:31:24 +0100 |
---|---|---|
committer | Tor Egge <Tor.Egge@broadpark.no> | 2021-03-19 15:31:24 +0100 |
commit | 629103b29e0fdc91091e9e1ac9413834dbf76a7d (patch) | |
tree | fc7f3342344c0640491797a08b745473d6f6aba2 | |
parent | a1b489dec69b08017e3b30913f34e51ff262abd6 (diff) |
Perform simple lookup in unordered dictionary when available.
-rw-r--r-- | searchlib/src/vespa/searchlib/attribute/enum_store_dictionary.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/searchlib/src/vespa/searchlib/attribute/enum_store_dictionary.cpp b/searchlib/src/vespa/searchlib/attribute/enum_store_dictionary.cpp index 6605c7ad704..1676020b417 100644 --- a/searchlib/src/vespa/searchlib/attribute/enum_store_dictionary.cpp +++ b/searchlib/src/vespa/searchlib/attribute/enum_store_dictionary.cpp @@ -113,6 +113,14 @@ bool EnumStoreDictionary<DictionaryT, UnorderedDictionaryT>::find_frozen_index(const vespalib::datastore::EntryComparator& cmp, Index& idx) const { + if constexpr (has_unordered_dictionary) { + auto find_result = this->_unordered_dict.find(cmp, EntryRef()); + if (find_result != nullptr) { + idx = find_result->first.load_acquire(); + return true; + } + return false; + } auto itr = this->_dict.getFrozenView().find(Index(), cmp); if (!itr.valid()) { return false; @@ -152,6 +160,13 @@ template <typename DictionaryT, typename UnorderedDictionaryT> std::pair<IEnumStore::Index, EntryRef> EnumStoreDictionary<DictionaryT, UnorderedDictionaryT>::find_posting_list(const vespalib::datastore::EntryComparator& cmp, EntryRef root) const { + if constexpr (has_unordered_dictionary) { + auto find_result = this->_unordered_dict.find(cmp, EntryRef()); + if (find_result != nullptr) { + return std::make_pair(find_result->first.load_acquire(), find_result->second.load_acquire()); + } + return std::make_pair(Index(), EntryRef()); + } typename DictionaryType::ConstIterator itr(vespalib::btree::BTreeNode::Ref(), this->_dict.getAllocator()); itr.lower_bound(root, Index(), cmp); if (itr.valid() && !cmp.less(Index(), itr.getKey())) { |