Add CompactRangeOptions for Java (#4220)
Summary: Closes https://github.com/facebook/rocksdb/issues/4195 CompactRangeOptions are available the CPP API, but not in the Java API. This PR adds CompactRangeOptions to the Java API and adds an overloaded compactRange() method. See https://github.com/facebook/rocksdb/issues/4195 for the original discussion. This change supports all fields of CompactRangeOptions, including the required enum converters in the JNI portal. Significant changes: - Make CompactRangeOptions available in the compactRange() for Java. - Deprecate other compactRange() methods that have individual option params, like in the CPP code. - Migrate rocksdb_compactrange_helper() to CompactRangeOptions. - Add Java unit tests for CompactRangeOptions. Pull Request resolved: https://github.com/facebook/rocksdb/pull/4220 Differential Revision: D9380007 Pulled By: sagar0 fbshipit-source-id: 6af6c334f221427f1997b33fb24c3986b092fed6main
parent
fa4de6e30f
commit
c7cf981a85
@ -0,0 +1,196 @@ |
|||||||
|
// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
|
||||||
|
// This source code is licensed under both the GPLv2 (found in the
|
||||||
|
// COPYING file in the root directory) and Apache 2.0 License
|
||||||
|
// (found in the LICENSE.Apache file in the root directory).
|
||||||
|
//
|
||||||
|
// This file implements the "bridge" between Java and C++ for
|
||||||
|
// rocksdb::CompactRangeOptions.
|
||||||
|
|
||||||
|
#include <jni.h> |
||||||
|
|
||||||
|
#include "include/org_rocksdb_CompactRangeOptions.h" |
||||||
|
#include "rocksdb/options.h" |
||||||
|
#include "rocksjni/portal.h" |
||||||
|
|
||||||
|
/*
|
||||||
|
* Class: org_rocksdb_CompactRangeOptions |
||||||
|
* Method: newCompactRangeOptions |
||||||
|
* Signature: ()J |
||||||
|
*/ |
||||||
|
jlong Java_org_rocksdb_CompactRangeOptions_newCompactRangeOptions( |
||||||
|
JNIEnv* /*env*/, jclass /*jclazz*/) { |
||||||
|
auto* options = new rocksdb::CompactRangeOptions(); |
||||||
|
return reinterpret_cast<jlong>(options); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Class: org_rocksdb_CompactRangeOptions |
||||||
|
* Method: exclusiveManualCompaction |
||||||
|
* Signature: (J)Z |
||||||
|
*/ |
||||||
|
jboolean Java_org_rocksdb_CompactRangeOptions_exclusiveManualCompaction( |
||||||
|
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle) { |
||||||
|
auto* options = reinterpret_cast<rocksdb::CompactRangeOptions*>(jhandle); |
||||||
|
return static_cast<jboolean>(options->exclusive_manual_compaction); |
||||||
|
} |
||||||
|
|
||||||
|
/*
|
||||||
|
* Class: org_rocksdb_CompactRangeOptions |
||||||
|
* Method: setExclusiveManualCompaction |
||||||
|
* Signature: (JZ)V |
||||||
|
*/ |
||||||
|
void Java_org_rocksdb_CompactRangeOptions_setExclusiveManualCompaction( |
||||||
|
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle, jboolean exclusive_manual_compaction) { |
||||||
|
auto* options = |
||||||
|
reinterpret_cast<rocksdb::CompactRangeOptions*>(jhandle); |
||||||
|
options->exclusive_manual_compaction = static_cast<bool>(exclusive_manual_compaction); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Class: org_rocksdb_CompactRangeOptions |
||||||
|
* Method: bottommostLevelCompaction |
||||||
|
* Signature: (J)I |
||||||
|
*/ |
||||||
|
jint Java_org_rocksdb_CompactRangeOptions_bottommostLevelCompaction( |
||||||
|
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle) { |
||||||
|
auto* options = reinterpret_cast<rocksdb::CompactRangeOptions*>(jhandle); |
||||||
|
return rocksdb::BottommostLevelCompactionJni::toJavaBottommostLevelCompaction( |
||||||
|
options->bottommost_level_compaction); |
||||||
|
} |
||||||
|
|
||||||
|
/*
|
||||||
|
* Class: org_rocksdb_CompactRangeOptions |
||||||
|
* Method: setBottommostLevelCompaction |
||||||
|
* Signature: (JI)V |
||||||
|
*/ |
||||||
|
void Java_org_rocksdb_CompactRangeOptions_setBottommostLevelCompaction( |
||||||
|
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle, |
||||||
|
jint bottommost_level_compaction) { |
||||||
|
auto* options = reinterpret_cast<rocksdb::CompactRangeOptions*>(jhandle); |
||||||
|
options->bottommost_level_compaction = |
||||||
|
rocksdb::BottommostLevelCompactionJni::toCppBottommostLevelCompaction(bottommost_level_compaction); |
||||||
|
} |
||||||
|
|
||||||
|
/*
|
||||||
|
* Class: org_rocksdb_CompactRangeOptions |
||||||
|
* Method: changeLevel |
||||||
|
* Signature: (J)Z |
||||||
|
*/ |
||||||
|
jboolean Java_org_rocksdb_CompactRangeOptions_changeLevel |
||||||
|
(JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle) { |
||||||
|
auto* options = reinterpret_cast<rocksdb::CompactRangeOptions*>(jhandle); |
||||||
|
return static_cast<jboolean>(options->change_level); |
||||||
|
} |
||||||
|
|
||||||
|
/*
|
||||||
|
* Class: org_rocksdb_CompactRangeOptions |
||||||
|
* Method: setChangeLevel |
||||||
|
* Signature: (JZ)V |
||||||
|
*/ |
||||||
|
void Java_org_rocksdb_CompactRangeOptions_setChangeLevel |
||||||
|
(JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle, jboolean change_level) { |
||||||
|
auto* options = reinterpret_cast<rocksdb::CompactRangeOptions*>(jhandle); |
||||||
|
options->change_level = static_cast<bool>(change_level); |
||||||
|
} |
||||||
|
|
||||||
|
/*
|
||||||
|
* Class: org_rocksdb_CompactRangeOptions |
||||||
|
* Method: targetLevel |
||||||
|
* Signature: (J)I |
||||||
|
*/ |
||||||
|
jint Java_org_rocksdb_CompactRangeOptions_targetLevel |
||||||
|
(JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle) { |
||||||
|
auto* options = reinterpret_cast<rocksdb::CompactRangeOptions*>(jhandle); |
||||||
|
return static_cast<jint>(options->target_level); |
||||||
|
} |
||||||
|
|
||||||
|
/*
|
||||||
|
* Class: org_rocksdb_CompactRangeOptions |
||||||
|
* Method: setTargetLevel |
||||||
|
* Signature: (JI)V |
||||||
|
*/ |
||||||
|
void Java_org_rocksdb_CompactRangeOptions_setTargetLevel |
||||||
|
(JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle, jint target_level) { |
||||||
|
auto* options = reinterpret_cast<rocksdb::CompactRangeOptions*>(jhandle); |
||||||
|
options->target_level = static_cast<int>(target_level); |
||||||
|
} |
||||||
|
|
||||||
|
/*
|
||||||
|
* Class: org_rocksdb_CompactRangeOptions |
||||||
|
* Method: targetPathId |
||||||
|
* Signature: (J)I |
||||||
|
*/ |
||||||
|
jint Java_org_rocksdb_CompactRangeOptions_targetPathId |
||||||
|
(JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle) { |
||||||
|
auto* options = reinterpret_cast<rocksdb::CompactRangeOptions*>(jhandle); |
||||||
|
return static_cast<jint>(options->target_path_id); |
||||||
|
} |
||||||
|
|
||||||
|
/*
|
||||||
|
* Class: org_rocksdb_CompactRangeOptions |
||||||
|
* Method: setTargetPathId |
||||||
|
* Signature: (JI)V |
||||||
|
*/ |
||||||
|
void Java_org_rocksdb_CompactRangeOptions_setTargetPathId |
||||||
|
(JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle, jint target_path_id) { |
||||||
|
auto* options = reinterpret_cast<rocksdb::CompactRangeOptions*>(jhandle); |
||||||
|
options->target_path_id = static_cast<uint32_t>(target_path_id); |
||||||
|
} |
||||||
|
|
||||||
|
/*
|
||||||
|
* Class: org_rocksdb_CompactRangeOptions |
||||||
|
* Method: allowWriteStall |
||||||
|
* Signature: (J)Z |
||||||
|
*/ |
||||||
|
jboolean Java_org_rocksdb_CompactRangeOptions_allowWriteStall |
||||||
|
(JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle) { |
||||||
|
auto* options = reinterpret_cast<rocksdb::CompactRangeOptions*>(jhandle); |
||||||
|
return static_cast<jboolean>(options->allow_write_stall); |
||||||
|
} |
||||||
|
|
||||||
|
/*
|
||||||
|
* Class: org_rocksdb_CompactRangeOptions |
||||||
|
* Method: setAllowWriteStall |
||||||
|
* Signature: (JZ)V |
||||||
|
*/ |
||||||
|
void Java_org_rocksdb_CompactRangeOptions_setAllowWriteStall |
||||||
|
(JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle, jboolean allow_write_stall) { |
||||||
|
auto* options = reinterpret_cast<rocksdb::CompactRangeOptions*>(jhandle); |
||||||
|
options->allow_write_stall = static_cast<bool>(allow_write_stall); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Class: org_rocksdb_CompactRangeOptions |
||||||
|
* Method: maxSubcompactions |
||||||
|
* Signature: (J)I |
||||||
|
*/ |
||||||
|
jint Java_org_rocksdb_CompactRangeOptions_maxSubcompactions |
||||||
|
(JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle) { |
||||||
|
auto* options = reinterpret_cast<rocksdb::CompactRangeOptions*>(jhandle); |
||||||
|
return static_cast<jint>(options->max_subcompactions); |
||||||
|
} |
||||||
|
|
||||||
|
/*
|
||||||
|
* Class: org_rocksdb_CompactRangeOptions |
||||||
|
* Method: setMaxSubcompactions |
||||||
|
* Signature: (JI)V |
||||||
|
*/ |
||||||
|
void Java_org_rocksdb_CompactRangeOptions_setMaxSubcompactions |
||||||
|
(JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle, jint max_subcompactions) { |
||||||
|
auto* options = reinterpret_cast<rocksdb::CompactRangeOptions*>(jhandle); |
||||||
|
options->max_subcompactions = static_cast<uint32_t>(max_subcompactions); |
||||||
|
} |
||||||
|
|
||||||
|
/*
|
||||||
|
* Class: org_rocksdb_CompactRangeOptions |
||||||
|
* Method: disposeInternal |
||||||
|
* Signature: (J)V |
||||||
|
*/ |
||||||
|
void Java_org_rocksdb_CompactRangeOptions_disposeInternal( |
||||||
|
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle) { |
||||||
|
auto* options = reinterpret_cast<rocksdb::CompactRangeOptions*>(jhandle); |
||||||
|
delete options; |
||||||
|
} |
@ -0,0 +1,233 @@ |
|||||||
|
// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
|
||||||
|
// This source code is licensed under both the GPLv2 (found in the
|
||||||
|
// COPYING file in the root directory) and Apache 2.0 License
|
||||||
|
// (found in the LICENSE.Apache file in the root directory).
|
||||||
|
|
||||||
|
package org.rocksdb; |
||||||
|
|
||||||
|
/** |
||||||
|
* CompactRangeOptions is used by CompactRange() call. In the documentation of the methods "the compaction" refers to |
||||||
|
* any compaction that is using this CompactRangeOptions. |
||||||
|
*/ |
||||||
|
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; |
||||||
|
|
||||||
|
// For level based compaction, we can configure if we want to skip/force bottommost level compaction.
|
||||||
|
// The order of this neum MUST follow the C++ layer. See BottommostLevelCompaction in db/options.h
|
||||||
|
public enum BottommostLevelCompaction { |
||||||
|
/** |
||||||
|
* Skip bottommost level compaction |
||||||
|
*/ |
||||||
|
kSkip((byte)VALUE_kSkip), |
||||||
|
/** |
||||||
|
* Only compact bottommost level if there is a compaction filter. This is the default option |
||||||
|
*/ |
||||||
|
kIfHaveCompactionFilter(VALUE_kIfHaveCompactionFilter), |
||||||
|
/** |
||||||
|
* Always compact bottommost level |
||||||
|
*/ |
||||||
|
kForce(VALUE_kForce); |
||||||
|
|
||||||
|
private final byte value; |
||||||
|
|
||||||
|
BottommostLevelCompaction(final byte value) { |
||||||
|
this.value = value; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* <p>Returns the byte value of the enumerations value.</p> |
||||||
|
* |
||||||
|
* @return byte representation |
||||||
|
*/ |
||||||
|
public byte getValue() { |
||||||
|
return value; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Returns the BottommostLevelCompaction for the given C++ rocks enum value. |
||||||
|
* @param bottommostLevelCompaction The value of the BottommostLevelCompaction |
||||||
|
* @return BottommostLevelCompaction instance, or null if none matches |
||||||
|
*/ |
||||||
|
public static BottommostLevelCompaction fromRocksId(final int bottommostLevelCompaction) { |
||||||
|
switch (bottommostLevelCompaction) { |
||||||
|
case VALUE_kSkip: return kSkip; |
||||||
|
case VALUE_kIfHaveCompactionFilter: return kIfHaveCompactionFilter; |
||||||
|
case VALUE_kForce: return kForce; |
||||||
|
default: return null; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Construct CompactRangeOptions. |
||||||
|
*/ |
||||||
|
public CompactRangeOptions() { |
||||||
|
super(newCompactRangeOptions()); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Returns whether the compaction is exclusive or other compactions may run concurrently at the same time. |
||||||
|
* |
||||||
|
* @return true if exclusive, false if concurrent |
||||||
|
*/ |
||||||
|
public boolean exclusiveManualCompaction() { |
||||||
|
return exclusiveManualCompaction(nativeHandle_); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Sets whether the compaction is exclusive or other compaction are allowed run concurrently at the same time. |
||||||
|
* |
||||||
|
* @param exclusiveCompaction true if compaction should be exclusive |
||||||
|
* @return This CompactRangeOptions |
||||||
|
*/ |
||||||
|
public CompactRangeOptions setExclusiveManualCompaction(final boolean exclusiveCompaction) { |
||||||
|
setExclusiveManualCompaction(nativeHandle_, exclusiveCompaction); |
||||||
|
return this; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* Returns the policy for compacting the bottommost level |
||||||
|
* @return The BottommostLevelCompaction policy |
||||||
|
*/ |
||||||
|
public BottommostLevelCompaction bottommostLevelCompaction() { |
||||||
|
return BottommostLevelCompaction.fromRocksId(bottommostLevelCompaction(nativeHandle_)); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Sets the policy for compacting the bottommost level |
||||||
|
* |
||||||
|
* @param bottommostLevelCompaction The policy for compacting the bottommost level |
||||||
|
* @return This CompactRangeOptions |
||||||
|
*/ |
||||||
|
public CompactRangeOptions setBottommostLevelCompaction(final BottommostLevelCompaction bottommostLevelCompaction) { |
||||||
|
setBottommostLevelCompaction(nativeHandle_, bottommostLevelCompaction.getValue()); |
||||||
|
return this; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Returns whether compacted files will be moved to the minimum level capable of holding the data or given level |
||||||
|
* (specified non-negative target_level). |
||||||
|
* @return true, if compacted files will be moved to the minimum level |
||||||
|
*/ |
||||||
|
public boolean changeLevel() { |
||||||
|
return changeLevel(nativeHandle_); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Whether compacted files will be moved to the minimum level capable of holding the data or given level |
||||||
|
* (specified non-negative target_level). |
||||||
|
* |
||||||
|
* @param changeLevel If true, compacted files will be moved to the minimum level |
||||||
|
* @return This CompactRangeOptions |
||||||
|
*/ |
||||||
|
public CompactRangeOptions setChangeLevel(final boolean changeLevel) { |
||||||
|
setChangeLevel(nativeHandle_, changeLevel); |
||||||
|
return this; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* If change_level is true and target_level have non-negative value, compacted files will be moved to target_level. |
||||||
|
* @return The target level for the compacted files |
||||||
|
*/ |
||||||
|
public int targetLevel() { |
||||||
|
return targetLevel(nativeHandle_); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* If change_level is true and target_level have non-negative value, compacted files will be moved to target_level. |
||||||
|
* |
||||||
|
* @param targetLevel target level for the compacted files |
||||||
|
* @return This CompactRangeOptions |
||||||
|
*/ |
||||||
|
public CompactRangeOptions setTargetLevel(final int targetLevel) { |
||||||
|
setTargetLevel(nativeHandle_, targetLevel); |
||||||
|
return this; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* target_path_id for compaction output. Compaction outputs will be placed in options.db_paths[target_path_id]. |
||||||
|
* |
||||||
|
* @return target_path_id |
||||||
|
*/ |
||||||
|
public int targetPathId() { |
||||||
|
return targetPathId(nativeHandle_); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Compaction outputs will be placed in options.db_paths[target_path_id]. Behavior is undefined if target_path_id is |
||||||
|
* out of range. |
||||||
|
* |
||||||
|
* @param targetPathId target path id |
||||||
|
* @return This CompactRangeOptions |
||||||
|
*/ |
||||||
|
public CompactRangeOptions setTargetPathId(final int targetPathId) { |
||||||
|
setTargetPathId(nativeHandle_, targetPathId); |
||||||
|
return this; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* If true, compaction will execute immediately even if doing so would cause the DB to |
||||||
|
* enter write stall mode. Otherwise, it'll sleep until load is low enough. |
||||||
|
* @return true if compaction will execute immediately |
||||||
|
*/ |
||||||
|
public boolean allowWriteStall() { |
||||||
|
return allowWriteStall(nativeHandle_); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* If true, compaction will execute immediately even if doing so would cause the DB to |
||||||
|
* enter write stall mode. Otherwise, it'll sleep until load is low enough. |
||||||
|
* |
||||||
|
* @return This CompactRangeOptions |
||||||
|
* @param allowWriteStall true if compaction should execute immediately |
||||||
|
*/ |
||||||
|
public CompactRangeOptions setAllowWriteStall(final boolean allowWriteStall) { |
||||||
|
setAllowWriteStall(nativeHandle_, allowWriteStall); |
||||||
|
return this; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* If > 0, it will replace the option in the DBOptions for this compaction |
||||||
|
* @return number of subcompactions |
||||||
|
*/ |
||||||
|
public int maxSubcompactions() { |
||||||
|
return maxSubcompactions(nativeHandle_); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* If > 0, it will replace the option in the DBOptions for this compaction |
||||||
|
* |
||||||
|
* @param maxSubcompactions number of subcompactions |
||||||
|
* @return This CompactRangeOptions |
||||||
|
*/ |
||||||
|
public CompactRangeOptions setMaxSubcompactions(final int maxSubcompactions) { |
||||||
|
setMaxSubcompactions(nativeHandle_, maxSubcompactions); |
||||||
|
return this; |
||||||
|
} |
||||||
|
|
||||||
|
private native static long newCompactRangeOptions(); |
||||||
|
private native boolean exclusiveManualCompaction(final long handle); |
||||||
|
private native void setExclusiveManualCompaction(final long handle, final boolean exclusive_manual_compaction); |
||||||
|
private native int bottommostLevelCompaction(final long handle); |
||||||
|
private native void setBottommostLevelCompaction(final long handle, final int bottommostLevelCompaction); |
||||||
|
private native boolean changeLevel(final long handle); |
||||||
|
private native void setChangeLevel(final long handle, final boolean changeLevel); |
||||||
|
private native int targetLevel(final long handle); |
||||||
|
private native void setTargetLevel(final long handle, final int targetLevel); |
||||||
|
private native int targetPathId(final long handle); |
||||||
|
private native void setTargetPathId(final long handle, final int /* uint32_t */ targetPathId); |
||||||
|
private native boolean allowWriteStall(final long handle); |
||||||
|
private native void setAllowWriteStall(final long handle, final boolean allowWriteStall); |
||||||
|
private native void setMaxSubcompactions(final long handle, final int /* uint32_t */ maxSubcompactions); |
||||||
|
private native int maxSubcompactions(final long handle); |
||||||
|
|
||||||
|
@Override |
||||||
|
protected final native void disposeInternal(final long handle); |
||||||
|
|
||||||
|
} |
@ -0,0 +1,98 @@ |
|||||||
|
// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
|
||||||
|
// This source code is licensed under both the GPLv2 (found in the
|
||||||
|
// COPYING file in the root directory) and Apache 2.0 License
|
||||||
|
// (found in the LICENSE.Apache file in the root directory).
|
||||||
|
|
||||||
|
package org.rocksdb; |
||||||
|
|
||||||
|
import org.junit.Test; |
||||||
|
import org.rocksdb.CompactRangeOptions.BottommostLevelCompaction; |
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat; |
||||||
|
|
||||||
|
public class CompactRangeOptionsTest { |
||||||
|
|
||||||
|
static { |
||||||
|
RocksDB.loadLibrary(); |
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
public void exclusiveManualCompaction() { |
||||||
|
CompactRangeOptions opt = new CompactRangeOptions(); |
||||||
|
boolean value = false; |
||||||
|
opt.setExclusiveManualCompaction(value); |
||||||
|
assertThat(opt.exclusiveManualCompaction()).isEqualTo(value); |
||||||
|
value = true; |
||||||
|
opt.setExclusiveManualCompaction(value); |
||||||
|
assertThat(opt.exclusiveManualCompaction()).isEqualTo(value); |
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
public void bottommostLevelCompaction() { |
||||||
|
CompactRangeOptions opt = new CompactRangeOptions(); |
||||||
|
BottommostLevelCompaction value = BottommostLevelCompaction.kSkip; |
||||||
|
opt.setBottommostLevelCompaction(value); |
||||||
|
assertThat(opt.bottommostLevelCompaction()).isEqualTo(value); |
||||||
|
value = BottommostLevelCompaction.kForce; |
||||||
|
opt.setBottommostLevelCompaction(value); |
||||||
|
assertThat(opt.bottommostLevelCompaction()).isEqualTo(value); |
||||||
|
value = BottommostLevelCompaction.kIfHaveCompactionFilter; |
||||||
|
opt.setBottommostLevelCompaction(value); |
||||||
|
assertThat(opt.bottommostLevelCompaction()).isEqualTo(value); |
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
public void changeLevel() { |
||||||
|
CompactRangeOptions opt = new CompactRangeOptions(); |
||||||
|
boolean value = false; |
||||||
|
opt.setChangeLevel(value); |
||||||
|
assertThat(opt.changeLevel()).isEqualTo(value); |
||||||
|
value = true; |
||||||
|
opt.setChangeLevel(value); |
||||||
|
assertThat(opt.changeLevel()).isEqualTo(value); |
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
public void targetLevel() { |
||||||
|
CompactRangeOptions opt = new CompactRangeOptions(); |
||||||
|
int value = 2; |
||||||
|
opt.setTargetLevel(value); |
||||||
|
assertThat(opt.targetLevel()).isEqualTo(value); |
||||||
|
value = 3; |
||||||
|
opt.setTargetLevel(value); |
||||||
|
assertThat(opt.targetLevel()).isEqualTo(value); |
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
public void targetPathId() { |
||||||
|
CompactRangeOptions opt = new CompactRangeOptions(); |
||||||
|
int value = 2; |
||||||
|
opt.setTargetPathId(value); |
||||||
|
assertThat(opt.targetPathId()).isEqualTo(value); |
||||||
|
value = 3; |
||||||
|
opt.setTargetPathId(value); |
||||||
|
assertThat(opt.targetPathId()).isEqualTo(value); |
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
public void allowWriteStall() { |
||||||
|
CompactRangeOptions opt = new CompactRangeOptions(); |
||||||
|
boolean value = false; |
||||||
|
opt.setAllowWriteStall(value); |
||||||
|
assertThat(opt.allowWriteStall()).isEqualTo(value); |
||||||
|
value = true; |
||||||
|
opt.setAllowWriteStall(value); |
||||||
|
assertThat(opt.allowWriteStall()).isEqualTo(value); |
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
public void maxSubcompactions() { |
||||||
|
CompactRangeOptions opt = new CompactRangeOptions(); |
||||||
|
int value = 2; |
||||||
|
opt.setMaxSubcompactions(value); |
||||||
|
assertThat(opt.maxSubcompactions()).isEqualTo(value); |
||||||
|
value = 3; |
||||||
|
opt.setMaxSubcompactions(value); |
||||||
|
assertThat(opt.maxSubcompactions()).isEqualTo(value); |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue