Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
private Long segmentsBytesMax;
private Long segmentsBytesFloor;
private Long minScore;
private Double maxSkewThreshold;
private Double minDeletionRatio;

public static ConsolidationPolicy of(final ConsolidationType type) {
return new ConsolidationPolicy().type(type);
Expand Down Expand Up @@ -69,8 +71,10 @@
* @param segmentsMin The minimum number of segments that will be evaluated as candidates for consolidation.
* (default: 1)
* @return this
* @deprecated from ArangoDB 3.12.7 onwards.
*/
@Deprecated
public ConsolidationPolicy segmentsMin(final Long segmentsMin) {

Check warning on line 77 in core/src/main/java/com/arangodb/entity/arangosearch/ConsolidationPolicy.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Do not forget to remove this deprecated code someday.

See more on https://sonarcloud.io/project/issues?id=arangodb_arangodb-java-driver&issues=AZrabfK9uDLBMMjmbM9Z&open=AZrabfK9uDLBMMjmbM9Z&pullRequest=618
this.segmentsMin = segmentsMin;
return this;
}
Expand All @@ -83,8 +87,10 @@
* @param segmentsMax The maximum number of segments that will be evaluated as candidates for consolidation.
* (default: 10)
* @return this
* @deprecated from ArangoDB 3.12.7 onwards.
*/
@Deprecated
public ConsolidationPolicy segmentsMax(final Long segmentsMax) {

Check warning on line 93 in core/src/main/java/com/arangodb/entity/arangosearch/ConsolidationPolicy.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Do not forget to remove this deprecated code someday.

See more on https://sonarcloud.io/project/issues?id=arangodb_arangodb-java-driver&issues=AZrabfK9uDLBMMjmbM9a&open=AZrabfK9uDLBMMjmbM9a&pullRequest=618
this.segmentsMax = segmentsMax;
return this;
}
Expand All @@ -110,8 +116,10 @@
* @param segmentsBytesFloor Defines the value (in bytes) to treat all smaller segments as equal for consolidation
* selection. (default: 2097152)
* @return this
* @deprecated from ArangoDB 3.12.7 onwards.
*/
@Deprecated
public ConsolidationPolicy segmentsBytesFloor(final Long segmentsBytesFloor) {

Check warning on line 122 in core/src/main/java/com/arangodb/entity/arangosearch/ConsolidationPolicy.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Do not forget to remove this deprecated code someday.

See more on https://sonarcloud.io/project/issues?id=arangodb_arangodb-java-driver&issues=AZrabfK9uDLBMMjmbM9b&open=AZrabfK9uDLBMMjmbM9b&pullRequest=618
this.segmentsBytesFloor = segmentsBytesFloor;
return this;
}
Expand All @@ -123,23 +131,55 @@
/**
* @param minScore Filter out consolidation candidates with a score less than this. (default: 0)
* @return this
* @deprecated from ArangoDB 3.12.7 onwards.
*/
@Deprecated
public ConsolidationPolicy minScore(final Long minScore) {

Check warning on line 137 in core/src/main/java/com/arangodb/entity/arangosearch/ConsolidationPolicy.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Do not forget to remove this deprecated code someday.

See more on https://sonarcloud.io/project/issues?id=arangodb_arangodb-java-driver&issues=AZrabfK9uDLBMMjmbM9c&open=AZrabfK9uDLBMMjmbM9c&pullRequest=618
this.minScore = minScore;
return this;
}

public Double getMaxSkewThreshold() {
return maxSkewThreshold;
}

/**
* @param maxSkewThreshold The maximum allowed skew in segment sizes to allow consolidation.
* (default: 0.4)
* @return this
* @since ArangoDB 3.12.7
*/
public ConsolidationPolicy maxSkewThreshold(final Double maxSkewThreshold) {
this.maxSkewThreshold = maxSkewThreshold;
return this;
}

public Double getMinDeletionRatio() {
return minDeletionRatio;
}

/**
* @param minDeletionRatio The minimum required percentage of total deleted documents in a
* segment (or a group of segments) to execute cleanup on those segments.
* (default: 0.5)
* @return this
* @since ArangoDB 3.12.7
*/
public ConsolidationPolicy minDeletionRatio(final Double minDeletionRatio) {
this.minDeletionRatio = minDeletionRatio;
return this;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ConsolidationPolicy that = (ConsolidationPolicy) o;
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) && Objects.equals(minScore, that.minScore);
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) && Objects.equals(minScore, that.minScore) && Objects.equals(maxSkewThreshold, that.maxSkewThreshold) && Objects.equals(minDeletionRatio, that.minDeletionRatio);
}

@Override
public int hashCode() {
return Objects.hash(type, threshold, segmentsMin, segmentsMax, segmentsBytesMax, segmentsBytesFloor, minScore);
return Objects.hash(type, threshold, segmentsMin, segmentsMax, segmentsBytesMax, segmentsBytesFloor, minScore, maxSkewThreshold, minDeletionRatio);
}

@Override
Expand All @@ -152,6 +192,8 @@
", segmentsBytesMax=" + segmentsBytesMax +
", segmentsBytesFloor=" + segmentsBytesFloor +
", minScore=" + minScore +
", maxSkewThreshold=" + maxSkewThreshold +
", minDeletionRatio=" + minDeletionRatio +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,21 @@ private InvertedIndexOptions createOptions(String analyzerName) {
);
}

ConsolidationPolicy consolidationPolicy;
if (isAtLeastVersion(3, 12, 7)) {
consolidationPolicy = ConsolidationPolicy.of(ConsolidationType.TIER)
.segmentsBytesMax(55555L)
.maxSkewThreshold(0.3)
.minDeletionRatio(0.4);
} else {
consolidationPolicy = ConsolidationPolicy.of(ConsolidationType.TIER)
.segmentsMin(3L)
.segmentsMax(44L)
.segmentsBytesMax(55555L)
.segmentsBytesFloor(666L)
.minScore(77L);
}

return new InvertedIndexOptions()
.name(rndName())
.inBackground(true)
Expand All @@ -104,13 +119,7 @@ private InvertedIndexOptions createOptions(String analyzerName) {
.consolidationIntervalMsec(11L)
.commitIntervalMsec(22L)
.cleanupIntervalStep(33L)
.consolidationPolicy(ConsolidationPolicy.of(ConsolidationType.TIER)
.segmentsMin(3L)
.segmentsMax(44L)
.segmentsBytesMax(55555L)
.segmentsBytesFloor(666L)
.minScore(77L)
)
.consolidationPolicy(consolidationPolicy)
.writebufferIdle(44L)
.writebufferActive(55L)
.writebufferSizeMax(66L)
Expand Down Expand Up @@ -148,7 +157,7 @@ private void assertCorrectIndexEntity(InvertedIndexEntity indexResult, InvertedI
assertThat(indexResult.getPrimaryKeyCache()).isEqualTo(options.getPrimaryKeyCache());

if (isEnterprise() && isAtLeastVersion(3, 12)) {
assertThat(indexResult.getOptimizeTopK()).containsExactlyElementsOf(options.getOptimizeTopK());
assertThat(indexResult.getOptimizeTopK()).containsExactlyElementsOf(options.getOptimizeTopK());
}
}

Expand Down
25 changes: 17 additions & 8 deletions test-functional/src/test/java/com/arangodb/InvertedIndexTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,21 @@ private InvertedIndexOptions createOptions(String analyzerName) {
);
}

ConsolidationPolicy consolidationPolicy;
if (isAtLeastVersion(3, 12, 7)) {
consolidationPolicy = ConsolidationPolicy.of(ConsolidationType.TIER)
.segmentsBytesMax(55555L)
.maxSkewThreshold(0.3)
.minDeletionRatio(0.4);
} else {
consolidationPolicy = ConsolidationPolicy.of(ConsolidationType.TIER)
.segmentsMin(3L)
.segmentsMax(44L)
.segmentsBytesMax(55555L)
.segmentsBytesFloor(666L)
.minScore(77L);
}

return new InvertedIndexOptions()
.name(rndName())
.inBackground(true)
Expand All @@ -103,13 +118,7 @@ private InvertedIndexOptions createOptions(String analyzerName) {
.consolidationIntervalMsec(11L)
.commitIntervalMsec(22L)
.cleanupIntervalStep(33L)
.consolidationPolicy(ConsolidationPolicy.of(ConsolidationType.TIER)
.segmentsMin(3L)
.segmentsMax(44L)
.segmentsBytesMax(55555L)
.segmentsBytesFloor(666L)
.minScore(77L)
)
.consolidationPolicy(consolidationPolicy)
.writebufferIdle(44L)
.writebufferActive(55L)
.writebufferSizeMax(66L)
Expand Down Expand Up @@ -147,7 +156,7 @@ private void assertCorrectIndexEntity(InvertedIndexEntity indexResult, InvertedI
assertThat(indexResult.getPrimaryKeyCache()).isEqualTo(options.getPrimaryKeyCache());

if (isEnterprise() && isAtLeastVersion(3, 12)) {
assertThat(indexResult.getOptimizeTopK()).containsExactlyElementsOf(options.getOptimizeTopK());
assertThat(indexResult.getOptimizeTopK()).containsExactlyElementsOf(options.getOptimizeTopK());
}
}

Expand Down