// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. /** * @class search::SearchVisitor * * @brief Visitor that applies a search query to visitor data and converts them to a QueryResultCommand */ #pragma once #include "extendableattributes.h" #include "attrvector.hpp" namespace search { template std::unique_ptr SingleExtAttribute::getSearch(QueryTermSimpleUP term, const attribute::SearchContextParams & params) const { (void) term; (void) params; return {}; } template SingleExtAttribute::SingleExtAttribute(const vespalib::string &name) : Super(name, Config(BasicType::fromType(T()), attribute::CollectionType::SINGLE)) {} template bool SingleExtAttribute::addDoc(typename Super::DocId &docId) { docId = this->_data.size(); this->_data.push_back(attribute::getUndefined()); this->incNumDocs(); this->setCommittedDocIdLimit(this->getNumDocs()); return true; } template bool SingleExtAttribute::add(typename AddValueType::Type v, int32_t ) { this->_data.back() = v; return true; } template void SingleExtAttribute::onAddDocs(typename Super::DocId lidLimit) { this->_data.reserve(lidLimit); } template MultiExtAttribute::MultiExtAttribute(const vespalib::string &name, const attribute::CollectionType &ctype) : Super(name, Config(BasicType::fromType(T()), ctype)) { } template std::unique_ptr MultiExtAttribute::getSearch(QueryTermSimpleUP term, const attribute::SearchContextParams & params) const { (void) term; (void) params; return {}; } template MultiExtAttribute::MultiExtAttribute(const vespalib::string &name) : Super(name, Config(BasicType::fromType(static_cast(0)), attribute::CollectionType::ARRAY)) {} template bool MultiExtAttribute::addDoc(typename Super::DocId &docId) { docId = this->_idx.size() - 1; this->_idx.push_back(this->_idx.back()); this->incNumDocs(); this->setCommittedDocIdLimit(this->getNumDocs()); return true; } template bool MultiExtAttribute::add(typename AddValueType::Type v, int32_t) { this->_data.push_back(v); std::vector &idx = this->_idx; idx.back()++; this->checkSetMaxValueCount(idx.back() - idx[idx.size() - 2]); return true; } template void MultiExtAttribute::onAddDocs(uint32_t lidLimit) { this->_data.reserve(lidLimit); } template MultiExtAttribute::~MultiExtAttribute() = default; template WeightedSetExtAttributeBase::WeightedSetExtAttributeBase(const vespalib::string & name) : B(name, attribute::CollectionType::WSET), _weights() {} template WeightedSetExtAttributeBase::~WeightedSetExtAttributeBase() = default; template void WeightedSetExtAttributeBase::addWeight(int32_t w) { _weights.push_back(w); } } // namespace search