// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once #include "numeric_direct_posting_store_adapter.h" #include "direct_posting_store_adapter.hpp" namespace search::attribute { template NumericDirectPostingStoreAdapter:: NumericDirectPostingStoreAdapter(const PostingStoreType& posting_store, const EnumStoreType& enum_store, bool attr_is_filter) : DirectPostingStoreAdapter(posting_store, enum_store, attr_is_filter) { } template NumericDirectPostingStoreAdapter::LookupResult NumericDirectPostingStoreAdapter:: lookup(const LookupKey& key, vespalib::datastore::EntryRef dictionary_snapshot) const { int64_t int_term; if (!key.asInteger(int_term)) { return LookupResult(); } auto comp = this->_enum_store.make_comparator(int_term); 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 NumericDirectPostingStoreAdapter:: collect_folded(vespalib::datastore::EntryRef enum_idx, vespalib::datastore::EntryRef dictionary_snapshot, const std::function& callback) const { (void) dictionary_snapshot; callback(enum_idx); } template int64_t NumericDirectPostingStoreAdapter:: get_integer_value(vespalib::datastore::EntryRef enum_idx) const noexcept { return this->_enum_store.get_value(enum_idx); } }