From 418b36a9bcd3ebb6460be60b77cb56fdda3e0ba6 Mon Sep 17 00:00:00 2001 From: Brendan MacDonell Date: Thu, 25 Aug 2022 13:32:03 -0700 Subject: [PATCH] Support CompactionPri::kRoundRobin in RocksJava (#10572) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: Pretty trivial — this PR just adds the new compaction priority to the Java API. Pull Request resolved: https://github.com/facebook/rocksdb/pull/10572 Reviewed By: hx235 Differential Revision: D39006523 Pulled By: ajkr fbshipit-source-id: ea8d665817e7b05826c397afa41c3abcda81484e --- HISTORY.md | 3 +++ java/rocksjni/portal.h | 4 ++++ java/src/main/java/org/rocksdb/CompactionPriority.java | 10 +++++++++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/HISTORY.md b/HISTORY.md index 78bf8c6c4..e76975a99 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -6,6 +6,9 @@ ### Public API changes * Add `rocksdb_column_family_handle_get_id`, `rocksdb_column_family_handle_get_name` to get name, id of column family in C API +### Java API Changes +* Add CompactionPriority.RoundRobin. + ## 7.6.0 (08/19/2022) ### New Features * Added `prepopulate_blob_cache` to ColumnFamilyOptions. If enabled, prepopulate warm/hot blobs which are already in memory into blob cache at the time of flush. On a flush, the blob that is in memory (in memtables) get flushed to the device. If using Direct IO, additional IO is incurred to read this blob back into memory again, which is avoided by enabling this option. This further helps if the workload exhibits high temporal locality, where most of the reads go to recently written data. This also helps in case of the remote file system since it involves network traffic and higher latencies. diff --git a/java/rocksjni/portal.h b/java/rocksjni/portal.h index b9fde668e..40615e284 100644 --- a/java/rocksjni/portal.h +++ b/java/rocksjni/portal.h @@ -4622,6 +4622,8 @@ class CompactionPriorityJni { return 0x2; case ROCKSDB_NAMESPACE::CompactionPri::kMinOverlappingRatio: return 0x3; + case ROCKSDB_NAMESPACE::CompactionPri::kRoundRobin: + return 0x4; default: return 0x0; // undefined } @@ -4640,6 +4642,8 @@ class CompactionPriorityJni { return ROCKSDB_NAMESPACE::CompactionPri::kOldestSmallestSeqFirst; case 0x3: return ROCKSDB_NAMESPACE::CompactionPri::kMinOverlappingRatio; + case 0x4: + return ROCKSDB_NAMESPACE::CompactionPri::kRoundRobin; default: // undefined/default return ROCKSDB_NAMESPACE::CompactionPri::kByCompensatedSize; diff --git a/java/src/main/java/org/rocksdb/CompactionPriority.java b/java/src/main/java/org/rocksdb/CompactionPriority.java index a4f53cd64..eda05942e 100644 --- a/java/src/main/java/org/rocksdb/CompactionPriority.java +++ b/java/src/main/java/org/rocksdb/CompactionPriority.java @@ -33,7 +33,15 @@ public enum CompactionPriority { * and its size is the smallest. It in many cases can optimize write * amplification. */ - MinOverlappingRatio((byte)0x3); + MinOverlappingRatio((byte)0x3), + + /** + * Keeps a cursor(s) of the successor of the file (key range) was/were + * compacted before, and always picks the next files (key range) in that + * level. The file picking process will cycle through all the files in a + * round-robin manner. + */ + RoundRobin((byte)0x4); private final byte value;