aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib/src/vespa/searchcommon/common/schemaconfigurer.h
blob: 30deb01456c8bbdbf57b2897e4075afcc1b725f9 (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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include <vespa/vespalib/stllike/string.h>

namespace vespa::config::search::internal {
    class InternalIndexschemaType;
    class InternalAttributesType;
}

namespace search::index {

class Schema;

/**
 * Schema class used to give a high-level description of the content
 * of an index.
 **/
class SchemaBuilder
{
public:
    using IndexschemaConfig = const vespa::config::search::internal::InternalIndexschemaType;
    using AttributesConfig = const vespa::config::search::internal::InternalAttributesType;
    /**
     * Build from indexschema config.
     *
     * @param indexCfg IndexschemaConfig to use
     */
    static void build(const IndexschemaConfig &cfg, Schema &schema);
    /**
     * Build from attribute config.
     *
     * @param attributeCfg AttributesConfig to use
     **/
    static void build(const AttributesConfig &cfg, Schema &schema);
};

class SchemaConfigurer
{
private:
    using IndexschemaConfig = SchemaBuilder::IndexschemaConfig;
    using AttributesConfig = SchemaBuilder::AttributesConfig;
    Schema & _schema;
    void configure(const IndexschemaConfig & cfg);
    void configure(const AttributesConfig & cfg);

public:
    /**
     * Load this schema from config using the given config id.
     *
     * @param configId the config id used to retrieve the relevant config.
     **/
    SchemaConfigurer(Schema & schema, const vespalib::string &configId);
};

}