Cleanup deprecation warnings and javadoc (#6218)

Summary:
There are no API changes ;-)
Pull Request resolved: https://github.com/facebook/rocksdb/pull/6218

Differential Revision: D19200373

Pulled By: pdillinger

fbshipit-source-id: 58d34b01ea53b75a1eccbd72f8b14d6256a7380f
This commit is contained in:
Adam Retter 2019-12-20 13:39:11 -08:00 committed by Facebook Github Bot
parent f89dea4fec
commit 4d3264e4ab
76 changed files with 614 additions and 307 deletions

View File

@ -249,7 +249,7 @@ set(JAVA_TEST_CLASSES
src/test/java/org/rocksdb/NativeComparatorWrapperTest.java src/test/java/org/rocksdb/NativeComparatorWrapperTest.java
src/test/java/org/rocksdb/PlatformRandomHelper.java src/test/java/org/rocksdb/PlatformRandomHelper.java
src/test/java/org/rocksdb/RocksDBExceptionTest.java src/test/java/org/rocksdb/RocksDBExceptionTest.java
src/test/java/org/rocksdb/RocksMemoryResource.java src/test/java/org/rocksdb/RocksNativeLibraryResource.java
src/test/java/org/rocksdb/SnapshotTest.java src/test/java/org/rocksdb/SnapshotTest.java
src/test/java/org/rocksdb/WriteBatchTest.java src/test/java/org/rocksdb/WriteBatchTest.java
src/test/java/org/rocksdb/util/CapturingWriteBatchHandler.java src/test/java/org/rocksdb/util/CapturingWriteBatchHandler.java

View File

@ -198,18 +198,19 @@ public abstract class AbstractMutableOptions {
return self(); return self();
} }
@SuppressWarnings("unchecked")
protected <N extends Enum<N>> N getEnum(final K key) protected <N extends Enum<N>> N getEnum(final K key)
throws NoSuchElementException, NumberFormatException { throws NoSuchElementException, NumberFormatException {
final MutableOptionValue<?> value = options.get(key); final MutableOptionValue<?> value = options.get(key);
if(value == null) { if (value == null) {
throw new NoSuchElementException(key.name() + " has not been set"); throw new NoSuchElementException(key.name() + " has not been set");
} }
if(!(value instanceof MutableOptionValue.MutableOptionEnumValue)) { if (!(value instanceof MutableOptionValue.MutableOptionEnumValue)) {
throw new NoSuchElementException(key.name() + " is not of Enum type"); throw new NoSuchElementException(key.name() + " is not of Enum type");
} }
return ((MutableOptionValue.MutableOptionEnumValue<N>)value).asObject(); return ((MutableOptionValue.MutableOptionEnumValue<N>) value).asObject();
} }
public U fromString( public U fromString(

View File

@ -507,7 +507,12 @@ public class BlockBasedTableConfig extends TableFormatConfig {
return this; return this;
} }
/* /**
* Set the filter.
*
* @param filter the filter
* @return the reference to the current config.
*
* @deprecated Use {@link #setFilterPolicy(Filter)} * @deprecated Use {@link #setFilterPolicy(Filter)}
*/ */
@Deprecated @Deprecated

View File

@ -66,7 +66,7 @@ public class ColumnFamilyOptions extends RocksObject
/** /**
* <p>Constructor to be used by * <p>Constructor to be used by
* {@link #getColumnFamilyOptionsFromProps(java.util.Properties)}, * {@link #getColumnFamilyOptionsFromProps(java.util.Properties)},
* {@link ColumnFamilyDescriptor#columnFamilyOptions()} * {@link ColumnFamilyDescriptor#getOptions()}
* and also called via JNI.</p> * and also called via JNI.</p>
* *
* @param handle native handle to ColumnFamilyOptions instance. * @param handle native handle to ColumnFamilyOptions instance.

View File

@ -385,6 +385,7 @@ public class DBOptions extends RocksObject
} }
@Override @Override
@Deprecated
public void setBaseBackgroundCompactions( public void setBaseBackgroundCompactions(
final int baseBackgroundCompactions) { final int baseBackgroundCompactions) {
assert(isOwningHandle()); assert(isOwningHandle());
@ -398,6 +399,7 @@ public class DBOptions extends RocksObject
} }
@Override @Override
@Deprecated
public DBOptions setMaxBackgroundCompactions( public DBOptions setMaxBackgroundCompactions(
final int maxBackgroundCompactions) { final int maxBackgroundCompactions) {
assert(isOwningHandle()); assert(isOwningHandle());
@ -406,6 +408,7 @@ public class DBOptions extends RocksObject
} }
@Override @Override
@Deprecated
public int maxBackgroundCompactions() { public int maxBackgroundCompactions() {
assert(isOwningHandle()); assert(isOwningHandle());
return maxBackgroundCompactions(nativeHandle_); return maxBackgroundCompactions(nativeHandle_);
@ -425,6 +428,7 @@ public class DBOptions extends RocksObject
} }
@Override @Override
@Deprecated
public DBOptions setMaxBackgroundFlushes( public DBOptions setMaxBackgroundFlushes(
final int maxBackgroundFlushes) { final int maxBackgroundFlushes) {
assert(isOwningHandle()); assert(isOwningHandle());
@ -433,6 +437,7 @@ public class DBOptions extends RocksObject
} }
@Override @Override
@Deprecated
public int maxBackgroundFlushes() { public int maxBackgroundFlushes() {
assert(isOwningHandle()); assert(isOwningHandle());
return maxBackgroundFlushes(nativeHandle_); return maxBackgroundFlushes(nativeHandle_);

View File

@ -59,6 +59,8 @@ public abstract class Env extends RocksObject {
* <p>Gets the number of background worker threads of the pool * <p>Gets the number of background worker threads of the pool
* for this environment.</p> * for this environment.</p>
* *
* @param priority the priority id of a specified thread pool.
*
* @return the number of threads. * @return the number of threads.
*/ */
public int getBackgroundThreads(final Priority priority) { public int getBackgroundThreads(final Priority priority) {
@ -98,6 +100,7 @@ public abstract class Env extends RocksObject {
* pool. * pool.
* *
* @param number the number of threads. * @param number the number of threads.
* @param priority the priority id of a specified thread pool.
* *
* @return current {@link RocksEnv} instance. * @return current {@link RocksEnv} instance.
*/ */
@ -111,6 +114,8 @@ public abstract class Env extends RocksObject {
* Lower IO priority for threads from the specified pool. * Lower IO priority for threads from the specified pool.
* *
* @param priority the priority id of a specified thread pool. * @param priority the priority id of a specified thread pool.
*
* @return current {@link RocksEnv} instance.
*/ */
public Env lowerThreadPoolIOPriority(final Priority priority) { public Env lowerThreadPoolIOPriority(final Priority priority) {
lowerThreadPoolIOPriority(nativeHandle_, priority.getValue()); lowerThreadPoolIOPriority(nativeHandle_, priority.getValue());
@ -121,6 +126,8 @@ public abstract class Env extends RocksObject {
* Lower CPU priority for threads from the specified pool. * Lower CPU priority for threads from the specified pool.
* *
* @param priority the priority id of a specified thread pool. * @param priority the priority id of a specified thread pool.
*
* @return current {@link RocksEnv} instance.
*/ */
public Env lowerThreadPoolCPUPriority(final Priority priority) { public Env lowerThreadPoolCPUPriority(final Priority priority) {
lowerThreadPoolCPUPriority(nativeHandle_, priority.getValue()); lowerThreadPoolCPUPriority(nativeHandle_, priority.getValue());
@ -131,6 +138,8 @@ public abstract class Env extends RocksObject {
* Returns the status of all threads that belong to the current Env. * Returns the status of all threads that belong to the current Env.
* *
* @return the status of all threads belong to this env. * @return the status of all threads belong to this env.
*
* @throws RocksDBException if the thread list cannot be acquired.
*/ */
public List<ThreadStatus> getThreadList() throws RocksDBException { public List<ThreadStatus> getThreadList() throws RocksDBException {
return Arrays.asList(getThreadList(nativeHandle_)); return Arrays.asList(getThreadList(nativeHandle_));

View File

@ -169,12 +169,30 @@ public enum HistogramType {
} }
/** /**
* @deprecated * Returns the byte value of the enumerations value
* Exposes internal value of native enum mappings. This method will be marked private in the *
* next major release. * @return byte representation
*/ */
@Deprecated
public byte getValue() { public byte getValue() {
return value; return value;
} }
/**
* Get Histogram type by byte value.
*
* @param value byte representation of HistogramType.
*
* @return {@link org.rocksdb.HistogramType} instance.
* @throws java.lang.IllegalArgumentException if an invalid
* value is provided.
*/
public static HistogramType getHistogramType(final byte value) {
for (final HistogramType histogramType : HistogramType.values()) {
if (histogramType.getValue() == value) {
return histogramType;
}
}
throw new IllegalArgumentException(
"Illegal value provided for HistogramType.");
}
} }

View File

@ -39,7 +39,7 @@ public enum InfoLogLevel {
*/ */
public static InfoLogLevel getInfoLogLevel(final byte value) { public static InfoLogLevel getInfoLogLevel(final byte value) {
for (final InfoLogLevel infoLogLevel : InfoLogLevel.values()) { for (final InfoLogLevel infoLogLevel : InfoLogLevel.values()) {
if (infoLogLevel.getValue() == value){ if (infoLogLevel.getValue() == value) {
return infoLogLevel; return infoLogLevel;
} }
} }

View File

@ -151,6 +151,7 @@ public class MutableDBOptions extends AbstractMutableOptions {
} }
@Override @Override
@Deprecated
public void setBaseBackgroundCompactions( public void setBaseBackgroundCompactions(
final int baseBackgroundCompactions) { final int baseBackgroundCompactions) {
setInt(DBOption.base_background_compactions, setInt(DBOption.base_background_compactions,
@ -163,6 +164,7 @@ public class MutableDBOptions extends AbstractMutableOptions {
} }
@Override @Override
@Deprecated
public MutableDBOptionsBuilder setMaxBackgroundCompactions( public MutableDBOptionsBuilder setMaxBackgroundCompactions(
final int maxBackgroundCompactions) { final int maxBackgroundCompactions) {
return setInt(DBOption.max_background_compactions, return setInt(DBOption.max_background_compactions,
@ -170,6 +172,7 @@ public class MutableDBOptions extends AbstractMutableOptions {
} }
@Override @Override
@Deprecated
public int maxBackgroundCompactions() { public int maxBackgroundCompactions() {
return getInt(DBOption.max_background_compactions); return getInt(DBOption.max_background_compactions);
} }

View File

@ -73,8 +73,8 @@ public class OptimisticTransactionDB extends RocksDB
for (int i = 0; i < columnFamilyDescriptors.size(); i++) { for (int i = 0; i < columnFamilyDescriptors.size(); i++) {
final ColumnFamilyDescriptor cfDescriptor = columnFamilyDescriptors final ColumnFamilyDescriptor cfDescriptor = columnFamilyDescriptors
.get(i); .get(i);
cfNames[i] = cfDescriptor.columnFamilyName(); cfNames[i] = cfDescriptor.getName();
cfOptionHandles[i] = cfDescriptor.columnFamilyOptions().nativeHandle_; cfOptionHandles[i] = cfDescriptor.getOptions().nativeHandle_;
} }
final long[] handles = open(dbOptions.nativeHandle_, path, cfNames, final long[] handles = open(dbOptions.nativeHandle_, path, cfNames,

View File

@ -6,7 +6,7 @@
package org.rocksdb; package org.rocksdb;
public class OptimisticTransactionOptions extends RocksObject public class OptimisticTransactionOptions extends RocksObject
implements TransactionalOptions { implements TransactionalOptions<OptimisticTransactionOptions> {
public OptimisticTransactionOptions() { public OptimisticTransactionOptions() {
super(newOptimisticTransactionOptions()); super(newOptimisticTransactionOptions());

View File

@ -429,6 +429,7 @@ public class Options extends RocksObject
} }
@Override @Override
@Deprecated
public int maxBackgroundCompactions() { public int maxBackgroundCompactions() {
assert(isOwningHandle()); assert(isOwningHandle());
return maxBackgroundCompactions(nativeHandle_); return maxBackgroundCompactions(nativeHandle_);
@ -453,6 +454,7 @@ public class Options extends RocksObject
} }
@Override @Override
@Deprecated
public void setBaseBackgroundCompactions( public void setBaseBackgroundCompactions(
final int baseBackgroundCompactions) { final int baseBackgroundCompactions) {
assert(isOwningHandle()); assert(isOwningHandle());
@ -466,6 +468,7 @@ public class Options extends RocksObject
} }
@Override @Override
@Deprecated
public Options setMaxBackgroundCompactions( public Options setMaxBackgroundCompactions(
final int maxBackgroundCompactions) { final int maxBackgroundCompactions) {
assert(isOwningHandle()); assert(isOwningHandle());
@ -487,12 +490,14 @@ public class Options extends RocksObject
} }
@Override @Override
@Deprecated
public int maxBackgroundFlushes() { public int maxBackgroundFlushes() {
assert(isOwningHandle()); assert(isOwningHandle());
return maxBackgroundFlushes(nativeHandle_); return maxBackgroundFlushes(nativeHandle_);
} }
@Override @Override
@Deprecated
public Options setMaxBackgroundFlushes( public Options setMaxBackgroundFlushes(
final int maxBackgroundFlushes) { final int maxBackgroundFlushes) {
assert(isOwningHandle()); assert(isOwningHandle());

View File

@ -283,8 +283,8 @@ public class RocksDB extends RocksObject {
for (int i = 0; i < columnFamilyDescriptors.size(); i++) { for (int i = 0; i < columnFamilyDescriptors.size(); i++) {
final ColumnFamilyDescriptor cfDescriptor = columnFamilyDescriptors final ColumnFamilyDescriptor cfDescriptor = columnFamilyDescriptors
.get(i); .get(i);
cfNames[i] = cfDescriptor.columnFamilyName(); cfNames[i] = cfDescriptor.getName();
cfOptionHandles[i] = cfDescriptor.columnFamilyOptions().nativeHandle_; cfOptionHandles[i] = cfDescriptor.getOptions().nativeHandle_;
} }
final long[] handles = open(options.nativeHandle_, path, cfNames, final long[] handles = open(options.nativeHandle_, path, cfNames,
@ -407,8 +407,8 @@ public class RocksDB extends RocksObject {
for (int i = 0; i < columnFamilyDescriptors.size(); i++) { for (int i = 0; i < columnFamilyDescriptors.size(); i++) {
final ColumnFamilyDescriptor cfDescriptor = columnFamilyDescriptors final ColumnFamilyDescriptor cfDescriptor = columnFamilyDescriptors
.get(i); .get(i);
cfNames[i] = cfDescriptor.columnFamilyName(); cfNames[i] = cfDescriptor.getName();
cfOptionHandles[i] = cfDescriptor.columnFamilyOptions().nativeHandle_; cfOptionHandles[i] = cfDescriptor.getOptions().nativeHandle_;
} }
final long[] handles = openROnly(options.nativeHandle_, path, cfNames, final long[] handles = openROnly(options.nativeHandle_, path, cfNames,
@ -514,6 +514,9 @@ public class RocksDB extends RocksObject {
* @param columnFamilyNames the names of the column families. * @param columnFamilyNames the names of the column families.
* *
* @return the handles to the newly created column families. * @return the handles to the newly created column families.
*
* @throws RocksDBException if an error occurs whilst creating
* the column families
*/ */
public List<ColumnFamilyHandle> createColumnFamilies( public List<ColumnFamilyHandle> createColumnFamilies(
final ColumnFamilyOptions columnFamilyOptions, final ColumnFamilyOptions columnFamilyOptions,
@ -536,6 +539,9 @@ public class RocksDB extends RocksObject {
* @param columnFamilyDescriptors the descriptions of the column families. * @param columnFamilyDescriptors the descriptions of the column families.
* *
* @return the handles to the newly created column families. * @return the handles to the newly created column families.
*
* @throws RocksDBException if an error occurs whilst creating
* the column families
*/ */
public List<ColumnFamilyHandle> createColumnFamilies( public List<ColumnFamilyHandle> createColumnFamilies(
final List<ColumnFamilyDescriptor> columnFamilyDescriptors) final List<ColumnFamilyDescriptor> columnFamilyDescriptors)
@ -2676,6 +2682,8 @@ public class RocksDB extends RocksObject {
* *
* Note this doesn't reset {@link Options#statistics()} as it is not * Note this doesn't reset {@link Options#statistics()} as it is not
* owned by DB. * owned by DB.
*
* @throws RocksDBException if an error occurs whilst reseting the stats
*/ */
public void resetStats() throws RocksDBException { public void resetStats() throws RocksDBException {
resetStats(nativeHandle_); resetStats(nativeHandle_);
@ -3105,13 +3113,15 @@ public class RocksDB extends RocksObject {
* @throws RocksDBException thrown if an error occurs within the native * @throws RocksDBException thrown if an error occurs within the native
* part of the library. * part of the library.
*/ */
public void compactRange(final ColumnFamilyHandle columnFamilyHandle, public void compactRange(
/* @Nullable */ final ColumnFamilyHandle columnFamilyHandle,
final byte[] begin, final byte[] end, final byte[] begin, final byte[] end,
final CompactRangeOptions compactRangeOptions) throws RocksDBException { final CompactRangeOptions compactRangeOptions) throws RocksDBException {
compactRange(nativeHandle_, compactRange(nativeHandle_,
begin, begin == null ? -1 : begin.length, begin, begin == null ? -1 : begin.length,
end, end == null ? -1 : end.length, end, end == null ? -1 : end.length,
compactRangeOptions.nativeHandle_, columnFamilyHandle.nativeHandle_); compactRangeOptions.nativeHandle_,
columnFamilyHandle == null ? 0 : columnFamilyHandle.nativeHandle_);
} }
/** /**
@ -3120,6 +3130,8 @@ public class RocksDB extends RocksObject {
* @param columnFamilyHandle {@link org.rocksdb.ColumnFamilyHandle} * @param columnFamilyHandle {@link org.rocksdb.ColumnFamilyHandle}
* instance, or null for the default column family. * instance, or null for the default column family.
* @param mutableColumnFamilyOptions the options. * @param mutableColumnFamilyOptions the options.
*
* @throws RocksDBException if an error occurs whilst setting the options
*/ */
public void setOptions( public void setOptions(
/* @Nullable */final ColumnFamilyHandle columnFamilyHandle, /* @Nullable */final ColumnFamilyHandle columnFamilyHandle,
@ -3134,6 +3146,8 @@ public class RocksDB extends RocksObject {
* Change the options for the default column family handle. * Change the options for the default column family handle.
* *
* @param mutableColumnFamilyOptions the options. * @param mutableColumnFamilyOptions the options.
*
* @throws RocksDBException if an error occurs whilst setting the options
*/ */
public void setOptions( public void setOptions(
final MutableColumnFamilyOptions mutableColumnFamilyOptions) final MutableColumnFamilyOptions mutableColumnFamilyOptions)
@ -3145,6 +3159,8 @@ public class RocksDB extends RocksObject {
* Set the options for the column family handle. * Set the options for the column family handle.
* *
* @param mutableDBoptions the options. * @param mutableDBoptions the options.
*
* @throws RocksDBException if an error occurs whilst setting the options
*/ */
public void setDBOptions(final MutableDBOptions mutableDBoptions) public void setDBOptions(final MutableDBOptions mutableDBoptions)
throws RocksDBException { throws RocksDBException {
@ -3154,7 +3170,7 @@ public class RocksDB extends RocksObject {
} }
/** /**
* Takes nputs a list of files specified by file names and * Takes a list of files specified by file names and
* compacts them to the specified level. * compacts them to the specified level.
* *
* Note that the behavior is different from * Note that the behavior is different from
@ -3169,6 +3185,10 @@ public class RocksDB extends RocksObject {
* @param compactionJobInfo the compaction job info, this parameter * @param compactionJobInfo the compaction job info, this parameter
* will be updated with the info from compacting the files, * will be updated with the info from compacting the files,
* can just be null if you don't need it. * can just be null if you don't need it.
*
* @return the list of compacted files
*
* @throws RocksDBException if an error occurs during compaction
*/ */
public List<String> compactFiles( public List<String> compactFiles(
final CompactionOptions compactionOptions, final CompactionOptions compactionOptions,
@ -3199,6 +3219,10 @@ public class RocksDB extends RocksObject {
* @param compactionJobInfo the compaction job info, this parameter * @param compactionJobInfo the compaction job info, this parameter
* will be updated with the info from compacting the files, * will be updated with the info from compacting the files,
* can just be null if you don't need it. * can just be null if you don't need it.
*
* @return the list of compacted files
*
* @throws RocksDBException if an error occurs during compaction
*/ */
public List<String> compactFiles( public List<String> compactFiles(
final CompactionOptions compactionOptions, final CompactionOptions compactionOptions,
@ -3221,7 +3245,7 @@ public class RocksDB extends RocksObject {
* finish. After it returns, no background process will be run until * finish. After it returns, no background process will be run until
* {@link #continueBackgroundWork()} is called * {@link #continueBackgroundWork()} is called
* *
* @throws RocksDBException If an error occurs when pausing background work * @throws RocksDBException if an error occurs when pausing background work
*/ */
public void pauseBackgroundWork() throws RocksDBException { public void pauseBackgroundWork() throws RocksDBException {
pauseBackgroundWork(nativeHandle_); pauseBackgroundWork(nativeHandle_);
@ -3231,7 +3255,7 @@ public class RocksDB extends RocksObject {
* Resumes background work which was suspended by * Resumes background work which was suspended by
* previously calling {@link #pauseBackgroundWork()} * previously calling {@link #pauseBackgroundWork()}
* *
* @throws RocksDBException If an error occurs when resuming background work * @throws RocksDBException if an error occurs when resuming background work
*/ */
public void continueBackgroundWork() throws RocksDBException { public void continueBackgroundWork() throws RocksDBException {
continueBackgroundWork(nativeHandle_); continueBackgroundWork(nativeHandle_);
@ -3251,6 +3275,8 @@ public class RocksDB extends RocksObject {
* parameter itself within the column family option. * parameter itself within the column family option.
* *
* @param columnFamilyHandles the column family handles * @param columnFamilyHandles the column family handles
*
* @throws RocksDBException if an error occurs whilst enabling auto-compaction
*/ */
public void enableAutoCompaction( public void enableAutoCompaction(
final List<ColumnFamilyHandle> columnFamilyHandles) final List<ColumnFamilyHandle> columnFamilyHandles)
@ -3284,6 +3310,8 @@ public class RocksDB extends RocksObject {
/** /**
* Maximum level to which a new compacted memtable is pushed if it * Maximum level to which a new compacted memtable is pushed if it
* does not create overlap. * does not create overlap.
*
* @return the maximum level
*/ */
public int maxMemCompactionLevel() { public int maxMemCompactionLevel() {
return maxMemCompactionLevel(null); return maxMemCompactionLevel(null);
@ -3294,15 +3322,19 @@ public class RocksDB extends RocksObject {
* does not create overlap. * does not create overlap.
* *
* @param columnFamilyHandle the column family handle * @param columnFamilyHandle the column family handle
*
* @return the maximum level
*/ */
public int maxMemCompactionLevel( public int maxMemCompactionLevel(
/* @Nullable */final ColumnFamilyHandle columnFamilyHandle) { /* @Nullable */ final ColumnFamilyHandle columnFamilyHandle) {
return maxMemCompactionLevel(nativeHandle_, return maxMemCompactionLevel(nativeHandle_,
columnFamilyHandle == null ? 0 : columnFamilyHandle.nativeHandle_); columnFamilyHandle == null ? 0 : columnFamilyHandle.nativeHandle_);
} }
/** /**
* Number of files in level-0 that would stop writes. * Number of files in level-0 that would stop writes.
*
* @return the number of files
*/ */
public int level0StopWriteTrigger() { public int level0StopWriteTrigger() {
return level0StopWriteTrigger(null); return level0StopWriteTrigger(null);
@ -3312,6 +3344,8 @@ public class RocksDB extends RocksObject {
* Number of files in level-0 that would stop writes. * Number of files in level-0 that would stop writes.
* *
* @param columnFamilyHandle the column family handle * @param columnFamilyHandle the column family handle
*
* @return the number of files
*/ */
public int level0StopWriteTrigger( public int level0StopWriteTrigger(
/* @Nullable */final ColumnFamilyHandle columnFamilyHandle) { /* @Nullable */final ColumnFamilyHandle columnFamilyHandle) {
@ -3407,6 +3441,8 @@ public class RocksDB extends RocksObject {
* it calls {@link #syncWal()} afterwards. * it calls {@link #syncWal()} afterwards.
* *
* @param sync true to also fsync to disk. * @param sync true to also fsync to disk.
*
* @throws RocksDBException if an error occurs whilst flushing
*/ */
public void flushWal(final boolean sync) throws RocksDBException { public void flushWal(final boolean sync) throws RocksDBException {
flushWal(nativeHandle_, sync); flushWal(nativeHandle_, sync);
@ -3422,6 +3458,8 @@ public class RocksDB extends RocksObject {
* won't be visible until the sync is done. * won't be visible until the sync is done.
* *
* Currently only works if {@link Options#allowMmapWrites()} is set to false. * Currently only works if {@link Options#allowMmapWrites()} is set to false.
*
* @throws RocksDBException if an error occurs whilst syncing
*/ */
public void syncWal() throws RocksDBException { public void syncWal() throws RocksDBException {
syncWal(nativeHandle_); syncWal(nativeHandle_);
@ -3519,6 +3557,9 @@ public class RocksDB extends RocksObject {
* See {@link #getLiveFiles(boolean)}. * See {@link #getLiveFiles(boolean)}.
* *
* @return the live files * @return the live files
*
* @throws RocksDBException if an error occurs whilst retrieving the list
* of live files
*/ */
public LiveFiles getLiveFiles() throws RocksDBException { public LiveFiles getLiveFiles() throws RocksDBException {
return getLiveFiles(true); return getLiveFiles(true);
@ -3542,6 +3583,9 @@ public class RocksDB extends RocksObject {
* indeterminate time. * indeterminate time.
* *
* @return the live files * @return the live files
*
* @throws RocksDBException if an error occurs whilst retrieving the list
* of live files
*/ */
public LiveFiles getLiveFiles(final boolean flushMemtable) public LiveFiles getLiveFiles(final boolean flushMemtable)
throws RocksDBException { throws RocksDBException {
@ -3559,6 +3603,9 @@ public class RocksDB extends RocksObject {
* Retrieve the sorted list of all wal files with earliest file first. * Retrieve the sorted list of all wal files with earliest file first.
* *
* @return the log files * @return the log files
*
* @throws RocksDBException if an error occurs whilst retrieving the list
* of sorted WAL files
*/ */
public List<LogFile> getSortedWalFiles() throws RocksDBException { public List<LogFile> getSortedWalFiles() throws RocksDBException {
final LogFile[] logFiles = getSortedWalFiles(nativeHandle_); final LogFile[] logFiles = getSortedWalFiles(nativeHandle_);
@ -3594,6 +3641,8 @@ public class RocksDB extends RocksObject {
* path relative to the db directory. eg. 000001.sst, /archive/000003.log * path relative to the db directory. eg. 000001.sst, /archive/000003.log
* *
* @param name the file name * @param name the file name
*
* @throws RocksDBException if an error occurs whilst deleting the file
*/ */
public void deleteFile(final String name) throws RocksDBException { public void deleteFile(final String name) throws RocksDBException {
deleteFile(nativeHandle_, name); deleteFile(nativeHandle_, name);
@ -3710,6 +3759,8 @@ public class RocksDB extends RocksObject {
* column family. * column family.
* *
* @return the properties * @return the properties
*
* @throws RocksDBException if an error occurs whilst getting the properties
*/ */
public Map<String, TableProperties> getPropertiesOfAllTables( public Map<String, TableProperties> getPropertiesOfAllTables(
/* @Nullable */final ColumnFamilyHandle columnFamilyHandle) /* @Nullable */final ColumnFamilyHandle columnFamilyHandle)
@ -3722,6 +3773,8 @@ public class RocksDB extends RocksObject {
* Get the properties of all tables in the default column family. * Get the properties of all tables in the default column family.
* *
* @return the properties * @return the properties
*
* @throws RocksDBException if an error occurs whilst getting the properties
*/ */
public Map<String, TableProperties> getPropertiesOfAllTables() public Map<String, TableProperties> getPropertiesOfAllTables()
throws RocksDBException { throws RocksDBException {
@ -3736,6 +3789,8 @@ public class RocksDB extends RocksObject {
* @param ranges the ranges over which to get the table properties * @param ranges the ranges over which to get the table properties
* *
* @return the properties * @return the properties
*
* @throws RocksDBException if an error occurs whilst getting the properties
*/ */
public Map<String, TableProperties> getPropertiesOfTablesInRange( public Map<String, TableProperties> getPropertiesOfTablesInRange(
/* @Nullable */final ColumnFamilyHandle columnFamilyHandle, /* @Nullable */final ColumnFamilyHandle columnFamilyHandle,
@ -3751,6 +3806,8 @@ public class RocksDB extends RocksObject {
* @param ranges the ranges over which to get the table properties * @param ranges the ranges over which to get the table properties
* *
* @return the properties * @return the properties
*
* @throws RocksDBException if an error occurs whilst getting the properties
*/ */
public Map<String, TableProperties> getPropertiesOfTablesInRange( public Map<String, TableProperties> getPropertiesOfTablesInRange(
final List<Range> ranges) throws RocksDBException { final List<Range> ranges) throws RocksDBException {
@ -3764,6 +3821,8 @@ public class RocksDB extends RocksObject {
* column family. * column family.
* *
* @return the suggested range. * @return the suggested range.
*
* @throws RocksDBException if an error occurs whilst suggesting the range
*/ */
public Range suggestCompactRange( public Range suggestCompactRange(
/* @Nullable */final ColumnFamilyHandle columnFamilyHandle) /* @Nullable */final ColumnFamilyHandle columnFamilyHandle)
@ -3778,6 +3837,8 @@ public class RocksDB extends RocksObject {
* Suggest the range to compact for the default column family. * Suggest the range to compact for the default column family.
* *
* @return the suggested range. * @return the suggested range.
*
* @throws RocksDBException if an error occurs whilst suggesting the range
*/ */
public Range suggestCompactRange() public Range suggestCompactRange()
throws RocksDBException { throws RocksDBException {
@ -3789,6 +3850,9 @@ public class RocksDB extends RocksObject {
* *
* @param columnFamilyHandle the column family handle, * @param columnFamilyHandle the column family handle,
* or null for the default column family. * or null for the default column family.
* @param targetLevel the target level for L0
*
* @throws RocksDBException if an error occurs whilst promoting L0
*/ */
public void promoteL0( public void promoteL0(
/* @Nullable */final ColumnFamilyHandle columnFamilyHandle, /* @Nullable */final ColumnFamilyHandle columnFamilyHandle,
@ -3800,6 +3864,10 @@ public class RocksDB extends RocksObject {
/** /**
* Promote L0 for the default column family. * Promote L0 for the default column family.
*
* @param targetLevel the target level for L0
*
* @throws RocksDBException if an error occurs whilst promoting L0
*/ */
public void promoteL0(final int targetLevel) public void promoteL0(final int targetLevel)
throws RocksDBException { throws RocksDBException {
@ -3813,6 +3881,8 @@ public class RocksDB extends RocksObject {
* *
* @param traceOptions the options * @param traceOptions the options
* @param traceWriter the trace writer * @param traceWriter the trace writer
*
* @throws RocksDBException if an error occurs whilst starting the trace
*/ */
public void startTrace(final TraceOptions traceOptions, public void startTrace(final TraceOptions traceOptions,
final AbstractTraceWriter traceWriter) throws RocksDBException { final AbstractTraceWriter traceWriter) throws RocksDBException {
@ -3829,23 +3899,28 @@ public class RocksDB extends RocksObject {
* Stop tracing DB operations. * Stop tracing DB operations.
* *
* See {@link #startTrace(TraceOptions, AbstractTraceWriter)} * See {@link #startTrace(TraceOptions, AbstractTraceWriter)}
*
* @throws RocksDBException if an error occurs whilst ending the trace
*/ */
public void endTrace() throws RocksDBException { public void endTrace() throws RocksDBException {
endTrace(nativeHandle_); endTrace(nativeHandle_);
} }
/* /**
* Delete files in multiple ranges at once * Delete files in multiple ranges at once.
* Delete files in a lot of ranges one at a time can be slow, use this API for * Delete files in a lot of ranges one at a time can be slow, use this API for
* better performance in that case. * better performance in that case.
*
* @param columnFamily - The column family for operation (null for default) * @param columnFamily - The column family for operation (null for default)
* @param includeEnd - Whether ranges should include end * @param includeEnd - Whether ranges should include end
* @param ranges - pairs of ranges (from1, to1, from2, to2, ...) * @param ranges - pairs of ranges (from1, to1, from2, to2, ...)
*
* @throws RocksDBException thrown if error happens in underlying * @throws RocksDBException thrown if error happens in underlying
* native library. * native library.
*/ */
public void deleteFilesInRanges(final ColumnFamilyHandle columnFamily, final List<byte[]> ranges, public void deleteFilesInRanges(final ColumnFamilyHandle columnFamily,
final boolean includeEnd) throws RocksDBException { final List<byte[]> ranges, final boolean includeEnd)
throws RocksDBException {
if (ranges.size() == 0) { if (ranges.size() == 0) {
return; return;
} }

View File

@ -23,6 +23,18 @@ public class SstFileMetaData {
/** /**
* Called from JNI C++ * Called from JNI C++
*
* @param fileName the file name
* @param path the file path
* @param size the size of the file
* @param smallestSeqno the smallest sequence number
* @param largestSeqno the largest sequence number
* @param smallestKey the smallest key
* @param largestKey the largest key
* @param numReadsSampled the number of reads sampled
* @param beingCompacted true if the file is being compacted, false otherwise
* @param numEntries the number of entries
* @param numDeletions the number of deletions
*/ */
protected SstFileMetaData( protected SstFileMetaData(
final String fileName, final String fileName,

View File

@ -60,8 +60,10 @@ public class SstFileReader extends RocksObject {
/** /**
* Get the properties of the table. * Get the properties of the table.
* *
*
* @return the properties * @return the properties
*
* @throws RocksDBException if an error occurs whilst getting the table
* properties
*/ */
public TableProperties getTableProperties() throws RocksDBException { public TableProperties getTableProperties() throws RocksDBException {
return getTableProperties(nativeHandle_); return getTableProperties(nativeHandle_);
@ -70,9 +72,11 @@ public class SstFileReader extends RocksObject {
@Override protected final native void disposeInternal(final long handle); @Override protected final native void disposeInternal(final long handle);
private native long newIterator(final long handle, final long readOptionsHandle); private native long newIterator(final long handle, final long readOptionsHandle);
private native void open(final long handle, final String filePath) throws RocksDBException; private native void open(final long handle, final String filePath)
throws RocksDBException;
private native static long newSstFileReader(final long optionsHandle); private native static long newSstFileReader(final long optionsHandle);
private native void verifyChecksum(final long handle) throws RocksDBException; private native void verifyChecksum(final long handle) throws RocksDBException;
private native TableProperties getTableProperties(final long handle) throws RocksDBException; private native TableProperties getTableProperties(final long handle)
throws RocksDBException;
} }

View File

@ -731,13 +731,30 @@ public enum TickerType {
} }
/** /**
* @deprecated Exposes internal value of native enum mappings. * Returns the byte value of the enumerations value
* This method will be marked package private in the next major release.
* *
* @return the internal representation * @return byte representation
*/ */
@Deprecated
public byte getValue() { public byte getValue() {
return value; return value;
} }
/**
* Get Ticker type by byte value.
*
* @param value byte representation of TickerType.
*
* @return {@link org.rocksdb.TickerType} instance.
* @throws java.lang.IllegalArgumentException if an invalid
* value is provided.
*/
public static TickerType getTickerType(final byte value) {
for (final TickerType tickerType : TickerType.values()) {
if (tickerType.getValue() == value) {
return tickerType;
}
}
throw new IllegalArgumentException(
"Illegal value provided for TickerType.");
}
} }

View File

@ -433,7 +433,7 @@ public class Transaction extends RocksObject {
* @param key the key to retrieve the value for. * @param key the key to retrieve the value for.
* @param exclusive true if the transaction should have exclusive access to * @param exclusive true if the transaction should have exclusive access to
* the key, otherwise false for shared access. * the key, otherwise false for shared access.
* @param do_validate true if it should validate the snapshot before doing the read * @param doValidate true if it should validate the snapshot before doing the read
* *
* @return a byte array storing the value associated with the input key if * @return a byte array storing the value associated with the input key if
* any. null if it does not find the specified key. * any. null if it does not find the specified key.
@ -443,16 +443,16 @@ public class Transaction extends RocksObject {
*/ */
public byte[] getForUpdate(final ReadOptions readOptions, public byte[] getForUpdate(final ReadOptions readOptions,
final ColumnFamilyHandle columnFamilyHandle, final byte[] key, final boolean exclusive, final ColumnFamilyHandle columnFamilyHandle, final byte[] key, final boolean exclusive,
final boolean do_validate) throws RocksDBException { final boolean doValidate) throws RocksDBException {
assert (isOwningHandle()); assert (isOwningHandle());
return getForUpdate(nativeHandle_, readOptions.nativeHandle_, key, key.length, return getForUpdate(nativeHandle_, readOptions.nativeHandle_, key, key.length,
columnFamilyHandle.nativeHandle_, exclusive, do_validate); columnFamilyHandle.nativeHandle_, exclusive, doValidate);
} }
/** /**
* Same as * Same as
* {@link #getForUpdate(ReadOptions, ColumnFamilyHandle, byte[], boolean, boolean)} * {@link #getForUpdate(ReadOptions, ColumnFamilyHandle, byte[], boolean, boolean)}
* with do_validate=true. * with doValidate=true.
* *
* @param readOptions Read options. * @param readOptions Read options.
* @param columnFamilyHandle {@link org.rocksdb.ColumnFamilyHandle} * @param columnFamilyHandle {@link org.rocksdb.ColumnFamilyHandle}
@ -472,7 +472,7 @@ public class Transaction extends RocksObject {
final boolean exclusive) throws RocksDBException { final boolean exclusive) throws RocksDBException {
assert(isOwningHandle()); assert(isOwningHandle());
return getForUpdate(nativeHandle_, readOptions.nativeHandle_, key, key.length, return getForUpdate(nativeHandle_, readOptions.nativeHandle_, key, key.length,
columnFamilyHandle.nativeHandle_, exclusive, true /*do_validate*/); columnFamilyHandle.nativeHandle_, exclusive, true /*doValidate*/);
} }
/** /**
@ -523,7 +523,7 @@ public class Transaction extends RocksObject {
final boolean exclusive) throws RocksDBException { final boolean exclusive) throws RocksDBException {
assert(isOwningHandle()); assert(isOwningHandle());
return getForUpdate( return getForUpdate(
nativeHandle_, readOptions.nativeHandle_, key, key.length, exclusive, true /*do_validate*/); nativeHandle_, readOptions.nativeHandle_, key, key.length, exclusive, true /*doValidate*/);
} }
/** /**
@ -658,27 +658,52 @@ public class Transaction extends RocksObject {
* @param columnFamilyHandle The column family to put the key/value into * @param columnFamilyHandle The column family to put the key/value into
* @param key the specified key to be inserted. * @param key the specified key to be inserted.
* @param value the value associated with the specified key. * @param value the value associated with the specified key.
* @param assumeTracked true when it is expected that the key is already
* tracked. More specifically, it means the the key was previous tracked
* in the same savepoint, with the same exclusive flag, and at a lower
* sequence number. If valid then it skips ValidateSnapshot,
* throws an error otherwise.
* *
* @throws RocksDBException when one of the TransactionalDB conditions * @throws RocksDBException when one of the TransactionalDB conditions
* described above occurs, or in the case of an unexpected error * described above occurs, or in the case of an unexpected error
*/ */
public void put(final ColumnFamilyHandle columnFamilyHandle, final byte[] key, final byte[] value, public void put(final ColumnFamilyHandle columnFamilyHandle, final byte[] key,
final boolean assume_tracked) throws RocksDBException { final byte[] value, final boolean assumeTracked) throws RocksDBException {
assert (isOwningHandle()); assert (isOwningHandle());
put(nativeHandle_, key, key.length, value, value.length, columnFamilyHandle.nativeHandle_, put(nativeHandle_, key, key.length, value, value.length,
assume_tracked); columnFamilyHandle.nativeHandle_, assumeTracked);
} }
/* /**
* Same as * Similar to {@link #put(ColumnFamilyHandle, byte[], byte[], boolean)}
* {@link #put(ColumnFamilyHandle, byte[], byte[], boolean)} * but with {@code assumeTracked = false}.
* with assume_tracked=false. *
* Will also perform conflict checking on the keys be written.
*
* If this Transaction was created on an {@link OptimisticTransactionDB},
* these functions should always succeed.
*
* If this Transaction was created on a {@link TransactionDB}, an
* {@link RocksDBException} may be thrown with an accompanying {@link Status}
* when:
* {@link Status.Code#Busy} if there is a write conflict,
* {@link Status.Code#TimedOut} if a lock could not be acquired,
* {@link Status.Code#TryAgain} if the memtable history size is not large
* enough. See
* {@link ColumnFamilyOptions#maxWriteBufferNumberToMaintain()}
*
* @param columnFamilyHandle The column family to put the key/value into
* @param key the specified key to be inserted.
* @param value the value associated with the specified key.
*
* @throws RocksDBException when one of the TransactionalDB conditions
* described above occurs, or in the case of an unexpected error
*/ */
public void put(final ColumnFamilyHandle columnFamilyHandle, final byte[] key, public void put(final ColumnFamilyHandle columnFamilyHandle, final byte[] key,
final byte[] value) throws RocksDBException { final byte[] value) throws RocksDBException {
assert(isOwningHandle()); assert(isOwningHandle());
put(nativeHandle_, key, key.length, value, value.length, columnFamilyHandle.nativeHandle_, put(nativeHandle_, key, key.length, value, value.length,
/*assume_tracked*/ false); columnFamilyHandle.nativeHandle_, false);
} }
/** /**
@ -718,28 +743,43 @@ public class Transaction extends RocksObject {
* @param columnFamilyHandle The column family to put the key/value into * @param columnFamilyHandle The column family to put the key/value into
* @param keyParts the specified key to be inserted. * @param keyParts the specified key to be inserted.
* @param valueParts the value associated with the specified key. * @param valueParts the value associated with the specified key.
* @param assumeTracked true when it is expected that the key is already
* tracked. More specifically, it means the the key was previous tracked
* in the same savepoint, with the same exclusive flag, and at a lower
* sequence number. If valid then it skips ValidateSnapshot,
* throws an error otherwise.
* *
* @throws RocksDBException when one of the TransactionalDB conditions * @throws RocksDBException when one of the TransactionalDB conditions
* described above occurs, or in the case of an unexpected error * described above occurs, or in the case of an unexpected error
*/ */
public void put(final ColumnFamilyHandle columnFamilyHandle, final byte[][] keyParts, public void put(final ColumnFamilyHandle columnFamilyHandle,
final byte[][] valueParts, final boolean assume_tracked) throws RocksDBException { final byte[][] keyParts, final byte[][] valueParts,
final boolean assumeTracked) throws RocksDBException {
assert (isOwningHandle()); assert (isOwningHandle());
put(nativeHandle_, keyParts, keyParts.length, valueParts, valueParts.length, put(nativeHandle_, keyParts, keyParts.length, valueParts, valueParts.length,
columnFamilyHandle.nativeHandle_, assume_tracked); columnFamilyHandle.nativeHandle_, assumeTracked);
} }
/* /**
* Same as * Similar to {@link #put(ColumnFamilyHandle, byte[][], byte[][], boolean)}
* {@link #put(ColumnFamilyHandle, byte[][], byte[][], boolean)} * but with with {@code assumeTracked = false}.
* with assume_tracked=false. *
* Allows you to specify the key and value in several parts that will be
* concatenated together.
*
* @param columnFamilyHandle The column family to put the key/value into
* @param keyParts the specified key to be inserted.
* @param valueParts the value associated with the specified key.
*
* @throws RocksDBException when one of the TransactionalDB conditions
* described above occurs, or in the case of an unexpected error
*/ */
public void put(final ColumnFamilyHandle columnFamilyHandle, public void put(final ColumnFamilyHandle columnFamilyHandle,
final byte[][] keyParts, final byte[][] valueParts) final byte[][] keyParts, final byte[][] valueParts)
throws RocksDBException { throws RocksDBException {
assert(isOwningHandle()); assert(isOwningHandle());
put(nativeHandle_, keyParts, keyParts.length, valueParts, valueParts.length, put(nativeHandle_, keyParts, keyParts.length, valueParts, valueParts.length,
columnFamilyHandle.nativeHandle_, /*assume_tracked*/ false); columnFamilyHandle.nativeHandle_, false);
} }
//TODO(AR) refactor if we implement org.rocksdb.SliceParts in future //TODO(AR) refactor if we implement org.rocksdb.SliceParts in future
@ -780,27 +820,53 @@ public class Transaction extends RocksObject {
* @param columnFamilyHandle The column family to merge the key/value into * @param columnFamilyHandle The column family to merge the key/value into
* @param key the specified key to be merged. * @param key the specified key to be merged.
* @param value the value associated with the specified key. * @param value the value associated with the specified key.
* @param assumeTracked true when it is expected that the key is already
* tracked. More specifically, it means the the key was previous tracked
* in the same savepoint, with the same exclusive flag, and at a lower
* sequence number. If valid then it skips ValidateSnapshot,
* throws an error otherwise.
* *
* @throws RocksDBException when one of the TransactionalDB conditions * @throws RocksDBException when one of the TransactionalDB conditions
* described above occurs, or in the case of an unexpected error * described above occurs, or in the case of an unexpected error
*/ */
public void merge(final ColumnFamilyHandle columnFamilyHandle, final byte[] key, public void merge(final ColumnFamilyHandle columnFamilyHandle,
final byte[] value, final boolean assume_tracked) throws RocksDBException { final byte[] key, final byte[] value, final boolean assumeTracked)
throws RocksDBException {
assert (isOwningHandle()); assert (isOwningHandle());
merge(nativeHandle_, key, key.length, value, value.length, columnFamilyHandle.nativeHandle_, merge(nativeHandle_, key, key.length, value, value.length,
assume_tracked); columnFamilyHandle.nativeHandle_, assumeTracked);
} }
/* /**
* Same as * Similar to {@link #merge(ColumnFamilyHandle, byte[], byte[], boolean)}
* {@link #merge(ColumnFamilyHandle, byte[], byte[], boolean)} * but with {@code assumeTracked = false}.
* with assume_tracked=false. *
* Will also perform conflict checking on the keys be written.
*
* If this Transaction was created on an {@link OptimisticTransactionDB},
* these functions should always succeed.
*
* If this Transaction was created on a {@link TransactionDB}, an
* {@link RocksDBException} may be thrown with an accompanying {@link Status}
* when:
* {@link Status.Code#Busy} if there is a write conflict,
* {@link Status.Code#TimedOut} if a lock could not be acquired,
* {@link Status.Code#TryAgain} if the memtable history size is not large
* enough. See
* {@link ColumnFamilyOptions#maxWriteBufferNumberToMaintain()}
*
* @param columnFamilyHandle The column family to merge the key/value into
* @param key the specified key to be merged.
* @param value the value associated with the specified key.
*
* @throws RocksDBException when one of the TransactionalDB conditions
* described above occurs, or in the case of an unexpected error
*/ */
public void merge(final ColumnFamilyHandle columnFamilyHandle, public void merge(final ColumnFamilyHandle columnFamilyHandle,
final byte[] key, final byte[] value) throws RocksDBException { final byte[] key, final byte[] value) throws RocksDBException {
assert(isOwningHandle()); assert(isOwningHandle());
merge(nativeHandle_, key, key.length, value, value.length, columnFamilyHandle.nativeHandle_, merge(nativeHandle_, key, key.length, value, value.length,
/*assume_tracked*/ false); columnFamilyHandle.nativeHandle_, false);
} }
/** /**
@ -849,26 +915,51 @@ public class Transaction extends RocksObject {
* *
* @param columnFamilyHandle The column family to delete the key/value from * @param columnFamilyHandle The column family to delete the key/value from
* @param key the specified key to be deleted. * @param key the specified key to be deleted.
* @param assumeTracked true when it is expected that the key is already
* tracked. More specifically, it means the the key was previous tracked
* in the same savepoint, with the same exclusive flag, and at a lower
* sequence number. If valid then it skips ValidateSnapshot,
* throws an error otherwise.
* *
* @throws RocksDBException when one of the TransactionalDB conditions * @throws RocksDBException when one of the TransactionalDB conditions
* described above occurs, or in the case of an unexpected error * described above occurs, or in the case of an unexpected error
*/ */
public void delete(final ColumnFamilyHandle columnFamilyHandle, final byte[] key, public void delete(final ColumnFamilyHandle columnFamilyHandle,
final boolean assume_tracked) throws RocksDBException { final byte[] key, final boolean assumeTracked) throws RocksDBException {
assert (isOwningHandle()); assert (isOwningHandle());
delete(nativeHandle_, key, key.length, columnFamilyHandle.nativeHandle_, assume_tracked); delete(nativeHandle_, key, key.length, columnFamilyHandle.nativeHandle_,
assumeTracked);
} }
/* /**
* Same as * Similar to {@link #delete(ColumnFamilyHandle, byte[], boolean)}
* {@link #delete(ColumnFamilyHandle, byte[], boolean)} * but with {@code assumeTracked = false}.
* with assume_tracked=false. *
* Will also perform conflict checking on the keys be written.
*
* If this Transaction was created on an {@link OptimisticTransactionDB},
* these functions should always succeed.
*
* If this Transaction was created on a {@link TransactionDB}, an
* {@link RocksDBException} may be thrown with an accompanying {@link Status}
* when:
* {@link Status.Code#Busy} if there is a write conflict,
* {@link Status.Code#TimedOut} if a lock could not be acquired,
* {@link Status.Code#TryAgain} if the memtable history size is not large
* enough. See
* {@link ColumnFamilyOptions#maxWriteBufferNumberToMaintain()}
*
* @param columnFamilyHandle The column family to delete the key/value from
* @param key the specified key to be deleted.
*
* @throws RocksDBException when one of the TransactionalDB conditions
* described above occurs, or in the case of an unexpected error
*/ */
public void delete(final ColumnFamilyHandle columnFamilyHandle, public void delete(final ColumnFamilyHandle columnFamilyHandle,
final byte[] key) throws RocksDBException { final byte[] key) throws RocksDBException {
assert(isOwningHandle()); assert(isOwningHandle());
delete(nativeHandle_, key, key.length, columnFamilyHandle.nativeHandle_, delete(nativeHandle_, key, key.length, columnFamilyHandle.nativeHandle_,
/*assume_tracked*/ false); /*assumeTracked*/ false);
} }
/** /**
@ -905,27 +996,41 @@ public class Transaction extends RocksObject {
* *
* @param columnFamilyHandle The column family to delete the key/value from * @param columnFamilyHandle The column family to delete the key/value from
* @param keyParts the specified key to be deleted. * @param keyParts the specified key to be deleted.
* @param assumeTracked true when it is expected that the key is already
* tracked. More specifically, it means the the key was previous tracked
* in the same savepoint, with the same exclusive flag, and at a lower
* sequence number. If valid then it skips ValidateSnapshot,
* throws an error otherwise.
* *
* @throws RocksDBException when one of the TransactionalDB conditions * @throws RocksDBException when one of the TransactionalDB conditions
* described above occurs, or in the case of an unexpected error * described above occurs, or in the case of an unexpected error
*/ */
public void delete(final ColumnFamilyHandle columnFamilyHandle, final byte[][] keyParts, public void delete(final ColumnFamilyHandle columnFamilyHandle,
final boolean assume_tracked) throws RocksDBException { final byte[][] keyParts, final boolean assumeTracked)
throws RocksDBException {
assert (isOwningHandle()); assert (isOwningHandle());
delete( delete(nativeHandle_, keyParts, keyParts.length,
nativeHandle_, keyParts, keyParts.length, columnFamilyHandle.nativeHandle_, assume_tracked); columnFamilyHandle.nativeHandle_, assumeTracked);
} }
/* /**
* Same as * Similar to{@link #delete(ColumnFamilyHandle, byte[][], boolean)}
* {@link #delete(ColumnFamilyHandle, byte[][], boolean)} * but with {@code assumeTracked = false}.
* with assume_tracked=false. *
* Allows you to specify the key in several parts that will be
* concatenated together.
*
* @param columnFamilyHandle The column family to delete the key/value from
* @param keyParts the specified key to be deleted.
*
* @throws RocksDBException when one of the TransactionalDB conditions
* described above occurs, or in the case of an unexpected error
*/ */
public void delete(final ColumnFamilyHandle columnFamilyHandle, public void delete(final ColumnFamilyHandle columnFamilyHandle,
final byte[][] keyParts) throws RocksDBException { final byte[][] keyParts) throws RocksDBException {
assert(isOwningHandle()); assert(isOwningHandle());
delete(nativeHandle_, keyParts, keyParts.length, columnFamilyHandle.nativeHandle_, delete(nativeHandle_, keyParts, keyParts.length,
/*assume_tracked*/ false); columnFamilyHandle.nativeHandle_, false);
} }
//TODO(AR) refactor if we implement org.rocksdb.SliceParts in future //TODO(AR) refactor if we implement org.rocksdb.SliceParts in future
@ -962,28 +1067,53 @@ public class Transaction extends RocksObject {
* *
* @param columnFamilyHandle The column family to delete the key/value from * @param columnFamilyHandle The column family to delete the key/value from
* @param key the specified key to be deleted. * @param key the specified key to be deleted.
* @param assumeTracked true when it is expected that the key is already
* tracked. More specifically, it means the the key was previous tracked
* in the same savepoint, with the same exclusive flag, and at a lower
* sequence number. If valid then it skips ValidateSnapshot,
* throws an error otherwise.
* *
* @throws RocksDBException when one of the TransactionalDB conditions * @throws RocksDBException when one of the TransactionalDB conditions
* described above occurs, or in the case of an unexpected error * described above occurs, or in the case of an unexpected error
*/ */
@Experimental("Performance optimization for a very specific workload") @Experimental("Performance optimization for a very specific workload")
public void singleDelete(final ColumnFamilyHandle columnFamilyHandle, final byte[] key, public void singleDelete(final ColumnFamilyHandle columnFamilyHandle,
final boolean assume_tracked) throws RocksDBException { final byte[] key, final boolean assumeTracked) throws RocksDBException {
assert (isOwningHandle()); assert (isOwningHandle());
singleDelete(nativeHandle_, key, key.length, columnFamilyHandle.nativeHandle_, assume_tracked); singleDelete(nativeHandle_, key, key.length,
columnFamilyHandle.nativeHandle_, assumeTracked);
} }
/* /**
* Same as * Similar to {@link #singleDelete(ColumnFamilyHandle, byte[], boolean)}
* {@link #singleDelete(ColumnFamilyHandle, byte[], boolean)} * but with {@code assumeTracked = false}.
* with assume_tracked=false. *
* will also perform conflict checking on the keys be written.
*
* If this Transaction was created on an {@link OptimisticTransactionDB},
* these functions should always succeed.
*
* If this Transaction was created on a {@link TransactionDB}, an
* {@link RocksDBException} may be thrown with an accompanying {@link Status}
* when:
* {@link Status.Code#Busy} if there is a write conflict,
* {@link Status.Code#TimedOut} if a lock could not be acquired,
* {@link Status.Code#TryAgain} if the memtable history size is not large
* enough. See
* {@link ColumnFamilyOptions#maxWriteBufferNumberToMaintain()}
*
* @param columnFamilyHandle The column family to delete the key/value from
* @param key the specified key to be deleted.
*
* @throws RocksDBException when one of the TransactionalDB conditions
* described above occurs, or in the case of an unexpected error
*/ */
@Experimental("Performance optimization for a very specific workload") @Experimental("Performance optimization for a very specific workload")
public void singleDelete(final ColumnFamilyHandle columnFamilyHandle, final byte[] key) public void singleDelete(final ColumnFamilyHandle columnFamilyHandle,
throws RocksDBException { final byte[] key) throws RocksDBException {
assert(isOwningHandle()); assert(isOwningHandle());
singleDelete(nativeHandle_, key, key.length, columnFamilyHandle.nativeHandle_, singleDelete(nativeHandle_, key, key.length,
/*assume_tracked*/ false); columnFamilyHandle.nativeHandle_, false);
} }
/** /**
@ -1021,29 +1151,43 @@ public class Transaction extends RocksObject {
* *
* @param columnFamilyHandle The column family to delete the key/value from * @param columnFamilyHandle The column family to delete the key/value from
* @param keyParts the specified key to be deleted. * @param keyParts the specified key to be deleted.
* @param assumeTracked true when it is expected that the key is already
* tracked. More specifically, it means the the key was previous tracked
* in the same savepoint, with the same exclusive flag, and at a lower
* sequence number. If valid then it skips ValidateSnapshot,
* throws an error otherwise.
* *
* @throws RocksDBException when one of the TransactionalDB conditions * @throws RocksDBException when one of the TransactionalDB conditions
* described above occurs, or in the case of an unexpected error * described above occurs, or in the case of an unexpected error
*/ */
@Experimental("Performance optimization for a very specific workload") @Experimental("Performance optimization for a very specific workload")
public void singleDelete(final ColumnFamilyHandle columnFamilyHandle, final byte[][] keyParts, public void singleDelete(final ColumnFamilyHandle columnFamilyHandle,
final boolean assume_tracked) throws RocksDBException { final byte[][] keyParts, final boolean assumeTracked)
throws RocksDBException {
assert (isOwningHandle()); assert (isOwningHandle());
singleDelete( singleDelete(nativeHandle_, keyParts, keyParts.length,
nativeHandle_, keyParts, keyParts.length, columnFamilyHandle.nativeHandle_, assume_tracked); columnFamilyHandle.nativeHandle_, assumeTracked);
} }
/* /**
* Same as * Similar to{@link #singleDelete(ColumnFamilyHandle, byte[][], boolean)}
* {@link #singleDelete(ColumnFamilyHandle, byte[][], boolean)} * but with {@code assumeTracked = false}.
* with assume_tracked=false. *
* Allows you to specify the key in several parts that will be
* concatenated together.
*
* @param columnFamilyHandle The column family to delete the key/value from
* @param keyParts the specified key to be deleted.
*
* @throws RocksDBException when one of the TransactionalDB conditions
* described above occurs, or in the case of an unexpected error
*/ */
@Experimental("Performance optimization for a very specific workload") @Experimental("Performance optimization for a very specific workload")
public void singleDelete(final ColumnFamilyHandle columnFamilyHandle, final byte[][] keyParts) public void singleDelete(final ColumnFamilyHandle columnFamilyHandle,
throws RocksDBException { final byte[][] keyParts) throws RocksDBException {
assert(isOwningHandle()); assert(isOwningHandle());
singleDelete(nativeHandle_, keyParts, keyParts.length, columnFamilyHandle.nativeHandle_, singleDelete(nativeHandle_, keyParts, keyParts.length,
/*assume_tracked*/ false); columnFamilyHandle.nativeHandle_, false);
} }
//TODO(AR) refactor if we implement org.rocksdb.SliceParts in future //TODO(AR) refactor if we implement org.rocksdb.SliceParts in future
@ -1756,9 +1900,9 @@ public class Transaction extends RocksObject {
throws RocksDBException; throws RocksDBException;
private native byte[] getForUpdate(final long handle, final long readOptionsHandle, private native byte[] getForUpdate(final long handle, final long readOptionsHandle,
final byte key[], final int keyLength, final long columnFamilyHandle, final boolean exclusive, final byte key[], final int keyLength, final long columnFamilyHandle, final boolean exclusive,
final boolean do_validate) throws RocksDBException; final boolean doValidate) throws RocksDBException;
private native byte[] getForUpdate(final long handle, final long readOptionsHandle, private native byte[] getForUpdate(final long handle, final long readOptionsHandle,
final byte key[], final int keyLen, final boolean exclusive, final boolean do_validate) final byte key[], final int keyLen, final boolean exclusive, final boolean doValidate)
throws RocksDBException; throws RocksDBException;
private native byte[][] multiGetForUpdate(final long handle, private native byte[][] multiGetForUpdate(final long handle,
final long readOptionsHandle, final byte[][] keys, final long readOptionsHandle, final byte[][] keys,
@ -1772,36 +1916,36 @@ public class Transaction extends RocksObject {
final long readOptionsHandle, final long columnFamilyHandle); final long readOptionsHandle, final long columnFamilyHandle);
private native void put(final long handle, final byte[] key, final int keyLength, private native void put(final long handle, final byte[] key, final int keyLength,
final byte[] value, final int valueLength, final long columnFamilyHandle, final byte[] value, final int valueLength, final long columnFamilyHandle,
final boolean assume_tracked) throws RocksDBException; final boolean assumeTracked) throws RocksDBException;
private native void put(final long handle, final byte[] key, private native void put(final long handle, final byte[] key,
final int keyLength, final byte[] value, final int valueLength) final int keyLength, final byte[] value, final int valueLength)
throws RocksDBException; throws RocksDBException;
private native void put(final long handle, final byte[][] keys, final int keysLength, private native void put(final long handle, final byte[][] keys, final int keysLength,
final byte[][] values, final int valuesLength, final long columnFamilyHandle, final byte[][] values, final int valuesLength, final long columnFamilyHandle,
final boolean assume_tracked) throws RocksDBException; final boolean assumeTracked) throws RocksDBException;
private native void put(final long handle, final byte[][] keys, private native void put(final long handle, final byte[][] keys,
final int keysLength, final byte[][] values, final int valuesLength) final int keysLength, final byte[][] values, final int valuesLength)
throws RocksDBException; throws RocksDBException;
private native void merge(final long handle, final byte[] key, final int keyLength, private native void merge(final long handle, final byte[] key, final int keyLength,
final byte[] value, final int valueLength, final long columnFamilyHandle, final byte[] value, final int valueLength, final long columnFamilyHandle,
final boolean assume_tracked) throws RocksDBException; final boolean assumeTracked) throws RocksDBException;
private native void merge(final long handle, final byte[] key, private native void merge(final long handle, final byte[] key,
final int keyLength, final byte[] value, final int valueLength) final int keyLength, final byte[] value, final int valueLength)
throws RocksDBException; throws RocksDBException;
private native void delete(final long handle, final byte[] key, final int keyLength, private native void delete(final long handle, final byte[] key, final int keyLength,
final long columnFamilyHandle, final boolean assume_tracked) throws RocksDBException; final long columnFamilyHandle, final boolean assumeTracked) throws RocksDBException;
private native void delete(final long handle, final byte[] key, private native void delete(final long handle, final byte[] key,
final int keyLength) throws RocksDBException; final int keyLength) throws RocksDBException;
private native void delete(final long handle, final byte[][] keys, final int keysLength, private native void delete(final long handle, final byte[][] keys, final int keysLength,
final long columnFamilyHandle, final boolean assume_tracked) throws RocksDBException; final long columnFamilyHandle, final boolean assumeTracked) throws RocksDBException;
private native void delete(final long handle, final byte[][] keys, private native void delete(final long handle, final byte[][] keys,
final int keysLength) throws RocksDBException; final int keysLength) throws RocksDBException;
private native void singleDelete(final long handle, final byte[] key, final int keyLength, private native void singleDelete(final long handle, final byte[] key, final int keyLength,
final long columnFamilyHandle, final boolean assume_tracked) throws RocksDBException; final long columnFamilyHandle, final boolean assumeTracked) throws RocksDBException;
private native void singleDelete(final long handle, final byte[] key, private native void singleDelete(final long handle, final byte[] key,
final int keyLength) throws RocksDBException; final int keyLength) throws RocksDBException;
private native void singleDelete(final long handle, final byte[][] keys, final int keysLength, private native void singleDelete(final long handle, final byte[][] keys, final int keysLength,
final long columnFamilyHandle, final boolean assume_tracked) throws RocksDBException; final long columnFamilyHandle, final boolean assumeTracked) throws RocksDBException;
private native void singleDelete(final long handle, final byte[][] keys, private native void singleDelete(final long handle, final byte[][] keys,
final int keysLength) throws RocksDBException; final int keysLength) throws RocksDBException;
private native void putUntracked(final long handle, final byte[] key, private native void putUntracked(final long handle, final byte[] key,

View File

@ -83,8 +83,8 @@ public class TransactionDB extends RocksDB
for (int i = 0; i < columnFamilyDescriptors.size(); i++) { for (int i = 0; i < columnFamilyDescriptors.size(); i++) {
final ColumnFamilyDescriptor cfDescriptor = columnFamilyDescriptors final ColumnFamilyDescriptor cfDescriptor = columnFamilyDescriptors
.get(i); .get(i);
cfNames[i] = cfDescriptor.columnFamilyName(); cfNames[i] = cfDescriptor.getName();
cfOptionHandles[i] = cfDescriptor.columnFamilyOptions().nativeHandle_; cfOptionHandles[i] = cfDescriptor.getOptions().nativeHandle_;
} }
final long[] handles = open(dbOptions.nativeHandle_, final long[] handles = open(dbOptions.nativeHandle_,

View File

@ -111,7 +111,7 @@ public class TransactionDBOptions extends RocksObject {
/** /**
* The wait timeout in milliseconds when writing a key * The wait timeout in milliseconds when writing a key
* OUTSIDE of a transaction (ie by calling {@link RocksDB#put}, * OUTSIDE of a transaction (ie by calling {@link RocksDB#put},
* {@link RocksDB#merge}, {@link RocksDB#remove} or {@link RocksDB#write} * {@link RocksDB#merge}, {@link RocksDB#delete} or {@link RocksDB#write}
* directly). * directly).
* *
* If 0, no waiting is done if a lock cannot instantly be acquired. * If 0, no waiting is done if a lock cannot instantly be acquired.
@ -129,7 +129,7 @@ public class TransactionDBOptions extends RocksObject {
/** /**
* If positive, specifies the wait timeout in milliseconds when writing a key * If positive, specifies the wait timeout in milliseconds when writing a key
* OUTSIDE of a transaction (ie by calling {@link RocksDB#put}, * OUTSIDE of a transaction (ie by calling {@link RocksDB#put},
* {@link RocksDB#merge}, {@link RocksDB#remove} or {@link RocksDB#write} * {@link RocksDB#merge}, {@link RocksDB#delete} or {@link RocksDB#write}
* directly). * directly).
* *
* If 0, no waiting is done if a lock cannot instantly be acquired. * If 0, no waiting is done if a lock cannot instantly be acquired.

View File

@ -6,7 +6,7 @@
package org.rocksdb; package org.rocksdb;
public class TransactionOptions extends RocksObject public class TransactionOptions extends RocksObject
implements TransactionalOptions { implements TransactionalOptions<TransactionOptions> {
public TransactionOptions() { public TransactionOptions() {
super(newTransactionOptions()); super(newTransactionOptions());

View File

@ -6,7 +6,8 @@
package org.rocksdb; package org.rocksdb;
interface TransactionalOptions extends AutoCloseable { interface TransactionalOptions<T extends TransactionalOptions<T>>
extends AutoCloseable {
/** /**
* True indicates snapshots will be set, just like if * True indicates snapshots will be set, just like if
@ -22,10 +23,9 @@ interface TransactionalOptions extends AutoCloseable {
* *
* Default: false * Default: false
* *
* @param <T> The type of transactional options.
* @param setSnapshot Whether to set a snapshot * @param setSnapshot Whether to set a snapshot
* *
* @return this TransactionalOptions instance * @return this TransactionalOptions instance
*/ */
<T extends TransactionalOptions> T setSetSnapshot(final boolean setSnapshot); T setSetSnapshot(final boolean setSnapshot);
} }

View File

@ -121,8 +121,8 @@ public class TtlDB extends RocksDB {
for (int i = 0; i < columnFamilyDescriptors.size(); i++) { for (int i = 0; i < columnFamilyDescriptors.size(); i++) {
final ColumnFamilyDescriptor cfDescriptor = final ColumnFamilyDescriptor cfDescriptor =
columnFamilyDescriptors.get(i); columnFamilyDescriptors.get(i);
cfNames[i] = cfDescriptor.columnFamilyName(); cfNames[i] = cfDescriptor.getName();
cfOptionHandles[i] = cfDescriptor.columnFamilyOptions().nativeHandle_; cfOptionHandles[i] = cfDescriptor.getOptions().nativeHandle_;
} }
final int ttlVals[] = new int[ttlValues.size()]; final int ttlVals[] = new int[ttlValues.size()];

View File

@ -19,7 +19,7 @@ import static org.rocksdb.Types.intToByte;
/** /**
* Abstract tests for both Comparator and DirectComparator * Abstract tests for both Comparator and DirectComparator
*/ */
public abstract class AbstractComparatorTest { public abstract class AbstractComparatorTest<T extends AbstractSlice<?>> {
/** /**
* Get a comparator which will expect Integer keys * Get a comparator which will expect Integer keys
@ -27,7 +27,7 @@ public abstract class AbstractComparatorTest {
* *
* @return An integer ascending order key comparator * @return An integer ascending order key comparator
*/ */
public abstract AbstractComparator getAscendingIntKeyComparator(); public abstract AbstractComparator<T> getAscendingIntKeyComparator();
/** /**
* Test which stores random keys into the database * Test which stores random keys into the database
@ -42,7 +42,7 @@ public abstract class AbstractComparatorTest {
*/ */
public void testRoundtrip(final Path db_path) throws IOException, public void testRoundtrip(final Path db_path) throws IOException,
RocksDBException { RocksDBException {
try (final AbstractComparator comparator = getAscendingIntKeyComparator(); try (final AbstractComparator<T> comparator = getAscendingIntKeyComparator();
final Options opt = new Options() final Options opt = new Options()
.setCreateIfMissing(true) .setCreateIfMissing(true)
.setComparator(comparator)) { .setComparator(comparator)) {
@ -52,7 +52,7 @@ public abstract class AbstractComparatorTest {
try (final RocksDB db = RocksDB.open(opt, db_path.toString())) { try (final RocksDB db = RocksDB.open(opt, db_path.toString())) {
final Random random = new Random(); final Random random = new Random();
for (int i = 0; i < ITERATIONS; i++) { for (int i = 0; i < ITERATIONS; i++) {
final byte key[] = intToByte(random.nextInt()); final byte[] key = intToByte(random.nextInt());
// does key already exist (avoid duplicates) // does key already exist (avoid duplicates)
if (i > 0 && db.get(key) != null) { if (i > 0 && db.get(key) != null) {
i--; // generate a different key i--; // generate a different key
@ -96,7 +96,7 @@ public abstract class AbstractComparatorTest {
public void testRoundtripCf(final Path db_path) throws IOException, public void testRoundtripCf(final Path db_path) throws IOException,
RocksDBException { RocksDBException {
try(final AbstractComparator comparator = getAscendingIntKeyComparator()) { try(final AbstractComparator<T> comparator = getAscendingIntKeyComparator()) {
final List<ColumnFamilyDescriptor> cfDescriptors = Arrays.asList( final List<ColumnFamilyDescriptor> cfDescriptors = Arrays.asList(
new ColumnFamilyDescriptor(RocksDB.DEFAULT_COLUMN_FAMILY), new ColumnFamilyDescriptor(RocksDB.DEFAULT_COLUMN_FAMILY),
new ColumnFamilyDescriptor("new_cf".getBytes(), new ColumnFamilyDescriptor("new_cf".getBytes(),

View File

@ -18,8 +18,8 @@ import static org.assertj.core.api.Assertions.assertThat;
public class BackupEngineTest { public class BackupEngineTest {
@ClassRule @ClassRule
public static final RocksMemoryResource rocksMemoryResource = public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE =
new RocksMemoryResource(); new RocksNativeLibraryResource();
@Rule @Rule
public TemporaryFolder dbFolder = new TemporaryFolder(); public TemporaryFolder dbFolder = new TemporaryFolder();

View File

@ -20,8 +20,8 @@ public class BackupableDBOptionsTest {
System.getProperty("java.io.tmpdir"); System.getProperty("java.io.tmpdir");
@ClassRule @ClassRule
public static final RocksMemoryResource rocksMemoryResource = public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE =
new RocksMemoryResource(); new RocksNativeLibraryResource();
@Rule @Rule
public ExpectedException exception = ExpectedException.none(); public ExpectedException exception = ExpectedException.none();

View File

@ -18,8 +18,8 @@ import static org.assertj.core.api.Assertions.assertThat;
public class BlockBasedTableConfigTest { public class BlockBasedTableConfigTest {
@ClassRule @ClassRule
public static final RocksMemoryResource rocksMemoryResource = public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE =
new RocksMemoryResource(); new RocksNativeLibraryResource();
@Rule public TemporaryFolder dbFolder = new TemporaryFolder(); @Rule public TemporaryFolder dbFolder = new TemporaryFolder();

View File

@ -12,8 +12,8 @@ import static org.assertj.core.api.Assertions.assertThat;
public class CheckPointTest { public class CheckPointTest {
@ClassRule @ClassRule
public static final RocksMemoryResource rocksMemoryResource = public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE =
new RocksMemoryResource(); new RocksNativeLibraryResource();
@Rule @Rule
public TemporaryFolder dbFolder = new TemporaryFolder(); public TemporaryFolder dbFolder = new TemporaryFolder();

View File

@ -19,8 +19,8 @@ import static org.assertj.core.api.Assertions.assertThat;
public class ColumnFamilyOptionsTest { public class ColumnFamilyOptionsTest {
@ClassRule @ClassRule
public static final RocksMemoryResource rocksMemoryResource = public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE =
new RocksMemoryResource(); new RocksNativeLibraryResource();
public static final Random rand = PlatformRandomHelper. public static final Random rand = PlatformRandomHelper.
getPlatformSpecificRandomFactory(); getPlatformSpecificRandomFactory();

View File

@ -18,8 +18,8 @@ import static org.assertj.core.api.Assertions.assertThat;
public class ColumnFamilyTest { public class ColumnFamilyTest {
@ClassRule @ClassRule
public static final RocksMemoryResource rocksMemoryResource = public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE =
new RocksMemoryResource(); new RocksNativeLibraryResource();
@Rule @Rule
public TemporaryFolder dbFolder = new TemporaryFolder(); public TemporaryFolder dbFolder = new TemporaryFolder();
@ -154,10 +154,10 @@ public class ColumnFamilyTest {
assertThat(retVal).isEqualTo("newcfvalue"); assertThat(retVal).isEqualTo("newcfvalue");
assertThat((db.get(columnFamilyHandleList.get(1), assertThat((db.get(columnFamilyHandleList.get(1),
"dfkey1".getBytes()))).isNull(); "dfkey1".getBytes()))).isNull();
db.remove(columnFamilyHandleList.get(1), "newcfkey1".getBytes()); db.delete(columnFamilyHandleList.get(1), "newcfkey1".getBytes());
assertThat((db.get(columnFamilyHandleList.get(1), assertThat((db.get(columnFamilyHandleList.get(1),
"newcfkey1".getBytes()))).isNull(); "newcfkey1".getBytes()))).isNull();
db.remove(columnFamilyHandleList.get(0), new WriteOptions(), db.delete(columnFamilyHandleList.get(0), new WriteOptions(),
"dfkey2".getBytes()); "dfkey2".getBytes());
assertThat(db.get(columnFamilyHandleList.get(0), new ReadOptions(), assertThat(db.get(columnFamilyHandleList.get(0), new ReadOptions(),
"dfkey2".getBytes())).isNull(); "dfkey2".getBytes())).isNull();
@ -309,8 +309,8 @@ public class ColumnFamilyTest {
"value".getBytes()); "value".getBytes());
writeBatch.put(columnFamilyHandleList.get(1), "newcfkey2".getBytes(), writeBatch.put(columnFamilyHandleList.get(1), "newcfkey2".getBytes(),
"value2".getBytes()); "value2".getBytes());
writeBatch.remove("xyz".getBytes()); writeBatch.delete("xyz".getBytes());
writeBatch.remove(columnFamilyHandleList.get(1), "xyz".getBytes()); writeBatch.delete(columnFamilyHandleList.get(1), "xyz".getBytes());
db.write(writeOpt, writeBatch); db.write(writeOpt, writeBatch);
assertThat(db.get(columnFamilyHandleList.get(1), assertThat(db.get(columnFamilyHandleList.get(1),
@ -396,19 +396,19 @@ public class ColumnFamilyTest {
final List<byte[]> keys = Arrays.asList(new byte[][]{ final List<byte[]> keys = Arrays.asList(new byte[][]{
"key".getBytes(), "newcfkey".getBytes() "key".getBytes(), "newcfkey".getBytes()
}); });
Map<byte[], byte[]> retValues = db.multiGet(columnFamilyHandleList,
List<byte[]> retValues = db.multiGetAsList(columnFamilyHandleList, keys);
assertThat(retValues.size()).isEqualTo(2);
assertThat(new String(retValues.get(0)))
.isEqualTo("value");
assertThat(new String(retValues.get(1)))
.isEqualTo("value");
retValues = db.multiGetAsList(new ReadOptions(), columnFamilyHandleList,
keys); keys);
assertThat(retValues.size()).isEqualTo(2); assertThat(retValues.size()).isEqualTo(2);
assertThat(new String(retValues.get(keys.get(0)))) assertThat(new String(retValues.get(0)))
.isEqualTo("value"); .isEqualTo("value");
assertThat(new String(retValues.get(keys.get(1)))) assertThat(new String(retValues.get(1)))
.isEqualTo("value");
retValues = db.multiGet(new ReadOptions(), columnFamilyHandleList,
keys);
assertThat(retValues.size()).isEqualTo(2);
assertThat(new String(retValues.get(keys.get(0))))
.isEqualTo("value");
assertThat(new String(retValues.get(keys.get(1))))
.isEqualTo("value"); .isEqualTo("value");
} finally { } finally {
for (final ColumnFamilyHandle columnFamilyHandle : for (final ColumnFamilyHandle columnFamilyHandle :
@ -590,7 +590,7 @@ public class ColumnFamilyTest {
cfDescriptors, columnFamilyHandleList)) { cfDescriptors, columnFamilyHandleList)) {
try { try {
db.dropColumnFamily(columnFamilyHandleList.get(1)); db.dropColumnFamily(columnFamilyHandleList.get(1));
db.remove(columnFamilyHandleList.get(1), "key".getBytes()); db.delete(columnFamilyHandleList.get(1), "key".getBytes());
} finally { } finally {
for (final ColumnFamilyHandle columnFamilyHandle : for (final ColumnFamilyHandle columnFamilyHandle :
columnFamilyHandleList) { columnFamilyHandleList) {
@ -639,7 +639,7 @@ public class ColumnFamilyTest {
keys.add("key".getBytes()); keys.add("key".getBytes());
keys.add("newcfkey".getBytes()); keys.add("newcfkey".getBytes());
final List<ColumnFamilyHandle> cfCustomList = new ArrayList<>(); final List<ColumnFamilyHandle> cfCustomList = new ArrayList<>();
db.multiGet(cfCustomList, keys); db.multiGetAsList(cfCustomList, keys);
} finally { } finally {
for (final ColumnFamilyHandle columnFamilyHandle : for (final ColumnFamilyHandle columnFamilyHandle :

View File

@ -13,8 +13,8 @@ import static org.assertj.core.api.Assertions.assertThat;
public class CompactionJobInfoTest { public class CompactionJobInfoTest {
@ClassRule @ClassRule
public static final RocksMemoryResource rocksMemoryResource = public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE =
new RocksMemoryResource(); new RocksNativeLibraryResource();
@Test @Test
public void columnFamilyName() { public void columnFamilyName() {

View File

@ -13,8 +13,8 @@ import static org.assertj.core.api.Assertions.assertThat;
public class CompactionJobStatsTest { public class CompactionJobStatsTest {
@ClassRule @ClassRule
public static final RocksMemoryResource rocksMemoryResource = public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE =
new RocksMemoryResource(); new RocksNativeLibraryResource();
@Test @Test
public void reset() { public void reset() {

View File

@ -13,8 +13,8 @@ import static org.assertj.core.api.Assertions.assertThat;
public class CompactionOptionsTest { public class CompactionOptionsTest {
@ClassRule @ClassRule
public static final RocksMemoryResource rocksMemoryResource = public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE =
new RocksMemoryResource(); new RocksNativeLibraryResource();
@Test @Test
public void compression() { public void compression() {

View File

@ -13,8 +13,8 @@ import static org.assertj.core.api.Assertions.assertThat;
public class ComparatorOptionsTest { public class ComparatorOptionsTest {
@ClassRule @ClassRule
public static final RocksMemoryResource rocksMemoryResource = public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE =
new RocksMemoryResource(); new RocksNativeLibraryResource();
@Test @Test
public void comparatorOptions() { public void comparatorOptions() {

View File

@ -18,8 +18,8 @@ import static org.assertj.core.api.Assertions.assertThat;
public class ComparatorTest { public class ComparatorTest {
@ClassRule @ClassRule
public static final RocksMemoryResource rocksMemoryResource = public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE =
new RocksMemoryResource(); new RocksNativeLibraryResource();
@Rule @Rule
public TemporaryFolder dbFolder = new TemporaryFolder(); public TemporaryFolder dbFolder = new TemporaryFolder();
@ -27,9 +27,9 @@ public class ComparatorTest {
@Test @Test
public void javaComparator() throws IOException, RocksDBException { public void javaComparator() throws IOException, RocksDBException {
final AbstractComparatorTest comparatorTest = new AbstractComparatorTest() { final AbstractComparatorTest<Slice> comparatorTest = new AbstractComparatorTest<Slice>() {
@Override @Override
public AbstractComparator getAscendingIntKeyComparator() { public AbstractComparator<Slice> getAscendingIntKeyComparator() {
return new Comparator(new ComparatorOptions()) { return new Comparator(new ComparatorOptions()) {
@Override @Override
@ -53,9 +53,9 @@ public class ComparatorTest {
@Test @Test
public void javaComparatorCf() throws IOException, RocksDBException { public void javaComparatorCf() throws IOException, RocksDBException {
final AbstractComparatorTest comparatorTest = new AbstractComparatorTest() { final AbstractComparatorTest<Slice> comparatorTest = new AbstractComparatorTest<Slice>() {
@Override @Override
public AbstractComparator getAscendingIntKeyComparator() { public AbstractComparator<Slice> getAscendingIntKeyComparator() {
return new Comparator(new ComparatorOptions()) { return new Comparator(new ComparatorOptions()) {
@Override @Override

View File

@ -16,8 +16,8 @@ import static org.assertj.core.api.Assertions.assertThat;
public class DBOptionsTest { public class DBOptionsTest {
@ClassRule @ClassRule
public static final RocksMemoryResource rocksMemoryResource = public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE =
new RocksMemoryResource(); new RocksNativeLibraryResource();
public static final Random rand = PlatformRandomHelper. public static final Random rand = PlatformRandomHelper.
getPlatformSpecificRandomFactory(); getPlatformSpecificRandomFactory();
@ -27,7 +27,7 @@ public class DBOptionsTest {
DBOptions origOpts = new DBOptions(); DBOptions origOpts = new DBOptions();
origOpts.setCreateIfMissing(rand.nextBoolean()); origOpts.setCreateIfMissing(rand.nextBoolean());
origOpts.setAllow2pc(rand.nextBoolean()); origOpts.setAllow2pc(rand.nextBoolean());
origOpts.setBaseBackgroundCompactions(rand.nextInt(10)); origOpts.setMaxBackgroundJobs(rand.nextInt(10));
DBOptions copyOpts = new DBOptions(origOpts); DBOptions copyOpts = new DBOptions(origOpts);
assertThat(origOpts.createIfMissing()).isEqualTo(copyOpts.createIfMissing()); assertThat(origOpts.createIfMissing()).isEqualTo(copyOpts.createIfMissing());
assertThat(origOpts.allow2pc()).isEqualTo(copyOpts.allow2pc()); assertThat(origOpts.allow2pc()).isEqualTo(copyOpts.allow2pc());
@ -215,6 +215,7 @@ public class DBOptionsTest {
} }
} }
@SuppressWarnings("deprecated")
@Test @Test
public void baseBackgroundCompactions() { public void baseBackgroundCompactions() {
try (final DBOptions opt = new DBOptions()) { try (final DBOptions opt = new DBOptions()) {
@ -225,6 +226,7 @@ public class DBOptionsTest {
} }
} }
@SuppressWarnings("deprecated")
@Test @Test
public void maxBackgroundCompactions() { public void maxBackgroundCompactions() {
try(final DBOptions opt = new DBOptions()) { try(final DBOptions opt = new DBOptions()) {
@ -244,6 +246,7 @@ public class DBOptionsTest {
} }
} }
@SuppressWarnings("deprecated")
@Test @Test
public void maxBackgroundFlushes() { public void maxBackgroundFlushes() {
try(final DBOptions opt = new DBOptions()) { try(final DBOptions opt = new DBOptions()) {

View File

@ -18,8 +18,8 @@ import static org.assertj.core.api.Assertions.assertThat;
public class DefaultEnvTest { public class DefaultEnvTest {
@ClassRule @ClassRule
public static final RocksMemoryResource rocksMemoryResource = public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE =
new RocksMemoryResource(); new RocksNativeLibraryResource();
@Rule @Rule
public TemporaryFolder dbFolder = new TemporaryFolder(); public TemporaryFolder dbFolder = new TemporaryFolder();

View File

@ -15,8 +15,8 @@ import java.nio.file.FileSystems;
public class DirectComparatorTest { public class DirectComparatorTest {
@ClassRule @ClassRule
public static final RocksMemoryResource rocksMemoryResource = public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE =
new RocksMemoryResource(); new RocksNativeLibraryResource();
@Rule @Rule
public TemporaryFolder dbFolder = new TemporaryFolder(); public TemporaryFolder dbFolder = new TemporaryFolder();
@ -24,9 +24,9 @@ public class DirectComparatorTest {
@Test @Test
public void directComparator() throws IOException, RocksDBException { public void directComparator() throws IOException, RocksDBException {
final AbstractComparatorTest comparatorTest = new AbstractComparatorTest() { final AbstractComparatorTest<DirectSlice> comparatorTest = new AbstractComparatorTest<DirectSlice>() {
@Override @Override
public AbstractComparator getAscendingIntKeyComparator() { public AbstractComparator<DirectSlice> getAscendingIntKeyComparator() {
return new DirectComparator(new ComparatorOptions()) { return new DirectComparator(new ComparatorOptions()) {
@Override @Override

View File

@ -13,8 +13,8 @@ import static org.assertj.core.api.Assertions.assertThat;
public class DirectSliceTest { public class DirectSliceTest {
@ClassRule @ClassRule
public static final RocksMemoryResource rocksMemoryResource = public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE =
new RocksMemoryResource(); new RocksNativeLibraryResource();
@Test @Test
public void directSlice() { public void directSlice() {

View File

@ -14,7 +14,7 @@ import static org.assertj.core.api.Assertions.assertThat;
public class EnvOptionsTest { public class EnvOptionsTest {
@ClassRule @ClassRule
public static final RocksMemoryResource rocksMemoryResource = new RocksMemoryResource(); public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE = new RocksNativeLibraryResource();
public static final Random rand = PlatformRandomHelper.getPlatformSpecificRandomFactory(); public static final Random rand = PlatformRandomHelper.getPlatformSpecificRandomFactory();

View File

@ -11,8 +11,8 @@ import org.junit.Test;
public class FilterTest { public class FilterTest {
@ClassRule @ClassRule
public static final RocksMemoryResource rocksMemoryResource = public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE =
new RocksMemoryResource(); new RocksNativeLibraryResource();
@Test @Test
public void filter() { public void filter() {
@ -21,17 +21,17 @@ public class FilterTest {
try(final Options options = new Options()) { try(final Options options = new Options()) {
try(final Filter bloomFilter = new BloomFilter()) { try(final Filter bloomFilter = new BloomFilter()) {
blockConfig.setFilter(bloomFilter); blockConfig.setFilterPolicy(bloomFilter);
options.setTableFormatConfig(blockConfig); options.setTableFormatConfig(blockConfig);
} }
try(final Filter bloomFilter = new BloomFilter(10)) { try(final Filter bloomFilter = new BloomFilter(10)) {
blockConfig.setFilter(bloomFilter); blockConfig.setFilterPolicy(bloomFilter);
options.setTableFormatConfig(blockConfig); options.setTableFormatConfig(blockConfig);
} }
try(final Filter bloomFilter = new BloomFilter(10, false)) { try(final Filter bloomFilter = new BloomFilter(10, false)) {
blockConfig.setFilter(bloomFilter); blockConfig.setFilterPolicy(bloomFilter);
options.setTableFormatConfig(blockConfig); options.setTableFormatConfig(blockConfig);
} }
} }

View File

@ -14,8 +14,8 @@ import static org.assertj.core.api.Assertions.assertThat;
public class FlushTest { public class FlushTest {
@ClassRule @ClassRule
public static final RocksMemoryResource rocksMemoryResource = public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE =
new RocksMemoryResource(); new RocksNativeLibraryResource();
@Rule @Rule
public TemporaryFolder dbFolder = new TemporaryFolder(); public TemporaryFolder dbFolder = new TemporaryFolder();

View File

@ -15,8 +15,8 @@ import static java.nio.charset.StandardCharsets.UTF_8;
public class HdfsEnvTest { public class HdfsEnvTest {
@ClassRule @ClassRule
public static final RocksMemoryResource rocksMemoryResource = public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE =
new RocksMemoryResource(); new RocksNativeLibraryResource();
@Rule @Rule
public TemporaryFolder dbFolder = new TemporaryFolder(); public TemporaryFolder dbFolder = new TemporaryFolder();

View File

@ -16,8 +16,8 @@ import static org.assertj.core.api.Assertions.assertThat;
public class InfoLogLevelTest { public class InfoLogLevelTest {
@ClassRule @ClassRule
public static final RocksMemoryResource rocksMemoryResource = public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE =
new RocksMemoryResource(); new RocksNativeLibraryResource();
@Rule @Rule
public TemporaryFolder dbFolder = new TemporaryFolder(); public TemporaryFolder dbFolder = new TemporaryFolder();

View File

@ -14,8 +14,8 @@ import static org.assertj.core.api.Assertions.assertThat;
public class IngestExternalFileOptionsTest { public class IngestExternalFileOptionsTest {
@ClassRule @ClassRule
public static final RocksMemoryResource rocksMemoryResource public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE
= new RocksMemoryResource(); = new RocksNativeLibraryResource();
public static final Random rand = public static final Random rand =
PlatformRandomHelper.getPlatformSpecificRandomFactory(); PlatformRandomHelper.getPlatformSpecificRandomFactory();

View File

@ -18,8 +18,8 @@ import static org.assertj.core.api.Assertions.assertThat;
public class KeyMayExistTest { public class KeyMayExistTest {
@ClassRule @ClassRule
public static final RocksMemoryResource rocksMemoryResource = public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE =
new RocksMemoryResource(); new RocksNativeLibraryResource();
@Rule @Rule
public TemporaryFolder dbFolder = new TemporaryFolder(); public TemporaryFolder dbFolder = new TemporaryFolder();

View File

@ -15,8 +15,8 @@ import static org.assertj.core.api.Assertions.assertThat;
public class LoggerTest { public class LoggerTest {
@ClassRule @ClassRule
public static final RocksMemoryResource rocksMemoryResource = public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE =
new RocksMemoryResource(); new RocksNativeLibraryResource();
@Rule @Rule
public TemporaryFolder dbFolder = new TemporaryFolder(); public TemporaryFolder dbFolder = new TemporaryFolder();

View File

@ -13,8 +13,8 @@ import static org.assertj.core.api.Assertions.assertThat;
public class MemTableTest { public class MemTableTest {
@ClassRule @ClassRule
public static final RocksMemoryResource rocksMemoryResource = public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE =
new RocksMemoryResource(); new RocksNativeLibraryResource();
@Test @Test
public void hashSkipListMemTable() throws RocksDBException { public void hashSkipListMemTable() throws RocksDBException {

View File

@ -25,8 +25,8 @@ public class MemoryUtilTest {
private final byte[] value = "some-value".getBytes(StandardCharsets.UTF_8); private final byte[] value = "some-value".getBytes(StandardCharsets.UTF_8);
@ClassRule @ClassRule
public static final RocksMemoryResource rocksMemoryResource = public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE =
new RocksMemoryResource(); new RocksNativeLibraryResource();
@Rule public TemporaryFolder dbFolder1 = new TemporaryFolder(); @Rule public TemporaryFolder dbFolder1 = new TemporaryFolder();
@Rule public TemporaryFolder dbFolder2 = new TemporaryFolder(); @Rule public TemporaryFolder dbFolder2 = new TemporaryFolder();

View File

@ -20,8 +20,8 @@ import static org.assertj.core.api.Assertions.assertThat;
public class MergeTest { public class MergeTest {
@ClassRule @ClassRule
public static final RocksMemoryResource rocksMemoryResource = public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE =
new RocksMemoryResource(); new RocksNativeLibraryResource();
@Rule @Rule
public TemporaryFolder dbFolder = new TemporaryFolder(); public TemporaryFolder dbFolder = new TemporaryFolder();

View File

@ -13,8 +13,8 @@ import static org.assertj.core.api.Assertions.assertThat;
public class MixedOptionsTest { public class MixedOptionsTest {
@ClassRule @ClassRule
public static final RocksMemoryResource rocksMemoryResource = public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE =
new RocksMemoryResource(); new RocksNativeLibraryResource();
@Test @Test
public void mixedOptionsTest(){ public void mixedOptionsTest(){
@ -22,7 +22,7 @@ public class MixedOptionsTest {
try(final Filter bloomFilter = new BloomFilter(); try(final Filter bloomFilter = new BloomFilter();
final ColumnFamilyOptions cfOptions = new ColumnFamilyOptions() final ColumnFamilyOptions cfOptions = new ColumnFamilyOptions()
.setTableFormatConfig( .setTableFormatConfig(
new BlockBasedTableConfig().setFilter(bloomFilter)) new BlockBasedTableConfig().setFilterPolicy(bloomFilter))
) { ) {
assertThat(cfOptions.tableFactoryName()).isEqualTo( assertThat(cfOptions.tableFactoryName()).isEqualTo(
"BlockBasedTable"); "BlockBasedTable");

View File

@ -18,8 +18,8 @@ import static org.assertj.core.api.Assertions.assertThat;
public class OptionsTest { public class OptionsTest {
@ClassRule @ClassRule
public static final RocksMemoryResource rocksMemoryResource = public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE =
new RocksMemoryResource(); new RocksNativeLibraryResource();
public static final Random rand = PlatformRandomHelper. public static final Random rand = PlatformRandomHelper.
getPlatformSpecificRandomFactory(); getPlatformSpecificRandomFactory();
@ -428,6 +428,7 @@ public class OptionsTest {
} }
} }
@SuppressWarnings("deprecated")
@Test @Test
public void baseBackgroundCompactions() { public void baseBackgroundCompactions() {
try (final Options opt = new Options()) { try (final Options opt = new Options()) {
@ -438,6 +439,7 @@ public class OptionsTest {
} }
} }
@SuppressWarnings("deprecated")
@Test @Test
public void maxBackgroundCompactions() { public void maxBackgroundCompactions() {
try (final Options opt = new Options()) { try (final Options opt = new Options()) {
@ -458,6 +460,7 @@ public class OptionsTest {
} }
} }
@SuppressWarnings("deprecated")
@Test @Test
public void maxBackgroundFlushes() { public void maxBackgroundFlushes() {
try (final Options opt = new Options()) { try (final Options opt = new Options()) {

View File

@ -16,7 +16,7 @@ import static org.assertj.core.api.Assertions.assertThat;
public class OptionsUtilTest { public class OptionsUtilTest {
@ClassRule @ClassRule
public static final RocksMemoryResource rocksMemoryResource = new RocksMemoryResource(); public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE = new RocksNativeLibraryResource();
@Rule public TemporaryFolder dbFolder = new TemporaryFolder(); @Rule public TemporaryFolder dbFolder = new TemporaryFolder();
@ -94,10 +94,10 @@ public class OptionsUtilTest {
assertThat(cfDescs.size()).isEqualTo(2); assertThat(cfDescs.size()).isEqualTo(2);
assertThat(cfDescs.get(0)).isNotNull(); assertThat(cfDescs.get(0)).isNotNull();
assertThat(cfDescs.get(1)).isNotNull(); assertThat(cfDescs.get(1)).isNotNull();
assertThat(cfDescs.get(0).columnFamilyName()).isEqualTo(RocksDB.DEFAULT_COLUMN_FAMILY); assertThat(cfDescs.get(0).getName()).isEqualTo(RocksDB.DEFAULT_COLUMN_FAMILY);
assertThat(cfDescs.get(1).columnFamilyName()).isEqualTo(secondCFName); assertThat(cfDescs.get(1).getName()).isEqualTo(secondCFName);
ColumnFamilyOptions defaultCFOpts = cfDescs.get(0).columnFamilyOptions(); ColumnFamilyOptions defaultCFOpts = cfDescs.get(0).getOptions();
assertThat(defaultCFOpts.writeBufferSize()).isEqualTo(baseDefaultCFOpts.writeBufferSize()); assertThat(defaultCFOpts.writeBufferSize()).isEqualTo(baseDefaultCFOpts.writeBufferSize());
assertThat(defaultCFOpts.maxWriteBufferNumber()) assertThat(defaultCFOpts.maxWriteBufferNumber())
.isEqualTo(baseDefaultCFOpts.maxWriteBufferNumber()); .isEqualTo(baseDefaultCFOpts.maxWriteBufferNumber());
@ -110,7 +110,7 @@ public class OptionsUtilTest {
assertThat(defaultCFOpts.bottommostCompressionType()) assertThat(defaultCFOpts.bottommostCompressionType())
.isEqualTo(baseDefaultCFOpts.bottommostCompressionType()); .isEqualTo(baseDefaultCFOpts.bottommostCompressionType());
ColumnFamilyOptions secondCFOpts = cfDescs.get(1).columnFamilyOptions(); ColumnFamilyOptions secondCFOpts = cfDescs.get(1).getOptions();
assertThat(secondCFOpts.writeBufferSize()).isEqualTo(baseSecondCFOpts.writeBufferSize()); assertThat(secondCFOpts.writeBufferSize()).isEqualTo(baseSecondCFOpts.writeBufferSize());
assertThat(secondCFOpts.maxWriteBufferNumber()) assertThat(secondCFOpts.maxWriteBufferNumber())
.isEqualTo(baseSecondCFOpts.maxWriteBufferNumber()); .isEqualTo(baseSecondCFOpts.maxWriteBufferNumber());

View File

@ -13,8 +13,8 @@ import static org.assertj.core.api.Assertions.assertThat;
public class PlainTableConfigTest { public class PlainTableConfigTest {
@ClassRule @ClassRule
public static final RocksMemoryResource rocksMemoryResource = public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE =
new RocksMemoryResource(); new RocksNativeLibraryResource();
@Test @Test
public void keySize() { public void keySize() {

View File

@ -13,8 +13,8 @@ import static org.rocksdb.RateLimiter.*;
public class RateLimiterTest { public class RateLimiterTest {
@ClassRule @ClassRule
public static final RocksMemoryResource rocksMemoryResource = public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE =
new RocksMemoryResource(); new RocksNativeLibraryResource();
@Test @Test
public void bytesPerSecond() { public void bytesPerSecond() {

View File

@ -18,8 +18,8 @@ import static org.assertj.core.api.Assertions.assertThat;
public class ReadOnlyTest { public class ReadOnlyTest {
@ClassRule @ClassRule
public static final RocksMemoryResource rocksMemoryResource = public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE =
new RocksMemoryResource(); new RocksNativeLibraryResource();
@Rule @Rule
public TemporaryFolder dbFolder = new TemporaryFolder(); public TemporaryFolder dbFolder = new TemporaryFolder();
@ -194,7 +194,7 @@ public class ReadOnlyTest {
dbFolder.getRoot().getAbsolutePath(), cfDescriptors, dbFolder.getRoot().getAbsolutePath(), cfDescriptors,
readOnlyColumnFamilyHandleList)) { readOnlyColumnFamilyHandleList)) {
try { try {
rDb.remove("key".getBytes()); rDb.delete("key".getBytes());
} finally { } finally {
for (final ColumnFamilyHandle columnFamilyHandle : for (final ColumnFamilyHandle columnFamilyHandle :
readOnlyColumnFamilyHandleList) { readOnlyColumnFamilyHandleList) {
@ -224,7 +224,7 @@ public class ReadOnlyTest {
dbFolder.getRoot().getAbsolutePath(), cfDescriptors, dbFolder.getRoot().getAbsolutePath(), cfDescriptors,
readOnlyColumnFamilyHandleList)) { readOnlyColumnFamilyHandleList)) {
try { try {
rDb.remove(readOnlyColumnFamilyHandleList.get(0), rDb.delete(readOnlyColumnFamilyHandleList.get(0),
"key".getBytes()); "key".getBytes());
} finally { } finally {
for (final ColumnFamilyHandle columnFamilyHandle : for (final ColumnFamilyHandle columnFamilyHandle :

View File

@ -18,8 +18,8 @@ import static org.assertj.core.api.Assertions.assertThat;
public class ReadOptionsTest { public class ReadOptionsTest {
@ClassRule @ClassRule
public static final RocksMemoryResource rocksMemoryResource = public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE =
new RocksMemoryResource(); new RocksNativeLibraryResource();
@Rule @Rule
public ExpectedException exception = ExpectedException.none(); public ExpectedException exception = ExpectedException.none();
@ -94,6 +94,7 @@ public class ReadOptionsTest {
} }
} }
@SuppressWarnings("deprecated")
@Test @Test
public void managed() { public void managed() {
try (final ReadOptions opt = new ReadOptions()) { try (final ReadOptions opt = new ReadOptions()) {

View File

@ -18,8 +18,8 @@ import static org.junit.Assert.fail;
public class RocksDBTest { public class RocksDBTest {
@ClassRule @ClassRule
public static final RocksMemoryResource rocksMemoryResource = public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE =
new RocksMemoryResource(); new RocksNativeLibraryResource();
@Rule @Rule
public TemporaryFolder dbFolder = new TemporaryFolder(); public TemporaryFolder dbFolder = new TemporaryFolder();
@ -352,8 +352,9 @@ public class RocksDBTest {
} }
} }
@SuppressWarnings("deprecated")
@Test @Test
public void multiGet() throws RocksDBException, InterruptedException { public void multiGet() throws RocksDBException {
try (final RocksDB db = RocksDB.open(dbFolder.getRoot().getAbsolutePath()); try (final RocksDB db = RocksDB.open(dbFolder.getRoot().getAbsolutePath());
final ReadOptions rOpt = new ReadOptions()) { final ReadOptions rOpt = new ReadOptions()) {
db.put("key1".getBytes(), "value".getBytes()); db.put("key1".getBytes(), "value".getBytes());
@ -392,7 +393,7 @@ public class RocksDBTest {
} }
@Test @Test
public void multiGetAsList() throws RocksDBException, InterruptedException { public void multiGetAsList() throws RocksDBException {
try (final RocksDB db = RocksDB.open(dbFolder.getRoot().getAbsolutePath()); try (final RocksDB db = RocksDB.open(dbFolder.getRoot().getAbsolutePath());
final ReadOptions rOpt = new ReadOptions()) { final ReadOptions rOpt = new ReadOptions()) {
db.put("key1".getBytes(), "value".getBytes()); db.put("key1".getBytes(), "value".getBytes());
@ -690,8 +691,13 @@ public class RocksDBTest {
db.put((String.valueOf(i)).getBytes(), b); db.put((String.valueOf(i)).getBytes(), b);
} }
db.flush(new FlushOptions().setWaitForFlush(true)); db.flush(new FlushOptions().setWaitForFlush(true));
db.compactRange("0".getBytes(), "201".getBytes(), try (final CompactRangeOptions compactRangeOpts = new CompactRangeOptions()
true, -1, 0); .setChangeLevel(true)
.setTargetLevel(-1)
.setTargetPathId(0)) {
db.compactRange(null, "0".getBytes(), "201".getBytes(),
compactRangeOpts);
}
} }
} }
@ -775,7 +781,10 @@ public class RocksDBTest {
dbFolder.getRoot().getAbsolutePath(), dbFolder.getRoot().getAbsolutePath(),
columnFamilyDescriptors, columnFamilyDescriptors,
columnFamilyHandles)) { columnFamilyHandles)) {
try { try (final CompactRangeOptions compactRangeOpts = new CompactRangeOptions()
.setChangeLevel(true)
.setTargetLevel(-1)
.setTargetPathId(0)) {
// fill database with key/value pairs // fill database with key/value pairs
byte[] b = new byte[10000]; byte[] b = new byte[10000];
for (int i = 0; i < 200; i++) { for (int i = 0; i < 200; i++) {
@ -784,7 +793,7 @@ public class RocksDBTest {
String.valueOf(i).getBytes(), b); String.valueOf(i).getBytes(), b);
} }
db.compactRange(columnFamilyHandles.get(1), "0".getBytes(), db.compactRange(columnFamilyHandles.get(1), "0".getBytes(),
"201".getBytes(), true, -1, 0); "201".getBytes(), compactRangeOpts);
} finally { } finally {
for (final ColumnFamilyHandle handle : columnFamilyHandles) { for (final ColumnFamilyHandle handle : columnFamilyHandles) {
handle.close(); handle.close();

View File

@ -14,8 +14,8 @@ import static org.assertj.core.api.Assertions.assertThat;
public class RocksIteratorTest { public class RocksIteratorTest {
@ClassRule @ClassRule
public static final RocksMemoryResource rocksMemoryResource = public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE =
new RocksMemoryResource(); new RocksNativeLibraryResource();
@Rule @Rule
public TemporaryFolder dbFolder = new TemporaryFolder(); public TemporaryFolder dbFolder = new TemporaryFolder();

View File

@ -6,17 +6,15 @@
package org.rocksdb; package org.rocksdb;
import org.junit.ClassRule; import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
public class RocksMemEnvTest { public class RocksMemEnvTest {
@ClassRule @ClassRule
public static final RocksMemoryResource rocksMemoryResource = public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE =
new RocksMemoryResource(); new RocksNativeLibraryResource();
@Test @Test
public void memEnvFillAndReopen() throws RocksDBException { public void memEnvFillAndReopen() throws RocksDBException {

View File

@ -1,25 +0,0 @@
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
package org.rocksdb;
import org.junit.rules.ExternalResource;
/**
* Resource to trigger garbage collection after each test
* run.
*
* @deprecated Will be removed with the implementation of
* {@link RocksObject#finalize()}
*/
@Deprecated
public class RocksMemoryResource extends ExternalResource {
static {
RocksDB.loadLibrary();
}
@Override
protected void after() {
System.gc();
System.runFinalization();
}
}

View File

@ -0,0 +1,18 @@
// 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.rules.ExternalResource;
/**
* Resource to load the RocksDB JNI library.
*/
public class RocksNativeLibraryResource extends ExternalResource {
@Override
protected void before() {
RocksDB.loadLibrary();
}
}

View File

@ -12,8 +12,8 @@ import static org.assertj.core.api.Assertions.assertThat;
public class SliceTest { public class SliceTest {
@ClassRule @ClassRule
public static final RocksMemoryResource rocksMemoryResource = public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE =
new RocksMemoryResource(); new RocksNativeLibraryResource();
@Test @Test
public void slice() { public void slice() {

View File

@ -14,8 +14,8 @@ import static org.assertj.core.api.Assertions.assertThat;
public class SnapshotTest { public class SnapshotTest {
@ClassRule @ClassRule
public static final RocksMemoryResource rocksMemoryResource = public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE =
new RocksMemoryResource(); new RocksNativeLibraryResource();
@Rule @Rule
public TemporaryFolder dbFolder = new TemporaryFolder(); public TemporaryFolder dbFolder = new TemporaryFolder();

View File

@ -25,8 +25,8 @@ public class SstFileWriterTest {
private static final String DB_DIRECTORY_NAME = "test_db"; private static final String DB_DIRECTORY_NAME = "test_db";
@ClassRule @ClassRule
public static final RocksMemoryResource rocksMemoryResource public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE
= new RocksMemoryResource(); = new RocksNativeLibraryResource();
@Rule public TemporaryFolder parentFolder = new TemporaryFolder(); @Rule public TemporaryFolder parentFolder = new TemporaryFolder();
@ -68,7 +68,7 @@ public class SstFileWriterTest {
comparatorOptions = new ComparatorOptions(); comparatorOptions = new ComparatorOptions();
comparator = new BytewiseComparator(comparatorOptions); comparator = new BytewiseComparator(comparatorOptions);
options.setComparator(comparator); options.setComparator(comparator);
sstFileWriter = new SstFileWriter(envOptions, options, comparator); sstFileWriter = new SstFileWriter(envOptions, options);
} else { } else {
sstFileWriter = new SstFileWriter(envOptions, options); sstFileWriter = new SstFileWriter(envOptions, options);
} }

View File

@ -17,8 +17,8 @@ import static org.assertj.core.api.Assertions.assertThat;
public class StatisticsCollectorTest { public class StatisticsCollectorTest {
@ClassRule @ClassRule
public static final RocksMemoryResource rocksMemoryResource = public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE =
new RocksMemoryResource(); new RocksNativeLibraryResource();
@Rule @Rule
public TemporaryFolder dbFolder = new TemporaryFolder(); public TemporaryFolder dbFolder = new TemporaryFolder();

View File

@ -17,8 +17,8 @@ import static org.assertj.core.api.Assertions.assertThat;
public class StatisticsTest { public class StatisticsTest {
@ClassRule @ClassRule
public static final RocksMemoryResource rocksMemoryResource = public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE =
new RocksMemoryResource(); new RocksNativeLibraryResource();
@Rule @Rule
public TemporaryFolder dbFolder = new TemporaryFolder(); public TemporaryFolder dbFolder = new TemporaryFolder();

View File

@ -15,8 +15,8 @@ import static java.nio.charset.StandardCharsets.UTF_8;
public class TimedEnvTest { public class TimedEnvTest {
@ClassRule @ClassRule
public static final RocksMemoryResource rocksMemoryResource = public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE =
new RocksMemoryResource(); new RocksNativeLibraryResource();
@Rule @Rule
public TemporaryFolder dbFolder = new TemporaryFolder(); public TemporaryFolder dbFolder = new TemporaryFolder();

View File

@ -10,8 +10,8 @@ import static org.assertj.core.api.Assertions.assertThat;
public class TransactionLogIteratorTest { public class TransactionLogIteratorTest {
@ClassRule @ClassRule
public static final RocksMemoryResource rocksMemoryResource = public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE =
new RocksMemoryResource(); new RocksNativeLibraryResource();
@Rule @Rule
public TemporaryFolder dbFolder = new TemporaryFolder(); public TemporaryFolder dbFolder = new TemporaryFolder();

View File

@ -20,8 +20,8 @@ import static org.assertj.core.api.Assertions.assertThat;
public class TtlDBTest { public class TtlDBTest {
@ClassRule @ClassRule
public static final RocksMemoryResource rocksMemoryResource = public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE =
new RocksMemoryResource(); new RocksNativeLibraryResource();
@Rule @Rule
public TemporaryFolder dbFolder = new TemporaryFolder(); public TemporaryFolder dbFolder = new TemporaryFolder();

View File

@ -21,8 +21,8 @@ import static org.rocksdb.util.TestUtil.*;
public class WalFilterTest { public class WalFilterTest {
@ClassRule @ClassRule
public static final RocksMemoryResource rocksMemoryResource = public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE =
new RocksMemoryResource(); new RocksNativeLibraryResource();
@Rule @Rule
public TemporaryFolder dbFolder = new TemporaryFolder(); public TemporaryFolder dbFolder = new TemporaryFolder();

View File

@ -19,8 +19,8 @@ import static org.rocksdb.util.CapturingWriteBatchHandler.Action.*;
public class WriteBatchHandlerTest { public class WriteBatchHandlerTest {
@ClassRule @ClassRule
public static final RocksMemoryResource rocksMemoryResource = public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE =
new RocksMemoryResource(); new RocksNativeLibraryResource();
@Test @Test
public void writeBatchHandler() throws RocksDBException { public void writeBatchHandler() throws RocksDBException {
@ -49,7 +49,7 @@ public class WriteBatchHandlerTest {
break; break;
case DELETE: case DELETE:
batch.remove(testEvent.key); batch.delete(testEvent.key);
break; break;
case LOG: case LOG:

View File

@ -26,8 +26,8 @@ import static java.nio.charset.StandardCharsets.UTF_8;
*/ */
public class WriteBatchTest { public class WriteBatchTest {
@ClassRule @ClassRule
public static final RocksMemoryResource rocksMemoryResource = public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE =
new RocksMemoryResource(); new RocksNativeLibraryResource();
@Rule @Rule
public TemporaryFolder dbFolder = new TemporaryFolder(); public TemporaryFolder dbFolder = new TemporaryFolder();

View File

@ -24,8 +24,8 @@ import static java.nio.charset.StandardCharsets.UTF_8;
public class WriteBatchWithIndexTest { public class WriteBatchWithIndexTest {
@ClassRule @ClassRule
public static final RocksMemoryResource rocksMemoryResource = public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE =
new RocksMemoryResource(); new RocksNativeLibraryResource();
@Rule @Rule
public TemporaryFolder dbFolder = new TemporaryFolder(); public TemporaryFolder dbFolder = new TemporaryFolder();

View File

@ -15,8 +15,8 @@ import static org.assertj.core.api.Assertions.assertThat;
public class WriteOptionsTest { public class WriteOptionsTest {
@ClassRule @ClassRule
public static final RocksMemoryResource rocksMemoryResource = public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE =
new RocksMemoryResource(); new RocksNativeLibraryResource();
public static final Random rand = PlatformRandomHelper. public static final Random rand = PlatformRandomHelper.
getPlatformSpecificRandomFactory(); getPlatformSpecificRandomFactory();

View File

@ -234,7 +234,7 @@ public class BytewiseComparatorTest {
if (map.containsKey(key)) { if (map.containsKey(key)) {
map.remove(key); map.remove(key);
} }
db.remove(new WriteOptions(), bytes(key)); db.delete(new WriteOptions(), bytes(key));
break; break;
default: default:
@ -243,7 +243,7 @@ public class BytewiseComparatorTest {
} }
try(final RocksIterator iter = db.newIterator(new ReadOptions())) { try(final RocksIterator iter = db.newIterator(new ReadOptions())) {
final KVIter<String, String> result_iter = new KVIter(map); final KVIter<String, String> result_iter = new KVIter<>(map);
boolean is_valid = false; boolean is_valid = false;
for (int i = 0; i < num_iter_ops; i++) { for (int i = 0; i < num_iter_ops; i++) {
@ -398,7 +398,7 @@ public class BytewiseComparatorTest {
}; };
} }
private class KVIter<K, V> implements RocksIteratorInterface { private static class KVIter<K, V> implements RocksIteratorInterface {
private final List<Map.Entry<K, V>> entries; private final List<Map.Entry<K, V>> entries;
private final java.util.Comparator<? super K> comparator; private final java.util.Comparator<? super K> comparator;
@ -409,10 +409,7 @@ public class BytewiseComparatorTest {
public KVIter(final TreeMap<K, V> map) { public KVIter(final TreeMap<K, V> map) {
this.entries = new ArrayList<>(); this.entries = new ArrayList<>();
final Iterator<Map.Entry<K, V>> iterator = map.entrySet().iterator(); entries.addAll(map.entrySet());
while(iterator.hasNext()) {
entries.add(iterator.next());
}
this.comparator = map.comparator(); this.comparator = map.comparator();
} }
@ -432,6 +429,7 @@ public class BytewiseComparatorTest {
offset = entries.size() - 1; offset = entries.size() - 1;
} }
@SuppressWarnings("unchecked")
@Override @Override
public void seek(final byte[] target) { public void seek(final byte[] target) {
for(offset = 0; offset < entries.size(); offset++) { for(offset = 0; offset < entries.size(); offset++) {
@ -442,6 +440,7 @@ public class BytewiseComparatorTest {
} }
} }
@SuppressWarnings("unchecked")
@Override @Override
public void seekForPrev(final byte[] target) { public void seekForPrev(final byte[] target) {
for(offset = entries.size()-1; offset >= 0; offset--) { for(offset = entries.size()-1; offset >= 0; offset--) {
@ -492,6 +491,7 @@ public class BytewiseComparatorTest {
} }
} }
@SuppressWarnings("unchecked")
public K key() { public K key() {
if(!isValid()) { if(!isValid()) {
if(entries.isEmpty()) { if(entries.isEmpty()) {
@ -508,6 +508,7 @@ public class BytewiseComparatorTest {
} }
} }
@SuppressWarnings("unchecked")
public V value() { public V value() {
if(!isValid()) { if(!isValid()) {
return (V)""; return (V)"";

View File

@ -224,6 +224,7 @@ public class EnvironmentTest {
setEnvironmentClassField(MUSL_LIBC_FIELD_NAME, INITIAL_MUSL_LIBC); setEnvironmentClassField(MUSL_LIBC_FIELD_NAME, INITIAL_MUSL_LIBC);
} }
@SuppressWarnings("unchecked")
private static <T> T getEnvironmentClassField(String fieldName) { private static <T> T getEnvironmentClassField(String fieldName) {
final Field field; final Field field;
try { try {
@ -235,7 +236,7 @@ public class EnvironmentTest {
modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL); modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);
*/ */
return (T)field.get(null); return (T)field.get(null);
} catch (NoSuchFieldException | IllegalAccessException e) { } catch (final NoSuchFieldException | IllegalAccessException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
} }
@ -251,7 +252,7 @@ public class EnvironmentTest {
modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL); modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);
*/ */
field.set(null, value); field.set(null, value);
} catch (NoSuchFieldException | IllegalAccessException e) { } catch (final NoSuchFieldException | IllegalAccessException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
} }