blob: f2b80fa2886203ce50b9861ff2045d3c9db56ced (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
// 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 <vespa/searchlib/common/geo_location_spec.h>
#include <vespa/vespalib/stllike/hash_map.h>
#include <vespa/vespalib/util/featureset.h>
#include <vespa/vespalib/util/stash.h>
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<MatchingElements> 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<uint32_t> _docsumbuf; // from getdocsums request
GetDocsumsStateCallback &_callback;
class DynTeaserState {
vespalib::hash_map<vespalib::string, std::unique_ptr<juniper::QueryHandle>> _queries; // juniper query representations
public:
DynTeaserState();
~DynTeaserState();
std::unique_ptr<juniper::QueryHandle>& get_query(vespalib::stringref field);
};
DynTeaserState _dynteaser;
std::unique_ptr<search::attribute::IAttributeContext> _attrCtx;
std::vector<const search::attribute::IAttributeVector *> _attributes;
private:
vespalib::Stash _stash;
public:
// DocsumFieldWriterState instances are owned by _stash
std::vector<DocsumFieldWriterState*> _fieldWriterStates;
// used by AbsDistanceDFW
std::vector<search::common::GeoLocationSpec> _parsedLocations;
void parse_locations();
// used by SummaryFeaturesDFW
std::shared_ptr<FeatureSet> _summaryFeatures;
bool _summaryFeaturesCached;
bool _omit_summary_features;
// used by RankFeaturesDFW
std::shared_ptr<FeatureSet> _rankFeatures;
// Used by AttributeCombinerDFW and MultiAttrDFW when filtering is enabled
std::unique_ptr<search::MatchingElements> _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; }
};
}
|