Exposed further Java API options for controlling compaction

This commit is contained in:
Adam Retter 2016-06-14 16:51:56 +01:00 committed by krad
parent d1be594636
commit ebdfe34cc4
6 changed files with 229 additions and 0 deletions

View File

@ -453,6 +453,28 @@ void Java_org_rocksdb_Options_setDeleteObsoleteFilesPeriodMicros(
static_cast<int64_t>(micros); static_cast<int64_t>(micros);
} }
/*
* Class: org_rocksdb_Options
* Method: setBaseBackgroundCompactions
* Signature: (JI)V
*/
void Java_org_rocksdb_Options_setBaseBackgroundCompactions(
JNIEnv* env, jobject jobj, jlong jhandle, jint max) {
reinterpret_cast<rocksdb::Options*>(jhandle)
->base_background_compactions = static_cast<int>(max);
}
/*
* Class: org_rocksdb_Options
* Method: baseBackgroundCompactions
* Signature: (J)I
*/
jint Java_org_rocksdb_Options_baseBackgroundCompactions(
JNIEnv* env, jobject jobj, jlong jhandle) {
return reinterpret_cast<rocksdb::Options*>(jhandle)
->base_background_compactions;
}
/* /*
* Class: org_rocksdb_Options * Class: org_rocksdb_Options
* Method: maxBackgroundCompactions * Method: maxBackgroundCompactions
@ -475,6 +497,28 @@ void Java_org_rocksdb_Options_setMaxBackgroundCompactions(
->max_background_compactions = static_cast<int>(max); ->max_background_compactions = static_cast<int>(max);
} }
/*
* Class: org_rocksdb_Options
* Method: setMaxSubcompactions
* Signature: (JI)V
*/
void Java_org_rocksdb_Options_setMaxSubcompactions(
JNIEnv* env, jobject jobj, jlong jhandle, jint max) {
reinterpret_cast<rocksdb::Options*>(jhandle)
->max_subcompactions = static_cast<int32_t>(max);
}
/*
* Class: org_rocksdb_Options
* Method: maxSubcompactions
* Signature: (J)I
*/
jint Java_org_rocksdb_Options_maxSubcompactions(
JNIEnv* env, jobject jobj, jlong jhandle) {
return reinterpret_cast<rocksdb::Options*>(jhandle)
->max_subcompactions;
}
/* /*
* Class: org_rocksdb_Options * Class: org_rocksdb_Options
* Method: maxBackgroundFlushes * Method: maxBackgroundFlushes
@ -3769,6 +3813,28 @@ jlong Java_org_rocksdb_DBOptions_deleteObsoleteFilesPeriodMicros(
->delete_obsolete_files_period_micros; ->delete_obsolete_files_period_micros;
} }
/*
* Class: org_rocksdb_DBOptions
* Method: setBaseBackgroundCompactions
* Signature: (JI)V
*/
void Java_org_rocksdb_DBOptions_setBaseBackgroundCompactions(
JNIEnv* env, jobject jobj, jlong jhandle, jint max) {
reinterpret_cast<rocksdb::DBOptions*>(jhandle)
->base_background_compactions = static_cast<int>(max);
}
/*
* Class: org_rocksdb_DBOptions
* Method: baseBackgroundCompactions
* Signature: (J)I
*/
jint Java_org_rocksdb_DBOptions_baseBackgroundCompactions(
JNIEnv* env, jobject jobj, jlong jhandle) {
return reinterpret_cast<rocksdb::DBOptions*>(jhandle)
->base_background_compactions;
}
/* /*
* Class: org_rocksdb_DBOptions * Class: org_rocksdb_DBOptions
* Method: setMaxBackgroundCompactions * Method: setMaxBackgroundCompactions
@ -3791,6 +3857,28 @@ jint Java_org_rocksdb_DBOptions_maxBackgroundCompactions(
jhandle)->max_background_compactions; jhandle)->max_background_compactions;
} }
/*
* Class: org_rocksdb_DBOptions
* Method: setMaxSubcompactions
* Signature: (JI)V
*/
void Java_org_rocksdb_DBOptions_setMaxSubcompactions(
JNIEnv* env, jobject jobj, jlong jhandle, jint max) {
reinterpret_cast<rocksdb::DBOptions*>(jhandle)
->max_subcompactions = static_cast<int32_t>(max);
}
/*
* Class: org_rocksdb_DBOptions
* Method: maxSubcompactions
* Signature: (J)I
*/
jint Java_org_rocksdb_DBOptions_maxSubcompactions(
JNIEnv* env, jobject jobj, jlong jhandle) {
return reinterpret_cast<rocksdb::DBOptions*>(jhandle)
->max_subcompactions;
}
/* /*
* Class: org_rocksdb_DBOptions * Class: org_rocksdb_DBOptions
* Method: setMaxBackgroundFlushes * Method: setMaxBackgroundFlushes

View File

@ -283,6 +283,19 @@ public class DBOptions extends RocksObject implements DBOptionsInterface {
return deleteObsoleteFilesPeriodMicros(nativeHandle_); return deleteObsoleteFilesPeriodMicros(nativeHandle_);
} }
@Override
public void setBaseBackgroundCompactions(
final int baseBackgroundCompactions) {
assert(isOwningHandle());
setBaseBackgroundCompactions(nativeHandle_, baseBackgroundCompactions);
}
@Override
public int baseBackgroundCompactions() {
assert(isOwningHandle());
return baseBackgroundCompactions(nativeHandle_);
}
@Override @Override
public DBOptions setMaxBackgroundCompactions( public DBOptions setMaxBackgroundCompactions(
final int maxBackgroundCompactions) { final int maxBackgroundCompactions) {
@ -297,6 +310,18 @@ public class DBOptions extends RocksObject implements DBOptionsInterface {
return maxBackgroundCompactions(nativeHandle_); return maxBackgroundCompactions(nativeHandle_);
} }
@Override
public void setMaxSubcompactions(final int maxSubcompactions) {
assert(isOwningHandle());
setMaxSubcompactions(nativeHandle_, maxSubcompactions);
}
@Override
public int maxSubcompactions() {
assert(isOwningHandle());
return maxSubcompactions(nativeHandle_);
}
@Override @Override
public DBOptions setMaxBackgroundFlushes( public DBOptions setMaxBackgroundFlushes(
final int maxBackgroundFlushes) { final int maxBackgroundFlushes) {
@ -586,9 +611,14 @@ public class DBOptions extends RocksObject implements DBOptionsInterface {
private native void setDeleteObsoleteFilesPeriodMicros( private native void setDeleteObsoleteFilesPeriodMicros(
long handle, long micros); long handle, long micros);
private native long deleteObsoleteFilesPeriodMicros(long handle); private native long deleteObsoleteFilesPeriodMicros(long handle);
private native void setBaseBackgroundCompactions(long handle,
int baseBackgroundCompactions);
private native int baseBackgroundCompactions(long handle);
private native void setMaxBackgroundCompactions( private native void setMaxBackgroundCompactions(
long handle, int maxBackgroundCompactions); long handle, int maxBackgroundCompactions);
private native int maxBackgroundCompactions(long handle); private native int maxBackgroundCompactions(long handle);
private native void setMaxSubcompactions(long handle, int maxSubcompactions);
private native int maxSubcompactions(long handle);
private native void setMaxBackgroundFlushes( private native void setMaxBackgroundFlushes(
long handle, int maxBackgroundFlushes); long handle, int maxBackgroundFlushes);
private native int maxBackgroundFlushes(long handle); private native int maxBackgroundFlushes(long handle);

View File

@ -350,6 +350,25 @@ public interface DBOptionsInterface {
*/ */
long deleteObsoleteFilesPeriodMicros(); long deleteObsoleteFilesPeriodMicros();
/**
* Suggested number of concurrent background compaction jobs, submitted to
* the default LOW priority thread pool.
* Default: 1
*
* @param baseBackgroundCompactions Suggested number of background compaction
* jobs
*/
void setBaseBackgroundCompactions(int baseBackgroundCompactions);
/**
* Suggested number of concurrent background compaction jobs, submitted to
* the default LOW priority thread pool.
* Default: 1
*
* @return Suggested number of background compaction jobs
*/
int baseBackgroundCompactions();
/** /**
* Specifies the maximum number of concurrent background compaction jobs, * Specifies the maximum number of concurrent background compaction jobs,
* submitted to the default LOW priority thread pool. * submitted to the default LOW priority thread pool.
@ -380,6 +399,28 @@ public interface DBOptionsInterface {
*/ */
int maxBackgroundCompactions(); int maxBackgroundCompactions();
/**
* This value represents the maximum number of threads that will
* concurrently perform a compaction job by breaking it into multiple,
* smaller ones that are run simultaneously.
* Default: 1 (i.e. no subcompactions)
*
* @param maxSubcompactions The maximum number of threads that will
* concurrently perform a compaction job
*/
void setMaxSubcompactions(int maxSubcompactions);
/**
* This value represents the maximum number of threads that will
* concurrently perform a compaction job by breaking it into multiple,
* smaller ones that are run simultaneously.
* Default: 1 (i.e. no subcompactions)
*
* @return The maximum number of threads that will concurrently perform a
* compaction job
*/
int maxSubcompactions();
/** /**
* Specifies the maximum number of concurrent background flush jobs. * Specifies the maximum number of concurrent background flush jobs.
* If you're increasing this, also consider increasing number of threads in * If you're increasing this, also consider increasing number of threads in

View File

@ -362,6 +362,19 @@ public class Options extends RocksObject
return new Statistics(statsPtr); return new Statistics(statsPtr);
} }
@Override
public void setBaseBackgroundCompactions(
final int baseBackgroundCompactions) {
assert(isOwningHandle());
setBaseBackgroundCompactions(nativeHandle_, baseBackgroundCompactions);
}
@Override
public int baseBackgroundCompactions() {
assert(isOwningHandle());
return baseBackgroundCompactions(nativeHandle_);
}
@Override @Override
public Options setMaxBackgroundCompactions( public Options setMaxBackgroundCompactions(
final int maxBackgroundCompactions) { final int maxBackgroundCompactions) {
@ -370,6 +383,18 @@ public class Options extends RocksObject
return this; return this;
} }
@Override
public void setMaxSubcompactions(final int maxSubcompactions) {
assert(isOwningHandle());
setMaxSubcompactions(nativeHandle_, maxSubcompactions);
}
@Override
public int maxSubcompactions() {
assert(isOwningHandle());
return maxSubcompactions(nativeHandle_);
}
@Override @Override
public int maxBackgroundFlushes() { public int maxBackgroundFlushes() {
assert(isOwningHandle()); assert(isOwningHandle());
@ -1197,9 +1222,14 @@ public class Options extends RocksObject
private native void setDeleteObsoleteFilesPeriodMicros( private native void setDeleteObsoleteFilesPeriodMicros(
long handle, long micros); long handle, long micros);
private native long deleteObsoleteFilesPeriodMicros(long handle); private native long deleteObsoleteFilesPeriodMicros(long handle);
private native void setBaseBackgroundCompactions(long handle,
int baseBackgroundCompactions);
private native int baseBackgroundCompactions(long handle);
private native void setMaxBackgroundCompactions( private native void setMaxBackgroundCompactions(
long handle, int maxBackgroundCompactions); long handle, int maxBackgroundCompactions);
private native int maxBackgroundCompactions(long handle); private native int maxBackgroundCompactions(long handle);
private native void setMaxSubcompactions(long handle, int maxSubcompactions);
private native int maxSubcompactions(long handle);
private native void setMaxBackgroundFlushes( private native void setMaxBackgroundFlushes(
long handle, int maxBackgroundFlushes); long handle, int maxBackgroundFlushes);
private native int maxBackgroundFlushes(long handle); private native int maxBackgroundFlushes(long handle);

View File

@ -170,6 +170,16 @@ public class DBOptionsTest {
} }
} }
@Test
public void baseBackgroundCompactions() {
try (final DBOptions opt = new DBOptions()) {
final int intValue = rand.nextInt();
opt.setBaseBackgroundCompactions(intValue);
assertThat(opt.baseBackgroundCompactions()).
isEqualTo(intValue);
}
}
@Test @Test
public void maxBackgroundCompactions() { public void maxBackgroundCompactions() {
try(final DBOptions opt = new DBOptions()) { try(final DBOptions opt = new DBOptions()) {
@ -179,6 +189,16 @@ public class DBOptionsTest {
} }
} }
@Test
public void maxSubcompactions() {
try (final DBOptions opt = new DBOptions()) {
final int intValue = rand.nextInt();
opt.setMaxSubcompactions(intValue);
assertThat(opt.maxSubcompactions()).
isEqualTo(intValue);
}
}
@Test @Test
public void maxBackgroundFlushes() { public void maxBackgroundFlushes() {
try(final DBOptions opt = new DBOptions()) { try(final DBOptions opt = new DBOptions()) {

View File

@ -473,6 +473,16 @@ public class OptionsTest {
} }
} }
@Test
public void baseBackgroundCompactions() {
try (final Options opt = new Options()) {
final int intValue = rand.nextInt();
opt.setBaseBackgroundCompactions(intValue);
assertThat(opt.baseBackgroundCompactions()).
isEqualTo(intValue);
}
}
@Test @Test
public void maxBackgroundCompactions() { public void maxBackgroundCompactions() {
try (final Options opt = new Options()) { try (final Options opt = new Options()) {
@ -483,6 +493,16 @@ public class OptionsTest {
} }
} }
@Test
public void maxSubcompactions() {
try (final Options opt = new Options()) {
final int intValue = rand.nextInt();
opt.setMaxSubcompactions(intValue);
assertThat(opt.maxSubcompactions()).
isEqualTo(intValue);
}
}
@Test @Test
public void maxBackgroundFlushes() { public void maxBackgroundFlushes() {
try (final Options opt = new Options()) { try (final Options opt = new Options()) {