// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once #include "getdocsumargs.h" #include #include #include #include #include namespace juniper { class Config; class QueryHandle; class Result; } namespace search { class MatchingElements; class MatchingElementsFields; } namespace search::common { class Location; } namespace search::attribute { class IAttributeContext; class IAttributeVector; } namespace search::docsummary { class GetDocsumsState; class IDocsumEnvironment; class DocsumFieldWriterState; class GetDocsumsStateCallback { public: virtual void fillSummaryFeatures(GetDocsumsState& state) = 0; virtual void fillRankFeatures(GetDocsumsState& state) = 0; virtual std::unique_ptr fill_matching_elements(const MatchingElementsFields &matching_elems_fields) = 0; virtual ~GetDocsumsStateCallback() = default; GetDocsumsStateCallback(const GetDocsumsStateCallback &) = delete; GetDocsumsStateCallback & operator = (const GetDocsumsStateCallback &) = delete; protected: GetDocsumsStateCallback() = default; }; /** * Per-thread memory shared between all docsum field generators. **/ class GetDocsumsState { public: using FeatureSet = vespalib::FeatureSet; const search::attribute::IAttributeVector * getAttribute(size_t index) const { return _attributes[index]; } GetDocsumArgs _args; // from getdocsums request std::vector _docsumbuf; // from getdocsums request GetDocsumsStateCallback &_callback; class DynTeaserState { vespalib::hash_map> _queries; // juniper query representations public: DynTeaserState(); ~DynTeaserState(); std::unique_ptr& get_query(vespalib::stringref field); }; DynTeaserState _dynteaser; std::unique_ptr _attrCtx; std::vector _attributes; private: vespalib::Stash _stash; const QueryNormalization *_normalization; public: // DocsumFieldWriterState instances are owned by _stash std::vector _fieldWriterStates; // used by AbsDistanceDFW std::vector _parsedLocations; void parse_locations(); // used by SummaryFeaturesDFW std::shared_ptr _summaryFeatures; bool _omit_summary_features; // used by RankFeaturesDFW std::shared_ptr _rankFeatures; // Used by AttributeCombinerDFW and MultiAttrDFW when filtering is enabled std::unique_ptr _matching_elements; GetDocsumsState(const GetDocsumsState &) = delete; GetDocsumsState& operator=(const GetDocsumsState &) = delete; explicit GetDocsumsState(GetDocsumsStateCallback &callback); ~GetDocsumsState(); const MatchingElements &get_matching_elements(const MatchingElementsFields &matching_elems_fields); vespalib::Stash& get_stash() noexcept { return _stash; } const QueryNormalization * query_normalization() const { return _normalization; } void query_normalization(const QueryNormalization * normalization) { _normalization = normalization; } }; }