Merge pull request #639 from cleaton/setMaxTableFileSize
Add JNI interface to set max_table_files_size for FIFO compaction
This commit is contained in:
commit
05e194158c
@ -1134,6 +1134,27 @@ jbyte Java_org_rocksdb_Options_compactionStyle(
|
||||
return reinterpret_cast<rocksdb::Options*>(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<rocksdb::Options*>(jhandle)->compaction_options_fifo.max_table_files_size =
|
||||
static_cast<long>(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<rocksdb::Options*>(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<rocksdb::ColumnFamilyOptions*>(jhandle)->compaction_options_fifo.max_table_files_size =
|
||||
static_cast<long>(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<rocksdb::ColumnFamilyOptions*>(jhandle)->compaction_options_fifo.max_table_files_size;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_rocksdb_ColumnFamilyOptions
|
||||
* Method: numLevels
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -723,4 +723,23 @@ public class ColumnFamilyOptionsTest {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void maxTableFilesSizeFIFO() {
|
||||
ColumnFamilyOptions opt = null;
|
||||
try {
|
||||
opt = new ColumnFamilyOptions();
|
||||
long longValue = rand.nextLong();
|
||||
// Size has to be positive
|
||||
longValue = (longValue < 0) ? -longValue : longValue;
|
||||
longValue = (longValue == 0) ? longValue + 1 : longValue;
|
||||
opt.setMaxTableFilesSizeFIFO(longValue);
|
||||
assertThat(opt.maxTableFilesSizeFIFO()).
|
||||
isEqualTo(longValue);
|
||||
} finally {
|
||||
if (opt != null) {
|
||||
opt.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1108,6 +1108,25 @@ public class OptionsTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void maxTableFilesSizeFIFO() {
|
||||
Options opt = null;
|
||||
try {
|
||||
opt = new Options();
|
||||
long longValue = rand.nextLong();
|
||||
// Size has to be positive
|
||||
longValue = (longValue < 0) ? -longValue : longValue;
|
||||
longValue = (longValue == 0) ? longValue + 1 : longValue;
|
||||
opt.setMaxTableFilesSizeFIFO(longValue);
|
||||
assertThat(opt.maxTableFilesSizeFIFO()).
|
||||
isEqualTo(longValue);
|
||||
} finally {
|
||||
if (opt != null) {
|
||||
opt.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void rateLimiterConfig() {
|
||||
Options options = null;
|
||||
|
Loading…
x
Reference in New Issue
Block a user