// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once #include "string_direct_posting_store_adapter.h" #include "direct_posting_store_adapter.hpp" namespace search::attribute { template StringDirectPostingStoreAdapter:: StringDirectPostingStoreAdapter(const PostingStoreType& posting_store, const EnumStoreType& enum_store, bool attr_is_filter) : DirectPostingStoreAdapter(posting_store, enum_store, attr_is_filter) { } template StringDirectPostingStoreAdapter::LookupResult StringDirectPostingStoreAdapter:: lookup(const LookupKey& key, vespalib::datastore::EntryRef dictionary_snapshot) const { vespalib::stringref keyAsString = key.asString(); // Assert the unfortunate assumption of the comparators. // Should be lifted once they take the length too. assert(keyAsString.data()[keyAsString.size()] == '\0'); auto comp = this->_enum_store.make_folded_comparator(keyAsString.data()); auto find_result = this->_dict.find_posting_list(comp, dictionary_snapshot); if (find_result.first.valid()) { auto pidx = find_result.second; if (pidx.valid()) { if constexpr (PostingStoreType::AggrCalcType::hasAggregated()) { auto minmax = this->_posting_store.getAggregated(pidx); return LookupResult(pidx, this->_posting_store.frozenSize(pidx), minmax.getMin(), minmax.getMax(), find_result.first); } else { return LookupResult(pidx, this->_posting_store.frozenSize(pidx), 1, 1, find_result.first); } } } return LookupResult(); } template void StringDirectPostingStoreAdapter:: collect_folded(vespalib::datastore::EntryRef enum_idx, vespalib::datastore::EntryRef dictionary_snapshot, const std::function& callback) const { this->_dict.collect_folded(enum_idx, dictionary_snapshot, callback); } template int64_t StringDirectPostingStoreAdapter:: get_integer_value(vespalib::datastore::EntryRef) const noexcept { // This is not supported for string attributes and is never called. abort(); } }