diff --git a/java/src/main/java/org/rocksdb/CompactRangeOptions.java b/java/src/main/java/org/rocksdb/CompactRangeOptions.java index da023d366..cf5708601 100644 --- a/java/src/main/java/org/rocksdb/CompactRangeOptions.java +++ b/java/src/main/java/org/rocksdb/CompactRangeOptions.java @@ -14,6 +14,7 @@ public class CompactRangeOptions extends RocksObject { private final static byte VALUE_kSkip = 0; private final static byte VALUE_kIfHaveCompactionFilter = 1; private final static byte VALUE_kForce = 2; + private final static byte VALUE_kForceOptimized = 3; // For level based compaction, we can configure if we want to skip/force bottommost level // compaction. The order of this enum MUST follow the C++ layer. See BottommostLevelCompaction in @@ -30,7 +31,12 @@ public class CompactRangeOptions extends RocksObject { /** * Always compact bottommost level */ - kForce(VALUE_kForce); + kForce(VALUE_kForce), + /** + * Always compact bottommost level but in bottommost level avoid + * double-compacting files created in the same compaction + */ + kForceOptimized(VALUE_kForceOptimized); private final byte value; @@ -57,6 +63,8 @@ public class CompactRangeOptions extends RocksObject { case VALUE_kSkip: return kSkip; case VALUE_kIfHaveCompactionFilter: return kIfHaveCompactionFilter; case VALUE_kForce: return kForce; + case VALUE_kForceOptimized: + return kForceOptimized; default: return null; } } diff --git a/java/src/test/java/org/rocksdb/CompactRangeOptionsTest.java b/java/src/test/java/org/rocksdb/CompactRangeOptionsTest.java index 18c187ddb..57bf22b57 100644 --- a/java/src/test/java/org/rocksdb/CompactRangeOptionsTest.java +++ b/java/src/test/java/org/rocksdb/CompactRangeOptionsTest.java @@ -39,6 +39,9 @@ public class CompactRangeOptionsTest { value = BottommostLevelCompaction.kIfHaveCompactionFilter; opt.setBottommostLevelCompaction(value); assertThat(opt.bottommostLevelCompaction()).isEqualTo(value); + value = BottommostLevelCompaction.kForceOptimized; + opt.setBottommostLevelCompaction(value); + assertThat(opt.bottommostLevelCompaction()).isEqualTo(value); } @Test