summaryrefslogtreecommitdiffstats
path: root/streamingvisitors/src/vespa/searchvisitor/indexenvironment.cpp
blob: 538f3efe44ac71e2f49b112dfda046109083b150 (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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#include "indexenvironment.h"

using namespace search::fef;

namespace streaming {

IndexEnvironment::IndexEnvironment(const ITableManager & tableManager) :
    _tableManager(&tableManager),
    _properties(),
    _fields(),
    _fieldNames(),
    _motivation(RANK),
    _rankAttributes(),
    _dumpAttributes()
{
}

IndexEnvironment::IndexEnvironment(const IndexEnvironment &) = default;
IndexEnvironment::IndexEnvironment(IndexEnvironment &&) noexcept = default;
IndexEnvironment::~IndexEnvironment() = default;

bool
IndexEnvironment::addField(const vespalib::string & name, bool isAttribute)
{
    if (getFieldByName(name) != nullptr) {
        return false;
    }
    FieldInfo info(isAttribute ? FieldType::ATTRIBUTE : FieldType::INDEX,
                   FieldInfo::CollectionType::SINGLE, name, _fields.size());
    info.addAttribute(); // we are able to produce needed attributes at query time
    _fields.push_back(info);
    _fieldNames[info.name()] = info.id();
    return true;
}

void
IndexEnvironment::hintAttributeAccess(const string & name) const {
    if (name.empty()) {
        return;
    }
    if (_motivation == RANK) {
        _rankAttributes.insert(name);
    } else {
        _dumpAttributes.insert(name);
    }
}

} // namespace streaming