Skip to content

Commit 87566e2

Browse files
committed
[DE-380] fixed ConsolidationPolicy API
(cherry picked from commit e4c8b5c)
1 parent ace1ef2 commit 87566e2

File tree

4 files changed

+78
-19
lines changed

4 files changed

+78
-19
lines changed

src/main/java/com/arangodb/entity/arangosearch/ConsolidationPolicy.java

+66-17
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@ public final class ConsolidationPolicy {
2929

3030
private ConsolidationType type;
3131
private Double threshold;
32-
private Long segmentThreshold;
32+
private Long segmentsMin;
33+
private Long segmentsMax;
34+
private Long segmentsBytesMax;
35+
private Long segmentsBytesFloor;
36+
3337

3438
public ConsolidationPolicy() {
3539
}
@@ -44,48 +48,93 @@ public ConsolidationPolicy type(final ConsolidationType type) {
4448
}
4549

4650
/**
47-
* @param threshold Select a given segment for "consolidation" if and only if the formula based on type (as
48-
* defined above)
49-
* evaluates to true, valid value range [0.0, 1.0] (default: 0.85)
51+
* @param threshold Select a given segment for "consolidation" if and only if the formula based on type (as defined
52+
* above) evaluates to true, valid value range [0.0, 1.0] (default: 0.85)
53+
* @param threshold Defines threshold value of [0.0, 1.0] possible range. Consolidation is performed on segments
54+
* which accumulated size in bytes is less than all segments’ byte size multiplied by the
55+
* threshold; i.e. the following formula is applied for each segment: {threshold} > (segment_bytes
56+
* + sum_of_merge_candidate_segment_bytes) / all_segment_bytes. (default: 0.1)
5057
* @return policy
58+
* @return this
5159
*/
5260
public ConsolidationPolicy threshold(final Double threshold) {
5361
this.threshold = threshold;
5462
return this;
5563
}
5664

65+
public ConsolidationType getType() {
66+
return type;
67+
}
68+
69+
public Double getThreshold() {
70+
return threshold;
71+
}
72+
73+
public Long getSegmentsMin() {
74+
return segmentsMin;
75+
}
76+
5777
/**
58-
* @param segmentThreshold Apply the "consolidation" operation if and only if (default: 300): {segmentThreshold} <
59-
* number_of_segments
60-
* @return policy
78+
* @param segmentsMin The minimum number of segments that will be evaluated as candidates for consolidation.
79+
* (default: 1)
80+
* @return this
6181
*/
62-
public ConsolidationPolicy segmentThreshold(final Long segmentThreshold) {
63-
this.segmentThreshold = segmentThreshold;
82+
public ConsolidationPolicy segmentsMin(final Long segmentsMin) {
83+
this.segmentsMin = segmentsMin;
6484
return this;
6585
}
6686

67-
public ConsolidationType getType() {
68-
return type;
87+
public Long getSegmentsMax() {
88+
return segmentsMax;
6989
}
7090

71-
public Double getThreshold() {
72-
return threshold;
91+
/**
92+
* @param segmentsMax The maximum number of segments that will be evaluated as candidates for consolidation.
93+
* (default: 10)
94+
* @return this
95+
*/
96+
public ConsolidationPolicy segmentsMax(final Long segmentsMax) {
97+
this.segmentsMax = segmentsMax;
98+
return this;
99+
}
100+
101+
public Long getSegmentsBytesMax() {
102+
return segmentsBytesMax;
73103
}
74104

75-
public Long getSegmentThreshold() {
76-
return segmentThreshold;
105+
/**
106+
* @param segmentsBytesMax Maximum allowed size of all consolidated segments in bytes. (default: 5368709120)
107+
* @return this
108+
*/
109+
public ConsolidationPolicy segmentsBytesMax(final Long segmentsBytesMax) {
110+
this.segmentsBytesMax = segmentsBytesMax;
111+
return this;
112+
}
113+
114+
public Long getSegmentsBytesFloor() {
115+
return segmentsBytesFloor;
116+
}
117+
118+
/**
119+
* @param segmentsBytesFloor Defines the value (in bytes) to treat all smaller segments as equal for consolidation
120+
* selection. (default: 2097152)
121+
* @return this
122+
*/
123+
public ConsolidationPolicy segmentsBytesFloor(final Long segmentsBytesFloor) {
124+
this.segmentsBytesFloor = segmentsBytesFloor;
125+
return this;
77126
}
78127

79128
@Override
80129
public boolean equals(Object o) {
81130
if (this == o) return true;
82131
if (o == null || getClass() != o.getClass()) return false;
83132
ConsolidationPolicy that = (ConsolidationPolicy) o;
84-
return type == that.type && Objects.equals(threshold, that.threshold) && Objects.equals(segmentThreshold, that.segmentThreshold);
133+
return type == that.type && Objects.equals(threshold, that.threshold) && Objects.equals(segmentsMin, that.segmentsMin) && Objects.equals(segmentsMax, that.segmentsMax) && Objects.equals(segmentsBytesMax, that.segmentsBytesMax) && Objects.equals(segmentsBytesFloor, that.segmentsBytesFloor);
85134
}
86135

87136
@Override
88137
public int hashCode() {
89-
return Objects.hash(type, threshold, segmentThreshold);
138+
return Objects.hash(type, threshold, segmentsMin, segmentsMax, segmentsBytesMax, segmentsBytesFloor);
90139
}
91140
}

src/main/java/com/arangodb/entity/arangosearch/ConsolidationType.java

+5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44

55
public enum ConsolidationType {
66

7+
/**
8+
* @deprecated The “bytes_accum” policy type is deprecated and remains in ArangoSearch for backwards compatibility
9+
* with the older versions. Please make sure to always use the “tier” policy instead.
10+
*/
11+
@Deprecated
712
@JsonProperty("bytes_accum")
813
BYTES_ACCUM,
914

src/test/java/com/arangodb/InvertedIndexTest.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,12 @@ private InvertedIndexOptions createOptions(String analyzerName) {
9898
.consolidationIntervalMsec(11L)
9999
.commitIntervalMsec(22L)
100100
.cleanupIntervalStep(33L)
101-
.consolidationPolicy(ConsolidationPolicy.of(ConsolidationType.BYTES_ACCUM).threshold(1.))
101+
.consolidationPolicy(ConsolidationPolicy.of(ConsolidationType.TIER)
102+
.segmentsMin(3L)
103+
.segmentsMax(44L)
104+
.segmentsBytesMax(55555L)
105+
.segmentsBytesFloor(666L)
106+
)
102107
.writebufferIdle(44L)
103108
.writebufferActive(55L)
104109
.writebufferSizeMax(66L);

src/test/resources/logback-test.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
</encoder>
99
</appender>
1010

11-
<root level="debug">
11+
<root level="info">
1212
<appender-ref ref="STDOUT"/>
1313
</root>
1414

0 commit comments

Comments
 (0)