blob: 163b86ce101c4b908537a5cb1072ec593032f3ab (
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
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "viewresolver.h"
#include <vespa/searchcommon/common/schema.h>
namespace proton::matching {
ViewResolver &
ViewResolver::add(vespalib::stringref view,
vespalib::stringref field)
{
_map[view].push_back(field);
return *this;
}
bool
ViewResolver::resolve(vespalib::stringref view,
std::vector<vespalib::string> &fields) const
{
auto pos = _map.find(view);
if (pos == _map.end()) {
fields.push_back(view);
return false;
}
fields = pos->second;
return true;
}
ViewResolver
ViewResolver::createFromSchema(const search::index::Schema &schema)
{
ViewResolver resolver;
for (uint32_t i = 0; i < schema.getNumFieldSets(); ++i) {
const search::index::Schema::FieldSet &f = schema.getFieldSet(i);
const vespalib::string &view = f.getName();
const std::vector<vespalib::string> &fields = f.getFields();
for (uint32_t j = 0; j < fields.size(); ++j) {
resolver.add(view, fields[j]);
}
}
return resolver;
}
}
|