From d62b6ed8385e769fb92f3e27abc34fa3e3a5a929 Mon Sep 17 00:00:00 2001 From: Jesper Lundgren Date: Sat, 20 Jun 2015 16:23:22 +0800 Subject: [PATCH] add setMaxTableFilesSize to JNI interface --- java/rocksjni/options.cc | 42 +++++++++++++++++++ .../java/org/rocksdb/ColumnFamilyOptions.java | 17 ++++++++ .../rocksdb/ColumnFamilyOptionsInterface.java | 21 ++++++++++ java/src/main/java/org/rocksdb/Options.java | 17 ++++++++ 4 files changed, 97 insertions(+) diff --git a/java/rocksjni/options.cc b/java/rocksjni/options.cc index 6f4ee5418..c1d30ee16 100644 --- a/java/rocksjni/options.cc +++ b/java/rocksjni/options.cc @@ -1134,6 +1134,27 @@ jbyte Java_org_rocksdb_Options_compactionStyle( return reinterpret_cast(jhandle)->compaction_style; } +/* + * Class: org_rocksdb_Options + * Method: setMaxTableFilesSizeFIFO + * Signature: (JJ)V + */ +void Java_org_rocksdb_Options_setMaxTableFilesSizeFIFO( + JNIEnv* env, jobject jobj, jlong jhandle, jlong jmax_table_files_size) { + reinterpret_cast(jhandle)->compaction_options_fifo.max_table_files_size = + static_cast(jmax_table_files_size); +} + +/* + * Class: org_rocksdb_Options + * Method: maxTableFilesSizeFIFO + * Signature: (J)J + */ +jlong Java_org_rocksdb_Options_maxTableFilesSizeFIFO( + JNIEnv* env, jobject jobj, jlong jhandle) { + return reinterpret_cast(jhandle)->compaction_options_fifo.max_table_files_size; +} + /* * Class: org_rocksdb_Options * Method: numLevels @@ -2271,6 +2292,27 @@ jbyte Java_org_rocksdb_ColumnFamilyOptions_compactionStyle( (jhandle)->compaction_style; } +/* + * Class: org_rocksdb_ColumnFamilyOptions + * Method: setMaxTableFilesSizeFIFO + * Signature: (JJ)V + */ +void Java_org_rocksdb_ColumnFamilyOptions_setMaxTableFilesSizeFIFO( + JNIEnv* env, jobject jobj, jlong jhandle, jlong jmax_table_files_size) { + reinterpret_cast(jhandle)->compaction_options_fifo.max_table_files_size = + static_cast(jmax_table_files_size); +} + +/* + * Class: org_rocksdb_ColumnFamilyOptions + * Method: maxTableFilesSizeFIFO + * Signature: (J)J + */ +jlong Java_org_rocksdb_ColumnFamilyOptions_maxTableFilesSizeFIFO( + JNIEnv* env, jobject jobj, jlong jhandle) { + return reinterpret_cast(jhandle)->compaction_options_fifo.max_table_files_size; +} + /* * Class: org_rocksdb_ColumnFamilyOptions * Method: numLevels diff --git a/java/src/main/java/org/rocksdb/ColumnFamilyOptions.java b/java/src/main/java/org/rocksdb/ColumnFamilyOptions.java index 2686a1a86..c916ccbd8 100644 --- a/java/src/main/java/org/rocksdb/ColumnFamilyOptions.java +++ b/java/src/main/java/org/rocksdb/ColumnFamilyOptions.java @@ -468,6 +468,20 @@ public class ColumnFamilyOptions extends RocksObject return CompactionStyle.values()[compactionStyle(nativeHandle_)]; } + @Override + public ColumnFamilyOptions setMaxTableFilesSizeFIFO( + final long maxTableFilesSize) { + assert(maxTableFilesSize > 0); // unsigned native type + assert(isInitialized()); + setMaxTableFilesSizeFIFO(nativeHandle_, maxTableFilesSize); + return this; + } + + @Override + public long maxTableFilesSizeFIFO() { + return maxTableFilesSizeFIFO(nativeHandle_); + } + @Override public ColumnFamilyOptions setVerifyChecksumsInCompaction( final boolean verifyChecksumsInCompaction) { @@ -740,6 +754,9 @@ public class ColumnFamilyOptions extends RocksObject private native boolean disableAutoCompactions(long handle); private native void setCompactionStyle(long handle, byte compactionStyle); private native byte compactionStyle(long handle); + private native void setMaxTableFilesSizeFIFO( + long handle, long max_table_files_size); + private native long maxTableFilesSizeFIFO(long handle); private native void setPurgeRedundantKvsWhileFlush( long handle, boolean purgeRedundantKvsWhileFlush); private native boolean purgeRedundantKvsWhileFlush(long handle); diff --git a/java/src/main/java/org/rocksdb/ColumnFamilyOptionsInterface.java b/java/src/main/java/org/rocksdb/ColumnFamilyOptionsInterface.java index f174c01fd..5eaef4edd 100644 --- a/java/src/main/java/org/rocksdb/ColumnFamilyOptionsInterface.java +++ b/java/src/main/java/org/rocksdb/ColumnFamilyOptionsInterface.java @@ -837,6 +837,27 @@ public interface ColumnFamilyOptionsInterface { */ CompactionStyle compactionStyle(); + /** + * FIFO compaction option. + * The oldest table file will be deleted + * once the sum of table files reaches this size. + * The default value is 1GB (1 * 1024 * 1024 * 1024). + * + * @param maxTableFilesSize the size limit of the total sum of table files. + * @return the instance of the current Object. + */ + Object setMaxTableFilesSizeFIFO(long maxTableFilesSize); + + /** + * FIFO compaction option. + * The oldest table file will be deleted + * once the sum of table files reaches this size. + * The default value is 1GB (1 * 1024 * 1024 * 1024). + * + * @return the size limit of the total sum of table files. + */ + long maxTableFilesSizeFIFO(); + /** * If true, compaction will verify checksum on every read that happens * as part of compaction diff --git a/java/src/main/java/org/rocksdb/Options.java b/java/src/main/java/org/rocksdb/Options.java index 75e5b1822..fdd7fe903 100644 --- a/java/src/main/java/org/rocksdb/Options.java +++ b/java/src/main/java/org/rocksdb/Options.java @@ -437,6 +437,20 @@ public class Options extends RocksObject return this; } + @Override + public Options setMaxTableFilesSizeFIFO( + final long maxTableFilesSize) { + assert(maxTableFilesSize > 0); // unsigned native type + assert(isInitialized()); + setMaxTableFilesSizeFIFO(nativeHandle_, maxTableFilesSize); + return this; + } + + @Override + public long maxTableFilesSizeFIFO() { + return maxTableFilesSizeFIFO(nativeHandle_); + } + @Override public int tableCacheNumshardbits() { assert(isInitialized()); @@ -1135,6 +1149,9 @@ public class Options extends RocksObject private native void setMaxManifestFileSize( long handle, long maxManifestFileSize); private native long maxManifestFileSize(long handle); + private native void setMaxTableFilesSizeFIFO( + long handle, long maxTableFilesSize); + private native long maxTableFilesSizeFIFO(long handle); private native void setTableCacheNumshardbits( long handle, int tableCacheNumshardbits); private native int tableCacheNumshardbits(long handle);