// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "floatfieldsearcher.h" using search::streaming::QueryTerm; using search::streaming::QueryTermList; namespace vsm { std::unique_ptr FloatFieldSearcher::duplicate() const { return std::make_unique(*this); } std::unique_ptr DoubleFieldSearcher::duplicate() const { return std::make_unique(*this); } template FloatFieldSearcherT::FloatFieldSearcherT(FieldIdT fId) : FieldSearcher(fId), _floatTerm() {} template FloatFieldSearcherT::~FloatFieldSearcherT() {} template void FloatFieldSearcherT::prepare(search::streaming::QueryTermList& qtl, const SharedSearcherBuf& buf, const vsm::FieldPathMapT& field_paths, search::fef::IQueryEnvironment& query_env) { _floatTerm.clear(); FieldSearcher::prepare(qtl, buf, field_paths, query_env); for (auto qt : qtl) { size_t sz(qt->termLen()); if (sz) { auto range = qt->getRange(); _floatTerm.emplace_back(range.low, range.high, range.valid); } } } template void FloatFieldSearcherT::onValue(const document::FieldValue & fv) { for(size_t j=0, jm(_floatTerm.size()); j < jm; j++) { const FloatInfo & ii = _floatTerm[j]; if (ii.valid() && (ii.cmp(fv.getAsDouble()))) { addHit(*_qtl[j], 0); } } set_element_length(1); } template bool FloatFieldSearcherT::FloatInfo::cmp(T key) const { return (_lower <= key) && (key <= _upper); } template class FloatFieldSearcherT; template class FloatFieldSearcherT; }