blob: efd5c93d267ed7a81f700c2fdc5242b84ee5ec6c (
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
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include "attribute_access_recorder.h"
#include "indexenvironment.h"
#include <vespa/searchlib/attribute/iattributemanager.h>
#include <vespa/searchlib/fef/iindexenvironment.h>
#include <vespa/searchlib/fef/iqueryenvironment.h>
#include <vespa/searchlib/fef/properties.h>
namespace streaming {
/**
* Implementation of the feature execution framework
* query environment API for the search visitor.
**/
class QueryEnvironment : public search::fef::IQueryEnvironment
{
private:
const IndexEnvironment &_indexEnv;
const search::fef::Properties &_properties;
std::unique_ptr<AttributeAccessRecorder> _attrCtx;
std::vector<const search::fef::ITermData *> _queryTerms;
std::vector<search::common::GeoLocationSpec> _locations;
public:
using UP = std::unique_ptr<QueryEnvironment>;
QueryEnvironment(const vespalib::string & location,
const IndexEnvironment & indexEnv,
const search::fef::Properties & properties,
const search::IAttributeManager * attrMgr = nullptr);
~QueryEnvironment();
void addGeoLocation(const vespalib::string &field, const vespalib::string &location);
// inherit documentation
virtual const search::fef::Properties & getProperties() const override { return _properties; }
// inherit documentation
virtual uint32_t getNumTerms() const override { return _queryTerms.size(); }
// inherit documentation
virtual const search::fef::ITermData *getTerm(uint32_t idx) const override {
if (idx >= _queryTerms.size()) {
return nullptr;
}
return _queryTerms[idx];
}
// inherit documentation
GeoLocationSpecPtrs getAllLocations() const override;
// inherit documentation
virtual const search::attribute::IAttributeContext & getAttributeContext() const override { return *_attrCtx; }
double get_average_field_length(const vespalib::string &) const override { return 100.0; }
// inherit documentation
virtual const search::fef::IIndexEnvironment & getIndexEnvironment() const override { return _indexEnv; }
void addTerm(const search::fef::ITermData *term) { _queryTerms.push_back(term); }
std::vector<vespalib::string> get_accessed_attributes() const { return _attrCtx->get_accessed_attributes(); }
};
} // namespace streaming
|