aboutsummaryrefslogtreecommitdiffstats
path: root/config-model/src/main/java/com/yahoo/schema/parser/ParsedIndex.java
blob: cf70168e8d26c54c8a9f2d239207fc4140ab8d7c (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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.schema.parser;

import com.yahoo.schema.document.HnswIndexParams;
import com.yahoo.schema.document.Stemming;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

/**
 * This class holds the extracted information after parsing an "index"
 * block, using simple data structures as far as possible.  Do not put
 * advanced logic here!
 * @author arnej27959
 **/
class ParsedIndex extends ParsedBlock {

    private Boolean enableBm25 = null;
    private Boolean isPrefix = null;
    private HnswIndexParams hnswParams = null;
    private final List<String> aliases = new ArrayList<>();
    private Stemming stemming = null;
    private Integer arity = null;
    private Long lowerBound = null;
    private Long upperBound = null;
    private Double densePLT = null;
    
    ParsedIndex(String name) {
        super(name, "index");
    }

    Optional<Boolean> getEnableBm25() { return Optional.ofNullable(this.enableBm25); }
    Optional<Boolean> getPrefix() { return Optional.ofNullable(this.isPrefix); }
    Optional<HnswIndexParams> getHnswIndexParams() { return Optional.ofNullable(this.hnswParams); }
    List<String> getAliases() { return List.copyOf(aliases); }
    boolean hasStemming() { return stemming != null; }
    Optional<Stemming> getStemming() { return Optional.ofNullable(stemming); }
    Optional<Integer> getArity() { return Optional.ofNullable(this.arity); }
    Optional<Long> getLowerBound() { return Optional.ofNullable(this.lowerBound); }
    Optional<Long> getUpperBound() { return Optional.ofNullable(this.upperBound); }
    Optional<Double> getDensePostingListThreshold() { return Optional.ofNullable(this.densePLT); }

    void addAlias(String alias) {
        aliases.add(alias);
    }

    void setArity(int arity) {
        this.arity = arity;
    }

    void setDensePostingListThreshold(double threshold) {
        this.densePLT = threshold;
    }

    void setEnableBm25(boolean value) {
        this.enableBm25 = value;
    }

    void setHnswIndexParams(HnswIndexParams params) {
        this.hnswParams = params;
    }

    void setLowerBound(long value) {
        this.lowerBound = value;
    }

    void setPrefix(boolean value) {
        this.isPrefix = value;
    }

    void setStemming(Stemming stemming) {
        this.stemming = stemming;
    }

    void setUpperBound(long value) {
        this.upperBound = value;
    }
}