blob: 8563d414c40b7e4429a09c65ee01201a92963dbd (
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
80
81
82
83
84
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.schema.document;
import java.util.Optional;
import java.util.OptionalDouble;
import java.util.OptionalInt;
import java.util.OptionalLong;
/**
* Encapsulates values required for predicate fields.
*
* @author lesters
*/
public final class BooleanIndexDefinition {
public static final int DEFAULT_ARITY = 8;
public static final long DEFAULT_UPPER_BOUND = Long.MAX_VALUE;
public static final long DEFAULT_LOWER_BOUND = Long.MIN_VALUE;
public static final double DEFAULT_DENSE_POSTING_LIST_THRESHOLD = 0.4;
private final OptionalInt arity; // mandatory field value
private final OptionalLong lowerBound;
private final OptionalLong upperBound;
private final OptionalDouble densePostingListThreshold;
public BooleanIndexDefinition(Optional<Integer> arity,
Optional<Long> lowerBound,
Optional<Long> upperBound,
Optional<Double> densePLT)
{
this.arity = arity.isPresent() ? OptionalInt.of(arity.get()) : OptionalInt.empty();
this.lowerBound = lowerBound.isPresent() ? OptionalLong.of(lowerBound.get()) : OptionalLong.empty();
this.upperBound = upperBound.isPresent() ? OptionalLong.of(upperBound.get()) : OptionalLong.empty();
this.densePostingListThreshold = densePLT.isPresent() ? OptionalDouble.of(densePLT.get()) : OptionalDouble.empty();
}
public BooleanIndexDefinition(OptionalInt arity, OptionalLong lowerBound,
OptionalLong upperBound, OptionalDouble densePostingListThreshold) {
this.arity = arity;
this.lowerBound = lowerBound;
this.upperBound = upperBound;
this.densePostingListThreshold = densePostingListThreshold;
}
public int getArity() {
return arity.getAsInt();
}
public boolean hasArity() {
return arity.isPresent();
}
public long getLowerBound() {
return lowerBound.orElse(DEFAULT_LOWER_BOUND);
}
public boolean hasLowerBound() {
return lowerBound.isPresent();
}
public long getUpperBound() {
return upperBound.orElse(DEFAULT_UPPER_BOUND);
}
public boolean hasUpperBound() {
return upperBound.isPresent();
}
public double getDensePostingListThreshold() {
return densePostingListThreshold.orElse(DEFAULT_DENSE_POSTING_LIST_THRESHOLD);
}
public boolean hasDensePostingListThreshold() {
return densePostingListThreshold.isPresent();
}
@Override
public String toString() {
return "BooleanIndexDefinition [arity=" + arity + ", lowerBound="
+ lowerBound + ", upperBound=" + upperBound + ", densePostingListThreshold="
+ densePostingListThreshold + "]";
}
}
|