blob: 0c8262cd1248d1cf4f899a2779c0e9bded2c2449 (
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
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "attributesconfigscout.h"
#include "attribute_type_matcher.h"
#include <vespa/searchlib/attribute/configconverter.h>
#include <vespa/searchcommon/attribute/config.h>
using search::attribute::ConfigConverter;
namespace proton {
AttributesConfigScout::AttributesConfigScout(const AttributesConfig &live)
: _live(live),
_map()
{
uint32_t i = 0;
for (const auto &attr : live.attribute) {
_map[attr.name] = i;
++i;
}
}
void
AttributesConfigScout::adjust(AttributesConfig::Attribute &attr,
const AttributesConfig::Attribute &liveAttr)
{
attr.enableonlybitvector = liveAttr.enableonlybitvector;
attr.fastsearch = liveAttr.fastsearch;
attr.paged = liveAttr.paged;
// Note: Predicate attributes only handle changes for the dense-posting-list-threshold config.
attr.densepostinglistthreshold = liveAttr.densepostinglistthreshold;
attr.distancemetric = liveAttr.distancemetric;
attr.index = liveAttr.index;
}
void
AttributesConfigScout::adjust(AttributesConfig::Attribute &attr)
{
search::attribute::Config cfg = ConfigConverter::convert(attr);
const auto it = _map.find(attr.name);
if (it != _map.end()) {
const auto &liveAttr = _live.attribute[it->second];
search::attribute::Config liveCfg = ConfigConverter::convert(liveAttr);
AttributeTypeMatcher matching_types;
if (matching_types(cfg, liveCfg)) {
adjust(attr, liveAttr);
}
}
}
std::shared_ptr<AttributesConfigScout::AttributesConfig>
AttributesConfigScout::adjust(const AttributesConfig &config)
{
std::shared_ptr<AttributesConfigBuilder> result =
std::make_shared<AttributesConfigBuilder>(config);
for (auto &attr : result->attribute) {
adjust(attr);
}
return result;
}
} // namespace proton
|