aboutsummaryrefslogtreecommitdiffstats
path: root/searchcore/src/vespa/searchcore/proton/matching/queryenvironment.cpp
blob: b6b0d9d1ca93ac9258ef90fbad17600527a85c93 (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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#include "queryenvironment.h"
#include <vespa/searchlib/index/i_field_length_inspector.h>

using search::attribute::IAttributeContext;
using search::fef::IIndexEnvironment;
using search::fef::Properties;

namespace proton::matching {

QueryEnvironment::QueryEnvironment(const IIndexEnvironment &indexEnv,
                                   const IAttributeContext &attrContext,
                                   const Properties &properties,
                                   const search::index::IFieldLengthInspector &field_length_inspector)
    : _indexEnv(indexEnv),
      _attrContext(attrContext),
      _properties(properties),
      _locations(),
      _terms(),
      _field_length_inspector(field_length_inspector)
{
}

const search::fef::Properties &
QueryEnvironment::getProperties() const
{
    return _properties;
}

uint32_t
QueryEnvironment::getNumTerms() const
{
    return _terms.size();
}

const search::fef::ITermData *
QueryEnvironment::getTerm(uint32_t idx) const
{
    if (idx >= _terms.size()) {
        return nullptr;
    }
    return _terms[idx];
}

const IAttributeContext &
QueryEnvironment::getAttributeContext() const
{
    return _attrContext;
}

double
QueryEnvironment::get_average_field_length(const vespalib::string &field_name) const
{
    return _field_length_inspector.get_field_length_info(field_name).get_average_field_length();
}

const search::fef::IIndexEnvironment &
QueryEnvironment::getIndexEnvironment() const
{
    return _indexEnv;
}

QueryEnvironment::~QueryEnvironment() = default;

}