// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once #include "numeric_search_context.h" #include #include namespace search::attribute { /* * SingleNumericSearchContext handles the creation of search iterators for * a query term on a single value numeric attribute vector. */ template class SingleNumericSearchContext final : public NumericSearchContext { private: using DocId = ISearchContext::DocId; vespalib::ConstArrayRef _data; int32_t onFind(DocId docId, int32_t elemId, int32_t& weight) const override { return find(docId, elemId, weight); } int32_t onFind(DocId docId, int elemId) const override { return find(docId, elemId); } public: SingleNumericSearchContext(std::unique_ptr qTerm, const AttributeVector& toBeSearched, vespalib::ConstArrayRef data); int32_t find(DocId docId, int32_t elemId, int32_t& weight) const { if ( elemId != 0) return -1; const T v = vespalib::atomic::load_ref_relaxed(_data[docId]); weight = 1; return this->match(v) ? 0 : -1; } int32_t find(DocId docId, int elemId) const { if ( elemId != 0) return -1; const T v = vespalib::atomic::load_ref_relaxed(_data[docId]); return this->match(v) ? 0 : -1; } std::unique_ptr createFilterIterator(fef::TermFieldMatchData* matchData, bool strict) override; uint32_t get_committed_docid_limit() const noexcept override; }; }