aboutsummaryrefslogtreecommitdiffstats
path: root/searchcore/src/vespa/searchcore/proton/attribute/attributesconfigscout.h
blob: b8ca9f5ace63795c3d20ad52f21f2dee017718de (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
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include <vespa/config-attributes.h>

namespace proton {

/**
 * Class to create adjusted attributes config that minimizes the number of
 * proton restarts needed due to config changes.  Grab the portions from
 * live (supposedly future) config that is safe to apply early during
 * initialization and replay.
 */
class AttributesConfigScout
{
public:
    using AttributesConfig = vespa::config::search::AttributesConfig;
    using AttributesConfigBuilder =
        vespa::config::search::AttributesConfigBuilder;

private:
    const AttributesConfig &_live;
    std::map<vespalib::string, uint32_t> _map;
    
    static void
    adjust(AttributesConfig::Attribute &attr,
           const AttributesConfig::Attribute &liveAttr);

    void
    adjust(AttributesConfig::Attribute &attr);

public:
    explicit AttributesConfigScout(const AttributesConfig &live);

    std::shared_ptr<AttributesConfig>
    adjust(const AttributesConfig &config);
};

}