From 4d3264e4abadad0b7a8653498fa457e966e408d0 Mon Sep 17 00:00:00 2001 From: Adam Retter Date: Fri, 20 Dec 2019 13:39:11 -0800 Subject: [PATCH] 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 --- java/CMakeLists.txt | 2 +- .../org/rocksdb/AbstractMutableOptions.java | 7 +- .../org/rocksdb/BlockBasedTableConfig.java | 7 +- .../java/org/rocksdb/ColumnFamilyOptions.java | 2 +- java/src/main/java/org/rocksdb/DBOptions.java | 5 + java/src/main/java/org/rocksdb/Env.java | 9 + .../main/java/org/rocksdb/HistogramType.java | 26 +- .../main/java/org/rocksdb/InfoLogLevel.java | 2 +- .../java/org/rocksdb/MutableDBOptions.java | 3 + .../org/rocksdb/OptimisticTransactionDB.java | 4 +- .../rocksdb/OptimisticTransactionOptions.java | 2 +- java/src/main/java/org/rocksdb/Options.java | 5 + java/src/main/java/org/rocksdb/RocksDB.java | 103 +++++- .../java/org/rocksdb/SstFileMetaData.java | 12 + .../main/java/org/rocksdb/SstFileReader.java | 10 +- .../src/main/java/org/rocksdb/TickerType.java | 25 +- .../main/java/org/rocksdb/Transaction.java | 312 +++++++++++++----- .../main/java/org/rocksdb/TransactionDB.java | 4 +- .../org/rocksdb/TransactionDBOptions.java | 4 +- .../java/org/rocksdb/TransactionOptions.java | 2 +- .../org/rocksdb/TransactionalOptions.java | 6 +- java/src/main/java/org/rocksdb/TtlDB.java | 4 +- .../org/rocksdb/AbstractComparatorTest.java | 10 +- .../java/org/rocksdb/BackupEngineTest.java | 4 +- .../org/rocksdb/BackupableDBOptionsTest.java | 4 +- .../rocksdb/BlockBasedTableConfigTest.java | 4 +- .../test/java/org/rocksdb/CheckPointTest.java | 4 +- .../org/rocksdb/ColumnFamilyOptionsTest.java | 4 +- .../java/org/rocksdb/ColumnFamilyTest.java | 30 +- .../org/rocksdb/CompactionJobInfoTest.java | 4 +- .../org/rocksdb/CompactionJobStatsTest.java | 4 +- .../org/rocksdb/CompactionOptionsTest.java | 4 +- .../org/rocksdb/ComparatorOptionsTest.java | 4 +- .../test/java/org/rocksdb/ComparatorTest.java | 12 +- .../test/java/org/rocksdb/DBOptionsTest.java | 9 +- .../test/java/org/rocksdb/DefaultEnvTest.java | 4 +- .../org/rocksdb/DirectComparatorTest.java | 8 +- .../java/org/rocksdb/DirectSliceTest.java | 4 +- .../test/java/org/rocksdb/EnvOptionsTest.java | 2 +- .../src/test/java/org/rocksdb/FilterTest.java | 10 +- java/src/test/java/org/rocksdb/FlushTest.java | 4 +- .../test/java/org/rocksdb/HdfsEnvTest.java | 4 +- .../java/org/rocksdb/InfoLogLevelTest.java | 4 +- .../IngestExternalFileOptionsTest.java | 4 +- .../java/org/rocksdb/KeyMayExistTest.java | 4 +- .../src/test/java/org/rocksdb/LoggerTest.java | 4 +- .../test/java/org/rocksdb/MemTableTest.java | 4 +- .../test/java/org/rocksdb/MemoryUtilTest.java | 4 +- java/src/test/java/org/rocksdb/MergeTest.java | 4 +- .../java/org/rocksdb/MixedOptionsTest.java | 6 +- .../test/java/org/rocksdb/OptionsTest.java | 7 +- .../java/org/rocksdb/OptionsUtilTest.java | 10 +- .../org/rocksdb/PlainTableConfigTest.java | 4 +- .../java/org/rocksdb/RateLimiterTest.java | 4 +- .../test/java/org/rocksdb/ReadOnlyTest.java | 8 +- .../java/org/rocksdb/ReadOptionsTest.java | 5 +- .../test/java/org/rocksdb/RocksDBTest.java | 25 +- .../java/org/rocksdb/RocksIteratorTest.java | 4 +- .../java/org/rocksdb/RocksMemEnvTest.java | 6 +- .../java/org/rocksdb/RocksMemoryResource.java | 25 -- .../rocksdb/RocksNativeLibraryResource.java | 18 + java/src/test/java/org/rocksdb/SliceTest.java | 4 +- .../test/java/org/rocksdb/SnapshotTest.java | 4 +- .../java/org/rocksdb/SstFileWriterTest.java | 6 +- .../org/rocksdb/StatisticsCollectorTest.java | 4 +- .../test/java/org/rocksdb/StatisticsTest.java | 4 +- .../test/java/org/rocksdb/TimedEnvTest.java | 4 +- .../rocksdb/TransactionLogIteratorTest.java | 4 +- java/src/test/java/org/rocksdb/TtlDBTest.java | 4 +- .../test/java/org/rocksdb/WalFilterTest.java | 4 +- .../org/rocksdb/WriteBatchHandlerTest.java | 6 +- .../test/java/org/rocksdb/WriteBatchTest.java | 4 +- .../org/rocksdb/WriteBatchWithIndexTest.java | 4 +- .../java/org/rocksdb/WriteOptionsTest.java | 4 +- .../rocksdb/util/BytewiseComparatorTest.java | 15 +- .../org/rocksdb/util/EnvironmentTest.java | 5 +- 76 files changed, 611 insertions(+), 304 deletions(-) delete mode 100644 java/src/test/java/org/rocksdb/RocksMemoryResource.java create mode 100644 java/src/test/java/org/rocksdb/RocksNativeLibraryResource.java diff --git a/java/CMakeLists.txt b/java/CMakeLists.txt index ac46611ca..1951bfa48 100644 --- a/java/CMakeLists.txt +++ b/java/CMakeLists.txt @@ -249,7 +249,7 @@ set(JAVA_TEST_CLASSES src/test/java/org/rocksdb/NativeComparatorWrapperTest.java src/test/java/org/rocksdb/PlatformRandomHelper.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/WriteBatchTest.java src/test/java/org/rocksdb/util/CapturingWriteBatchHandler.java diff --git a/java/src/main/java/org/rocksdb/AbstractMutableOptions.java b/java/src/main/java/org/rocksdb/AbstractMutableOptions.java index 4f843d87e..6180fba15 100644 --- a/java/src/main/java/org/rocksdb/AbstractMutableOptions.java +++ b/java/src/main/java/org/rocksdb/AbstractMutableOptions.java @@ -198,18 +198,19 @@ public abstract class AbstractMutableOptions { return self(); } + @SuppressWarnings("unchecked") protected > N getEnum(final K key) throws NoSuchElementException, NumberFormatException { final MutableOptionValue value = options.get(key); - if(value == null) { + if (value == null) { 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"); } - return ((MutableOptionValue.MutableOptionEnumValue)value).asObject(); + return ((MutableOptionValue.MutableOptionEnumValue) value).asObject(); } public U fromString( diff --git a/java/src/main/java/org/rocksdb/BlockBasedTableConfig.java b/java/src/main/java/org/rocksdb/BlockBasedTableConfig.java index bf5c0c1a9..5bc694af5 100644 --- a/java/src/main/java/org/rocksdb/BlockBasedTableConfig.java +++ b/java/src/main/java/org/rocksdb/BlockBasedTableConfig.java @@ -507,7 +507,12 @@ public class BlockBasedTableConfig extends TableFormatConfig { return this; } - /* + /** + * Set the filter. + * + * @param filter the filter + * @return the reference to the current config. + * * @deprecated Use {@link #setFilterPolicy(Filter)} */ @Deprecated diff --git a/java/src/main/java/org/rocksdb/ColumnFamilyOptions.java b/java/src/main/java/org/rocksdb/ColumnFamilyOptions.java index e57752463..fab36d159 100644 --- a/java/src/main/java/org/rocksdb/ColumnFamilyOptions.java +++ b/java/src/main/java/org/rocksdb/ColumnFamilyOptions.java @@ -66,7 +66,7 @@ public class ColumnFamilyOptions extends RocksObject /** *

Constructor to be used by * {@link #getColumnFamilyOptionsFromProps(java.util.Properties)}, - * {@link ColumnFamilyDescriptor#columnFamilyOptions()} + * {@link ColumnFamilyDescriptor#getOptions()} * and also called via JNI.

* * @param handle native handle to ColumnFamilyOptions instance. diff --git a/java/src/main/java/org/rocksdb/DBOptions.java b/java/src/main/java/org/rocksdb/DBOptions.java index b105230ad..36cc4abd9 100644 --- a/java/src/main/java/org/rocksdb/DBOptions.java +++ b/java/src/main/java/org/rocksdb/DBOptions.java @@ -385,6 +385,7 @@ public class DBOptions extends RocksObject } @Override + @Deprecated public void setBaseBackgroundCompactions( final int baseBackgroundCompactions) { assert(isOwningHandle()); @@ -398,6 +399,7 @@ public class DBOptions extends RocksObject } @Override + @Deprecated public DBOptions setMaxBackgroundCompactions( final int maxBackgroundCompactions) { assert(isOwningHandle()); @@ -406,6 +408,7 @@ public class DBOptions extends RocksObject } @Override + @Deprecated public int maxBackgroundCompactions() { assert(isOwningHandle()); return maxBackgroundCompactions(nativeHandle_); @@ -425,6 +428,7 @@ public class DBOptions extends RocksObject } @Override + @Deprecated public DBOptions setMaxBackgroundFlushes( final int maxBackgroundFlushes) { assert(isOwningHandle()); @@ -433,6 +437,7 @@ public class DBOptions extends RocksObject } @Override + @Deprecated public int maxBackgroundFlushes() { assert(isOwningHandle()); return maxBackgroundFlushes(nativeHandle_); diff --git a/java/src/main/java/org/rocksdb/Env.java b/java/src/main/java/org/rocksdb/Env.java index 1c53b5998..719296a14 100644 --- a/java/src/main/java/org/rocksdb/Env.java +++ b/java/src/main/java/org/rocksdb/Env.java @@ -59,6 +59,8 @@ public abstract class Env extends RocksObject { *

Gets the number of background worker threads of the pool * for this environment.

* + * @param priority the priority id of a specified thread pool. + * * @return the number of threads. */ public int getBackgroundThreads(final Priority priority) { @@ -98,6 +100,7 @@ public abstract class Env extends RocksObject { * pool. * * @param number the number of threads. + * @param priority the priority id of a specified thread pool. * * @return current {@link RocksEnv} instance. */ @@ -111,6 +114,8 @@ public abstract class Env extends RocksObject { * Lower IO priority for threads from the specified pool. * * @param priority the priority id of a specified thread pool. + * + * @return current {@link RocksEnv} instance. */ public Env lowerThreadPoolIOPriority(final Priority priority) { lowerThreadPoolIOPriority(nativeHandle_, priority.getValue()); @@ -121,6 +126,8 @@ public abstract class Env extends RocksObject { * Lower CPU priority for threads from the specified pool. * * @param priority the priority id of a specified thread pool. + * + * @return current {@link RocksEnv} instance. */ public Env lowerThreadPoolCPUPriority(final Priority priority) { 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. * * @return the status of all threads belong to this env. + * + * @throws RocksDBException if the thread list cannot be acquired. */ public List getThreadList() throws RocksDBException { return Arrays.asList(getThreadList(nativeHandle_)); diff --git a/java/src/main/java/org/rocksdb/HistogramType.java b/java/src/main/java/org/rocksdb/HistogramType.java index ab97a4d25..696ee75f2 100644 --- a/java/src/main/java/org/rocksdb/HistogramType.java +++ b/java/src/main/java/org/rocksdb/HistogramType.java @@ -169,12 +169,30 @@ public enum HistogramType { } /** - * @deprecated - * Exposes internal value of native enum mappings. This method will be marked private in the - * next major release. + * Returns the byte value of the enumerations value + * + * @return byte representation */ - @Deprecated public byte getValue() { 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."); + } } diff --git a/java/src/main/java/org/rocksdb/InfoLogLevel.java b/java/src/main/java/org/rocksdb/InfoLogLevel.java index 0051ea39f..b7c0f0700 100644 --- a/java/src/main/java/org/rocksdb/InfoLogLevel.java +++ b/java/src/main/java/org/rocksdb/InfoLogLevel.java @@ -39,7 +39,7 @@ public enum InfoLogLevel { */ public static InfoLogLevel getInfoLogLevel(final byte value) { for (final InfoLogLevel infoLogLevel : InfoLogLevel.values()) { - if (infoLogLevel.getValue() == value){ + if (infoLogLevel.getValue() == value) { return infoLogLevel; } } diff --git a/java/src/main/java/org/rocksdb/MutableDBOptions.java b/java/src/main/java/org/rocksdb/MutableDBOptions.java index 2de658d8f..aca33b136 100644 --- a/java/src/main/java/org/rocksdb/MutableDBOptions.java +++ b/java/src/main/java/org/rocksdb/MutableDBOptions.java @@ -151,6 +151,7 @@ public class MutableDBOptions extends AbstractMutableOptions { } @Override + @Deprecated public void setBaseBackgroundCompactions( final int baseBackgroundCompactions) { setInt(DBOption.base_background_compactions, @@ -163,6 +164,7 @@ public class MutableDBOptions extends AbstractMutableOptions { } @Override + @Deprecated public MutableDBOptionsBuilder setMaxBackgroundCompactions( final int maxBackgroundCompactions) { return setInt(DBOption.max_background_compactions, @@ -170,6 +172,7 @@ public class MutableDBOptions extends AbstractMutableOptions { } @Override + @Deprecated public int maxBackgroundCompactions() { return getInt(DBOption.max_background_compactions); } diff --git a/java/src/main/java/org/rocksdb/OptimisticTransactionDB.java b/java/src/main/java/org/rocksdb/OptimisticTransactionDB.java index 267cab1de..5a2e1f3ed 100644 --- a/java/src/main/java/org/rocksdb/OptimisticTransactionDB.java +++ b/java/src/main/java/org/rocksdb/OptimisticTransactionDB.java @@ -73,8 +73,8 @@ public class OptimisticTransactionDB extends RocksDB for (int i = 0; i < columnFamilyDescriptors.size(); i++) { final ColumnFamilyDescriptor cfDescriptor = columnFamilyDescriptors .get(i); - cfNames[i] = cfDescriptor.columnFamilyName(); - cfOptionHandles[i] = cfDescriptor.columnFamilyOptions().nativeHandle_; + cfNames[i] = cfDescriptor.getName(); + cfOptionHandles[i] = cfDescriptor.getOptions().nativeHandle_; } final long[] handles = open(dbOptions.nativeHandle_, path, cfNames, diff --git a/java/src/main/java/org/rocksdb/OptimisticTransactionOptions.java b/java/src/main/java/org/rocksdb/OptimisticTransactionOptions.java index 650ee2255..6639f79e2 100644 --- a/java/src/main/java/org/rocksdb/OptimisticTransactionOptions.java +++ b/java/src/main/java/org/rocksdb/OptimisticTransactionOptions.java @@ -6,7 +6,7 @@ package org.rocksdb; public class OptimisticTransactionOptions extends RocksObject - implements TransactionalOptions { + implements TransactionalOptions { public OptimisticTransactionOptions() { super(newOptimisticTransactionOptions()); diff --git a/java/src/main/java/org/rocksdb/Options.java b/java/src/main/java/org/rocksdb/Options.java index ed756090d..32ae611f3 100644 --- a/java/src/main/java/org/rocksdb/Options.java +++ b/java/src/main/java/org/rocksdb/Options.java @@ -429,6 +429,7 @@ public class Options extends RocksObject } @Override + @Deprecated public int maxBackgroundCompactions() { assert(isOwningHandle()); return maxBackgroundCompactions(nativeHandle_); @@ -453,6 +454,7 @@ public class Options extends RocksObject } @Override + @Deprecated public void setBaseBackgroundCompactions( final int baseBackgroundCompactions) { assert(isOwningHandle()); @@ -466,6 +468,7 @@ public class Options extends RocksObject } @Override + @Deprecated public Options setMaxBackgroundCompactions( final int maxBackgroundCompactions) { assert(isOwningHandle()); @@ -487,12 +490,14 @@ public class Options extends RocksObject } @Override + @Deprecated public int maxBackgroundFlushes() { assert(isOwningHandle()); return maxBackgroundFlushes(nativeHandle_); } @Override + @Deprecated public Options setMaxBackgroundFlushes( final int maxBackgroundFlushes) { assert(isOwningHandle()); diff --git a/java/src/main/java/org/rocksdb/RocksDB.java b/java/src/main/java/org/rocksdb/RocksDB.java index 0920886c4..25412640b 100644 --- a/java/src/main/java/org/rocksdb/RocksDB.java +++ b/java/src/main/java/org/rocksdb/RocksDB.java @@ -283,8 +283,8 @@ public class RocksDB extends RocksObject { for (int i = 0; i < columnFamilyDescriptors.size(); i++) { final ColumnFamilyDescriptor cfDescriptor = columnFamilyDescriptors .get(i); - cfNames[i] = cfDescriptor.columnFamilyName(); - cfOptionHandles[i] = cfDescriptor.columnFamilyOptions().nativeHandle_; + cfNames[i] = cfDescriptor.getName(); + cfOptionHandles[i] = cfDescriptor.getOptions().nativeHandle_; } 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++) { final ColumnFamilyDescriptor cfDescriptor = columnFamilyDescriptors .get(i); - cfNames[i] = cfDescriptor.columnFamilyName(); - cfOptionHandles[i] = cfDescriptor.columnFamilyOptions().nativeHandle_; + cfNames[i] = cfDescriptor.getName(); + cfOptionHandles[i] = cfDescriptor.getOptions().nativeHandle_; } 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. * * @return the handles to the newly created column families. + * + * @throws RocksDBException if an error occurs whilst creating + * the column families */ public List createColumnFamilies( final ColumnFamilyOptions columnFamilyOptions, @@ -536,6 +539,9 @@ public class RocksDB extends RocksObject { * @param columnFamilyDescriptors the descriptions of the column families. * * @return the handles to the newly created column families. + * + * @throws RocksDBException if an error occurs whilst creating + * the column families */ public List createColumnFamilies( final List columnFamilyDescriptors) @@ -2676,6 +2682,8 @@ public class RocksDB extends RocksObject { * * Note this doesn't reset {@link Options#statistics()} as it is not * owned by DB. + * + * @throws RocksDBException if an error occurs whilst reseting the stats */ public void resetStats() throws RocksDBException { resetStats(nativeHandle_); @@ -3105,13 +3113,15 @@ public class RocksDB extends RocksObject { * @throws RocksDBException thrown if an error occurs within the native * part of the library. */ - public void compactRange(final ColumnFamilyHandle columnFamilyHandle, + public void compactRange( + /* @Nullable */ final ColumnFamilyHandle columnFamilyHandle, final byte[] begin, final byte[] end, final CompactRangeOptions compactRangeOptions) throws RocksDBException { compactRange(nativeHandle_, begin, begin == null ? -1 : begin.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} * instance, or null for the default column family. * @param mutableColumnFamilyOptions the options. + * + * @throws RocksDBException if an error occurs whilst setting the options */ public void setOptions( /* @Nullable */final ColumnFamilyHandle columnFamilyHandle, @@ -3134,6 +3146,8 @@ public class RocksDB extends RocksObject { * Change the options for the default column family handle. * * @param mutableColumnFamilyOptions the options. + * + * @throws RocksDBException if an error occurs whilst setting the options */ public void setOptions( final MutableColumnFamilyOptions mutableColumnFamilyOptions) @@ -3145,6 +3159,8 @@ public class RocksDB extends RocksObject { * Set the options for the column family handle. * * @param mutableDBoptions the options. + * + * @throws RocksDBException if an error occurs whilst setting the options */ public void setDBOptions(final MutableDBOptions mutableDBoptions) 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. * * Note that the behavior is different from @@ -3169,6 +3185,10 @@ public class RocksDB extends RocksObject { * @param compactionJobInfo the compaction job info, this parameter * will be updated with the info from compacting the files, * 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 compactFiles( final CompactionOptions compactionOptions, @@ -3199,6 +3219,10 @@ public class RocksDB extends RocksObject { * @param compactionJobInfo the compaction job info, this parameter * will be updated with the info from compacting the files, * 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 compactFiles( final CompactionOptions compactionOptions, @@ -3221,7 +3245,7 @@ public class RocksDB extends RocksObject { * finish. After it returns, no background process will be run until * {@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 { pauseBackgroundWork(nativeHandle_); @@ -3231,7 +3255,7 @@ public class RocksDB extends RocksObject { * Resumes background work which was suspended by * 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 { continueBackgroundWork(nativeHandle_); @@ -3251,6 +3275,8 @@ public class RocksDB extends RocksObject { * parameter itself within the column family option. * * @param columnFamilyHandles the column family handles + * + * @throws RocksDBException if an error occurs whilst enabling auto-compaction */ public void enableAutoCompaction( final List columnFamilyHandles) @@ -3284,6 +3310,8 @@ public class RocksDB extends RocksObject { /** * Maximum level to which a new compacted memtable is pushed if it * does not create overlap. + * + * @return the maximum level */ public int maxMemCompactionLevel() { return maxMemCompactionLevel(null); @@ -3294,15 +3322,19 @@ public class RocksDB extends RocksObject { * does not create overlap. * * @param columnFamilyHandle the column family handle + * + * @return the maximum level */ public int maxMemCompactionLevel( - /* @Nullable */final ColumnFamilyHandle columnFamilyHandle) { + /* @Nullable */ final ColumnFamilyHandle columnFamilyHandle) { return maxMemCompactionLevel(nativeHandle_, columnFamilyHandle == null ? 0 : columnFamilyHandle.nativeHandle_); } /** * Number of files in level-0 that would stop writes. + * + * @return the number of files */ public int level0StopWriteTrigger() { return level0StopWriteTrigger(null); @@ -3312,6 +3344,8 @@ public class RocksDB extends RocksObject { * Number of files in level-0 that would stop writes. * * @param columnFamilyHandle the column family handle + * + * @return the number of files */ public int level0StopWriteTrigger( /* @Nullable */final ColumnFamilyHandle columnFamilyHandle) { @@ -3407,6 +3441,8 @@ public class RocksDB extends RocksObject { * it calls {@link #syncWal()} afterwards. * * @param sync true to also fsync to disk. + * + * @throws RocksDBException if an error occurs whilst flushing */ public void flushWal(final boolean sync) throws RocksDBException { flushWal(nativeHandle_, sync); @@ -3422,6 +3458,8 @@ public class RocksDB extends RocksObject { * won't be visible until the sync is done. * * Currently only works if {@link Options#allowMmapWrites()} is set to false. + * + * @throws RocksDBException if an error occurs whilst syncing */ public void syncWal() throws RocksDBException { syncWal(nativeHandle_); @@ -3519,6 +3557,9 @@ public class RocksDB extends RocksObject { * See {@link #getLiveFiles(boolean)}. * * @return the live files + * + * @throws RocksDBException if an error occurs whilst retrieving the list + * of live files */ public LiveFiles getLiveFiles() throws RocksDBException { return getLiveFiles(true); @@ -3542,6 +3583,9 @@ public class RocksDB extends RocksObject { * indeterminate time. * * @return the live files + * + * @throws RocksDBException if an error occurs whilst retrieving the list + * of live files */ public LiveFiles getLiveFiles(final boolean flushMemtable) throws RocksDBException { @@ -3559,6 +3603,9 @@ public class RocksDB extends RocksObject { * Retrieve the sorted list of all wal files with earliest file first. * * @return the log files + * + * @throws RocksDBException if an error occurs whilst retrieving the list + * of sorted WAL files */ public List getSortedWalFiles() throws RocksDBException { 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 * * @param name the file name + * + * @throws RocksDBException if an error occurs whilst deleting the file */ public void deleteFile(final String name) throws RocksDBException { deleteFile(nativeHandle_, name); @@ -3710,6 +3759,8 @@ public class RocksDB extends RocksObject { * column family. * * @return the properties + * + * @throws RocksDBException if an error occurs whilst getting the properties */ public Map getPropertiesOfAllTables( /* @Nullable */final ColumnFamilyHandle columnFamilyHandle) @@ -3722,6 +3773,8 @@ public class RocksDB extends RocksObject { * Get the properties of all tables in the default column family. * * @return the properties + * + * @throws RocksDBException if an error occurs whilst getting the properties */ public Map getPropertiesOfAllTables() throws RocksDBException { @@ -3736,6 +3789,8 @@ public class RocksDB extends RocksObject { * @param ranges the ranges over which to get the table properties * * @return the properties + * + * @throws RocksDBException if an error occurs whilst getting the properties */ public Map getPropertiesOfTablesInRange( /* @Nullable */final ColumnFamilyHandle columnFamilyHandle, @@ -3751,6 +3806,8 @@ public class RocksDB extends RocksObject { * @param ranges the ranges over which to get the table properties * * @return the properties + * + * @throws RocksDBException if an error occurs whilst getting the properties */ public Map getPropertiesOfTablesInRange( final List ranges) throws RocksDBException { @@ -3764,6 +3821,8 @@ public class RocksDB extends RocksObject { * column family. * * @return the suggested range. + * + * @throws RocksDBException if an error occurs whilst suggesting the range */ public Range suggestCompactRange( /* @Nullable */final ColumnFamilyHandle columnFamilyHandle) @@ -3778,6 +3837,8 @@ public class RocksDB extends RocksObject { * Suggest the range to compact for the default column family. * * @return the suggested range. + * + * @throws RocksDBException if an error occurs whilst suggesting the range */ public Range suggestCompactRange() throws RocksDBException { @@ -3789,6 +3850,9 @@ public class RocksDB extends RocksObject { * * @param columnFamilyHandle the column family handle, * 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( /* @Nullable */final ColumnFamilyHandle columnFamilyHandle, @@ -3800,6 +3864,10 @@ public class RocksDB extends RocksObject { /** * 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) throws RocksDBException { @@ -3813,6 +3881,8 @@ public class RocksDB extends RocksObject { * * @param traceOptions the options * @param traceWriter the trace writer + * + * @throws RocksDBException if an error occurs whilst starting the trace */ public void startTrace(final TraceOptions traceOptions, final AbstractTraceWriter traceWriter) throws RocksDBException { @@ -3829,23 +3899,28 @@ public class RocksDB extends RocksObject { * Stop tracing DB operations. * * See {@link #startTrace(TraceOptions, AbstractTraceWriter)} + * + * @throws RocksDBException if an error occurs whilst ending the trace */ public void endTrace() throws RocksDBException { 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 * better performance in that case. + * * @param columnFamily - The column family for operation (null for default) * @param includeEnd - Whether ranges should include end * @param ranges - pairs of ranges (from1, to1, from2, to2, ...) + * * @throws RocksDBException thrown if error happens in underlying * native library. */ - public void deleteFilesInRanges(final ColumnFamilyHandle columnFamily, final List ranges, - final boolean includeEnd) throws RocksDBException { + public void deleteFilesInRanges(final ColumnFamilyHandle columnFamily, + final List ranges, final boolean includeEnd) + throws RocksDBException { if (ranges.size() == 0) { return; } diff --git a/java/src/main/java/org/rocksdb/SstFileMetaData.java b/java/src/main/java/org/rocksdb/SstFileMetaData.java index 52e984dff..a04d05cb5 100644 --- a/java/src/main/java/org/rocksdb/SstFileMetaData.java +++ b/java/src/main/java/org/rocksdb/SstFileMetaData.java @@ -23,6 +23,18 @@ public class SstFileMetaData { /** * 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( final String fileName, diff --git a/java/src/main/java/org/rocksdb/SstFileReader.java b/java/src/main/java/org/rocksdb/SstFileReader.java index 53f96e3cc..bb1e94ee0 100644 --- a/java/src/main/java/org/rocksdb/SstFileReader.java +++ b/java/src/main/java/org/rocksdb/SstFileReader.java @@ -60,8 +60,10 @@ public class SstFileReader extends RocksObject { /** * Get the properties of the table. * - * * @return the properties + * + * @throws RocksDBException if an error occurs whilst getting the table + * properties */ public TableProperties getTableProperties() throws RocksDBException { return getTableProperties(nativeHandle_); @@ -70,9 +72,11 @@ public class SstFileReader extends RocksObject { @Override protected final native void disposeInternal(final long handle); 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 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; } diff --git a/java/src/main/java/org/rocksdb/TickerType.java b/java/src/main/java/org/rocksdb/TickerType.java index 40a642bd6..678733513 100644 --- a/java/src/main/java/org/rocksdb/TickerType.java +++ b/java/src/main/java/org/rocksdb/TickerType.java @@ -731,13 +731,30 @@ public enum TickerType { } /** - * @deprecated Exposes internal value of native enum mappings. - * This method will be marked package private in the next major release. + * Returns the byte value of the enumerations value * - * @return the internal representation + * @return byte representation */ - @Deprecated public byte getValue() { 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."); + } } diff --git a/java/src/main/java/org/rocksdb/Transaction.java b/java/src/main/java/org/rocksdb/Transaction.java index 96f1143d4..d59be4c80 100644 --- a/java/src/main/java/org/rocksdb/Transaction.java +++ b/java/src/main/java/org/rocksdb/Transaction.java @@ -433,7 +433,7 @@ public class Transaction extends RocksObject { * @param key the key to retrieve the value for. * @param exclusive true if the transaction should have exclusive access to * 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 * 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, final ColumnFamilyHandle columnFamilyHandle, final byte[] key, final boolean exclusive, - final boolean do_validate) throws RocksDBException { + final boolean doValidate) throws RocksDBException { assert (isOwningHandle()); return getForUpdate(nativeHandle_, readOptions.nativeHandle_, key, key.length, - columnFamilyHandle.nativeHandle_, exclusive, do_validate); + columnFamilyHandle.nativeHandle_, exclusive, doValidate); } /** * Same as * {@link #getForUpdate(ReadOptions, ColumnFamilyHandle, byte[], boolean, boolean)} - * with do_validate=true. + * with doValidate=true. * * @param readOptions Read options. * @param columnFamilyHandle {@link org.rocksdb.ColumnFamilyHandle} @@ -472,7 +472,7 @@ public class Transaction extends RocksObject { final boolean exclusive) throws RocksDBException { assert(isOwningHandle()); 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 { assert(isOwningHandle()); 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 key the specified key to be inserted. * @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 * described above occurs, or in the case of an unexpected error */ - public void put(final ColumnFamilyHandle columnFamilyHandle, final byte[] key, final byte[] value, - final boolean assume_tracked) throws RocksDBException { + public void put(final ColumnFamilyHandle columnFamilyHandle, final byte[] key, + final byte[] value, final boolean assumeTracked) throws RocksDBException { assert (isOwningHandle()); - put(nativeHandle_, key, key.length, value, value.length, columnFamilyHandle.nativeHandle_, - assume_tracked); + put(nativeHandle_, key, key.length, value, value.length, + columnFamilyHandle.nativeHandle_, assumeTracked); } - /* - * Same as - * {@link #put(ColumnFamilyHandle, byte[], byte[], boolean)} - * with assume_tracked=false. + /** + * Similar to {@link #put(ColumnFamilyHandle, byte[], byte[], boolean)} + * but with {@code assumeTracked = 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, final byte[] value) throws RocksDBException { assert(isOwningHandle()); - put(nativeHandle_, key, key.length, value, value.length, columnFamilyHandle.nativeHandle_, - /*assume_tracked*/ false); + put(nativeHandle_, key, key.length, value, value.length, + columnFamilyHandle.nativeHandle_, false); } /** @@ -718,28 +743,43 @@ public class Transaction extends RocksObject { * @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. + * @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 * described above occurs, or in the case of an unexpected error */ - public void put(final ColumnFamilyHandle columnFamilyHandle, final byte[][] keyParts, - final byte[][] valueParts, final boolean assume_tracked) throws RocksDBException { + public void put(final ColumnFamilyHandle columnFamilyHandle, + final byte[][] keyParts, final byte[][] valueParts, + final boolean assumeTracked) throws RocksDBException { assert (isOwningHandle()); put(nativeHandle_, keyParts, keyParts.length, valueParts, valueParts.length, - columnFamilyHandle.nativeHandle_, assume_tracked); + columnFamilyHandle.nativeHandle_, assumeTracked); } - /* - * Same as - * {@link #put(ColumnFamilyHandle, byte[][], byte[][], boolean)} - * with assume_tracked=false. + /** + * Similar to {@link #put(ColumnFamilyHandle, byte[][], byte[][], boolean)} + * but with with {@code assumeTracked = 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, final byte[][] keyParts, final byte[][] valueParts) throws RocksDBException { assert(isOwningHandle()); 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 @@ -780,27 +820,53 @@ public class Transaction extends RocksObject { * @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. + * @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 * described above occurs, or in the case of an unexpected error */ - public void merge(final ColumnFamilyHandle columnFamilyHandle, final byte[] key, - final byte[] value, final boolean assume_tracked) throws RocksDBException { + public void merge(final ColumnFamilyHandle columnFamilyHandle, + final byte[] key, final byte[] value, final boolean assumeTracked) + throws RocksDBException { assert (isOwningHandle()); - merge(nativeHandle_, key, key.length, value, value.length, columnFamilyHandle.nativeHandle_, - assume_tracked); + merge(nativeHandle_, key, key.length, value, value.length, + columnFamilyHandle.nativeHandle_, assumeTracked); } - /* - * Same as - * {@link #merge(ColumnFamilyHandle, byte[], byte[], boolean)} - * with assume_tracked=false. + /** + * Similar to {@link #merge(ColumnFamilyHandle, byte[], byte[], boolean)} + * but with {@code assumeTracked = 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, final byte[] key, final byte[] value) throws RocksDBException { assert(isOwningHandle()); - merge(nativeHandle_, key, key.length, value, value.length, columnFamilyHandle.nativeHandle_, - /*assume_tracked*/ false); + merge(nativeHandle_, key, key.length, value, value.length, + columnFamilyHandle.nativeHandle_, false); } /** @@ -849,26 +915,51 @@ public class Transaction extends RocksObject { * * @param columnFamilyHandle The column family to delete the key/value from * @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 * described above occurs, or in the case of an unexpected error */ - public void delete(final ColumnFamilyHandle columnFamilyHandle, final byte[] key, - final boolean assume_tracked) throws RocksDBException { + public void delete(final ColumnFamilyHandle columnFamilyHandle, + final byte[] key, final boolean assumeTracked) throws RocksDBException { assert (isOwningHandle()); - delete(nativeHandle_, key, key.length, columnFamilyHandle.nativeHandle_, assume_tracked); + delete(nativeHandle_, key, key.length, columnFamilyHandle.nativeHandle_, + assumeTracked); } - /* - * Same as - * {@link #delete(ColumnFamilyHandle, byte[], boolean)} - * with assume_tracked=false. + /** + * Similar to {@link #delete(ColumnFamilyHandle, byte[], boolean)} + * but with {@code assumeTracked = 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, final byte[] key) throws RocksDBException { assert(isOwningHandle()); 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 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 * described above occurs, or in the case of an unexpected error */ - public void delete(final ColumnFamilyHandle columnFamilyHandle, final byte[][] keyParts, - final boolean assume_tracked) throws RocksDBException { + public void delete(final ColumnFamilyHandle columnFamilyHandle, + final byte[][] keyParts, final boolean assumeTracked) + throws RocksDBException { assert (isOwningHandle()); - delete( - nativeHandle_, keyParts, keyParts.length, columnFamilyHandle.nativeHandle_, assume_tracked); + delete(nativeHandle_, keyParts, keyParts.length, + columnFamilyHandle.nativeHandle_, assumeTracked); } - /* - * Same as - * {@link #delete(ColumnFamilyHandle, byte[][], boolean)} - * with assume_tracked=false. + /** + * Similar to{@link #delete(ColumnFamilyHandle, byte[][], boolean)} + * but with {@code assumeTracked = 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, final byte[][] keyParts) throws RocksDBException { assert(isOwningHandle()); - delete(nativeHandle_, keyParts, keyParts.length, columnFamilyHandle.nativeHandle_, - /*assume_tracked*/ false); + delete(nativeHandle_, keyParts, keyParts.length, + columnFamilyHandle.nativeHandle_, false); } //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 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 * described above occurs, or in the case of an unexpected error */ @Experimental("Performance optimization for a very specific workload") - public void singleDelete(final ColumnFamilyHandle columnFamilyHandle, final byte[] key, - final boolean assume_tracked) throws RocksDBException { + public void singleDelete(final ColumnFamilyHandle columnFamilyHandle, + final byte[] key, final boolean assumeTracked) throws RocksDBException { assert (isOwningHandle()); - singleDelete(nativeHandle_, key, key.length, columnFamilyHandle.nativeHandle_, assume_tracked); + singleDelete(nativeHandle_, key, key.length, + columnFamilyHandle.nativeHandle_, assumeTracked); } - /* - * Same as - * {@link #singleDelete(ColumnFamilyHandle, byte[], boolean)} - * with assume_tracked=false. + /** + * Similar to {@link #singleDelete(ColumnFamilyHandle, byte[], boolean)} + * but with {@code assumeTracked = 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") - public void singleDelete(final ColumnFamilyHandle columnFamilyHandle, final byte[] key) - throws RocksDBException { + public void singleDelete(final ColumnFamilyHandle columnFamilyHandle, + final byte[] key) throws RocksDBException { assert(isOwningHandle()); - singleDelete(nativeHandle_, key, key.length, columnFamilyHandle.nativeHandle_, - /*assume_tracked*/ false); + singleDelete(nativeHandle_, key, key.length, + columnFamilyHandle.nativeHandle_, false); } /** @@ -1021,29 +1151,43 @@ public class Transaction extends RocksObject { * * @param columnFamilyHandle The column family to delete the key/value from * @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 * described above occurs, or in the case of an unexpected error */ @Experimental("Performance optimization for a very specific workload") - public void singleDelete(final ColumnFamilyHandle columnFamilyHandle, final byte[][] keyParts, - final boolean assume_tracked) throws RocksDBException { + public void singleDelete(final ColumnFamilyHandle columnFamilyHandle, + final byte[][] keyParts, final boolean assumeTracked) + throws RocksDBException { assert (isOwningHandle()); - singleDelete( - nativeHandle_, keyParts, keyParts.length, columnFamilyHandle.nativeHandle_, assume_tracked); + singleDelete(nativeHandle_, keyParts, keyParts.length, + columnFamilyHandle.nativeHandle_, assumeTracked); } - /* - * Same as - * {@link #singleDelete(ColumnFamilyHandle, byte[][], boolean)} - * with assume_tracked=false. + /** + * Similar to{@link #singleDelete(ColumnFamilyHandle, byte[][], boolean)} + * but with {@code assumeTracked = 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") - public void singleDelete(final ColumnFamilyHandle columnFamilyHandle, final byte[][] keyParts) - throws RocksDBException { + public void singleDelete(final ColumnFamilyHandle columnFamilyHandle, + final byte[][] keyParts) throws RocksDBException { assert(isOwningHandle()); - singleDelete(nativeHandle_, keyParts, keyParts.length, columnFamilyHandle.nativeHandle_, - /*assume_tracked*/ false); + singleDelete(nativeHandle_, keyParts, keyParts.length, + columnFamilyHandle.nativeHandle_, false); } //TODO(AR) refactor if we implement org.rocksdb.SliceParts in future @@ -1756,9 +1900,9 @@ public class Transaction extends RocksObject { throws RocksDBException; private native byte[] getForUpdate(final long handle, final long readOptionsHandle, 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, - 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; private native byte[][] multiGetForUpdate(final long handle, final long readOptionsHandle, final byte[][] keys, @@ -1772,36 +1916,36 @@ public class Transaction extends RocksObject { final long readOptionsHandle, final long columnFamilyHandle); private native void put(final long handle, final byte[] key, final int keyLength, 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, final int keyLength, final byte[] value, final int valueLength) throws RocksDBException; private native void put(final long handle, final byte[][] keys, final int keysLength, 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, final int keysLength, final byte[][] values, final int valuesLength) throws RocksDBException; private native void merge(final long handle, final byte[] key, final int keyLength, 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, final int keyLength, final byte[] value, final int valueLength) throws RocksDBException; 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, final int keyLength) throws RocksDBException; 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, final int keysLength) throws RocksDBException; 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, final int keyLength) throws RocksDBException; 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, final int keysLength) throws RocksDBException; private native void putUntracked(final long handle, final byte[] key, diff --git a/java/src/main/java/org/rocksdb/TransactionDB.java b/java/src/main/java/org/rocksdb/TransactionDB.java index a1a09cf96..7a6259975 100644 --- a/java/src/main/java/org/rocksdb/TransactionDB.java +++ b/java/src/main/java/org/rocksdb/TransactionDB.java @@ -83,8 +83,8 @@ public class TransactionDB extends RocksDB for (int i = 0; i < columnFamilyDescriptors.size(); i++) { final ColumnFamilyDescriptor cfDescriptor = columnFamilyDescriptors .get(i); - cfNames[i] = cfDescriptor.columnFamilyName(); - cfOptionHandles[i] = cfDescriptor.columnFamilyOptions().nativeHandle_; + cfNames[i] = cfDescriptor.getName(); + cfOptionHandles[i] = cfDescriptor.getOptions().nativeHandle_; } final long[] handles = open(dbOptions.nativeHandle_, diff --git a/java/src/main/java/org/rocksdb/TransactionDBOptions.java b/java/src/main/java/org/rocksdb/TransactionDBOptions.java index 76f545cde..7f4296a7c 100644 --- a/java/src/main/java/org/rocksdb/TransactionDBOptions.java +++ b/java/src/main/java/org/rocksdb/TransactionDBOptions.java @@ -111,7 +111,7 @@ public class TransactionDBOptions extends RocksObject { /** * The wait timeout in milliseconds when writing a key * 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). * * 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 * 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). * * If 0, no waiting is done if a lock cannot instantly be acquired. diff --git a/java/src/main/java/org/rocksdb/TransactionOptions.java b/java/src/main/java/org/rocksdb/TransactionOptions.java index 1cd936ae6..195fc85e4 100644 --- a/java/src/main/java/org/rocksdb/TransactionOptions.java +++ b/java/src/main/java/org/rocksdb/TransactionOptions.java @@ -6,7 +6,7 @@ package org.rocksdb; public class TransactionOptions extends RocksObject - implements TransactionalOptions { + implements TransactionalOptions { public TransactionOptions() { super(newTransactionOptions()); diff --git a/java/src/main/java/org/rocksdb/TransactionalOptions.java b/java/src/main/java/org/rocksdb/TransactionalOptions.java index 87aaa7986..d55ee900c 100644 --- a/java/src/main/java/org/rocksdb/TransactionalOptions.java +++ b/java/src/main/java/org/rocksdb/TransactionalOptions.java @@ -6,7 +6,8 @@ package org.rocksdb; -interface TransactionalOptions extends AutoCloseable { +interface TransactionalOptions> + extends AutoCloseable { /** * True indicates snapshots will be set, just like if @@ -22,10 +23,9 @@ interface TransactionalOptions extends AutoCloseable { * * Default: false * - * @param The type of transactional options. * @param setSnapshot Whether to set a snapshot * * @return this TransactionalOptions instance */ - T setSetSnapshot(final boolean setSnapshot); + T setSetSnapshot(final boolean setSnapshot); } diff --git a/java/src/main/java/org/rocksdb/TtlDB.java b/java/src/main/java/org/rocksdb/TtlDB.java index 26eee4a87..c1e3bb473 100644 --- a/java/src/main/java/org/rocksdb/TtlDB.java +++ b/java/src/main/java/org/rocksdb/TtlDB.java @@ -121,8 +121,8 @@ public class TtlDB extends RocksDB { for (int i = 0; i < columnFamilyDescriptors.size(); i++) { final ColumnFamilyDescriptor cfDescriptor = columnFamilyDescriptors.get(i); - cfNames[i] = cfDescriptor.columnFamilyName(); - cfOptionHandles[i] = cfDescriptor.columnFamilyOptions().nativeHandle_; + cfNames[i] = cfDescriptor.getName(); + cfOptionHandles[i] = cfDescriptor.getOptions().nativeHandle_; } final int ttlVals[] = new int[ttlValues.size()]; diff --git a/java/src/test/java/org/rocksdb/AbstractComparatorTest.java b/java/src/test/java/org/rocksdb/AbstractComparatorTest.java index 91a1e9994..6c8d3eb79 100644 --- a/java/src/test/java/org/rocksdb/AbstractComparatorTest.java +++ b/java/src/test/java/org/rocksdb/AbstractComparatorTest.java @@ -19,7 +19,7 @@ import static org.rocksdb.Types.intToByte; /** * Abstract tests for both Comparator and DirectComparator */ -public abstract class AbstractComparatorTest { +public abstract class AbstractComparatorTest> { /** * Get a comparator which will expect Integer keys @@ -27,7 +27,7 @@ public abstract class AbstractComparatorTest { * * @return An integer ascending order key comparator */ - public abstract AbstractComparator getAscendingIntKeyComparator(); + public abstract AbstractComparator getAscendingIntKeyComparator(); /** * 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, RocksDBException { - try (final AbstractComparator comparator = getAscendingIntKeyComparator(); + try (final AbstractComparator comparator = getAscendingIntKeyComparator(); final Options opt = new Options() .setCreateIfMissing(true) .setComparator(comparator)) { @@ -52,7 +52,7 @@ public abstract class AbstractComparatorTest { try (final RocksDB db = RocksDB.open(opt, db_path.toString())) { final Random random = new Random(); 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) if (i > 0 && db.get(key) != null) { i--; // generate a different key @@ -96,7 +96,7 @@ public abstract class AbstractComparatorTest { public void testRoundtripCf(final Path db_path) throws IOException, RocksDBException { - try(final AbstractComparator comparator = getAscendingIntKeyComparator()) { + try(final AbstractComparator comparator = getAscendingIntKeyComparator()) { final List cfDescriptors = Arrays.asList( new ColumnFamilyDescriptor(RocksDB.DEFAULT_COLUMN_FAMILY), new ColumnFamilyDescriptor("new_cf".getBytes(), diff --git a/java/src/test/java/org/rocksdb/BackupEngineTest.java b/java/src/test/java/org/rocksdb/BackupEngineTest.java index 7c50df357..de8017a91 100644 --- a/java/src/test/java/org/rocksdb/BackupEngineTest.java +++ b/java/src/test/java/org/rocksdb/BackupEngineTest.java @@ -18,8 +18,8 @@ import static org.assertj.core.api.Assertions.assertThat; public class BackupEngineTest { @ClassRule - public static final RocksMemoryResource rocksMemoryResource = - new RocksMemoryResource(); + public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE = + new RocksNativeLibraryResource(); @Rule public TemporaryFolder dbFolder = new TemporaryFolder(); diff --git a/java/src/test/java/org/rocksdb/BackupableDBOptionsTest.java b/java/src/test/java/org/rocksdb/BackupableDBOptionsTest.java index 0b4992184..a216ba574 100644 --- a/java/src/test/java/org/rocksdb/BackupableDBOptionsTest.java +++ b/java/src/test/java/org/rocksdb/BackupableDBOptionsTest.java @@ -20,8 +20,8 @@ public class BackupableDBOptionsTest { System.getProperty("java.io.tmpdir"); @ClassRule - public static final RocksMemoryResource rocksMemoryResource = - new RocksMemoryResource(); + public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE = + new RocksNativeLibraryResource(); @Rule public ExpectedException exception = ExpectedException.none(); diff --git a/java/src/test/java/org/rocksdb/BlockBasedTableConfigTest.java b/java/src/test/java/org/rocksdb/BlockBasedTableConfigTest.java index fe9f86325..6fdd314cb 100644 --- a/java/src/test/java/org/rocksdb/BlockBasedTableConfigTest.java +++ b/java/src/test/java/org/rocksdb/BlockBasedTableConfigTest.java @@ -18,8 +18,8 @@ import static org.assertj.core.api.Assertions.assertThat; public class BlockBasedTableConfigTest { @ClassRule - public static final RocksMemoryResource rocksMemoryResource = - new RocksMemoryResource(); + public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE = + new RocksNativeLibraryResource(); @Rule public TemporaryFolder dbFolder = new TemporaryFolder(); diff --git a/java/src/test/java/org/rocksdb/CheckPointTest.java b/java/src/test/java/org/rocksdb/CheckPointTest.java index 9b1ea209a..c2cc6fc62 100644 --- a/java/src/test/java/org/rocksdb/CheckPointTest.java +++ b/java/src/test/java/org/rocksdb/CheckPointTest.java @@ -12,8 +12,8 @@ import static org.assertj.core.api.Assertions.assertThat; public class CheckPointTest { @ClassRule - public static final RocksMemoryResource rocksMemoryResource = - new RocksMemoryResource(); + public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE = + new RocksNativeLibraryResource(); @Rule public TemporaryFolder dbFolder = new TemporaryFolder(); diff --git a/java/src/test/java/org/rocksdb/ColumnFamilyOptionsTest.java b/java/src/test/java/org/rocksdb/ColumnFamilyOptionsTest.java index 2cd8f0de9..af67f4663 100644 --- a/java/src/test/java/org/rocksdb/ColumnFamilyOptionsTest.java +++ b/java/src/test/java/org/rocksdb/ColumnFamilyOptionsTest.java @@ -19,8 +19,8 @@ import static org.assertj.core.api.Assertions.assertThat; public class ColumnFamilyOptionsTest { @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(); diff --git a/java/src/test/java/org/rocksdb/ColumnFamilyTest.java b/java/src/test/java/org/rocksdb/ColumnFamilyTest.java index 84815b476..cc8199ec4 100644 --- a/java/src/test/java/org/rocksdb/ColumnFamilyTest.java +++ b/java/src/test/java/org/rocksdb/ColumnFamilyTest.java @@ -18,8 +18,8 @@ import static org.assertj.core.api.Assertions.assertThat; public class ColumnFamilyTest { @ClassRule - public static final RocksMemoryResource rocksMemoryResource = - new RocksMemoryResource(); + public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE = + new RocksNativeLibraryResource(); @Rule public TemporaryFolder dbFolder = new TemporaryFolder(); @@ -154,10 +154,10 @@ public class ColumnFamilyTest { assertThat(retVal).isEqualTo("newcfvalue"); assertThat((db.get(columnFamilyHandleList.get(1), "dfkey1".getBytes()))).isNull(); - db.remove(columnFamilyHandleList.get(1), "newcfkey1".getBytes()); + db.delete(columnFamilyHandleList.get(1), "newcfkey1".getBytes()); assertThat((db.get(columnFamilyHandleList.get(1), "newcfkey1".getBytes()))).isNull(); - db.remove(columnFamilyHandleList.get(0), new WriteOptions(), + db.delete(columnFamilyHandleList.get(0), new WriteOptions(), "dfkey2".getBytes()); assertThat(db.get(columnFamilyHandleList.get(0), new ReadOptions(), "dfkey2".getBytes())).isNull(); @@ -309,8 +309,8 @@ public class ColumnFamilyTest { "value".getBytes()); writeBatch.put(columnFamilyHandleList.get(1), "newcfkey2".getBytes(), "value2".getBytes()); - writeBatch.remove("xyz".getBytes()); - writeBatch.remove(columnFamilyHandleList.get(1), "xyz".getBytes()); + writeBatch.delete("xyz".getBytes()); + writeBatch.delete(columnFamilyHandleList.get(1), "xyz".getBytes()); db.write(writeOpt, writeBatch); assertThat(db.get(columnFamilyHandleList.get(1), @@ -396,19 +396,19 @@ public class ColumnFamilyTest { final List keys = Arrays.asList(new byte[][]{ "key".getBytes(), "newcfkey".getBytes() }); - Map retValues = db.multiGet(columnFamilyHandleList, - keys); + + List retValues = db.multiGetAsList(columnFamilyHandleList, keys); assertThat(retValues.size()).isEqualTo(2); - assertThat(new String(retValues.get(keys.get(0)))) + assertThat(new String(retValues.get(0))) .isEqualTo("value"); - assertThat(new String(retValues.get(keys.get(1)))) + assertThat(new String(retValues.get(1))) .isEqualTo("value"); - retValues = db.multiGet(new ReadOptions(), columnFamilyHandleList, + retValues = db.multiGetAsList(new ReadOptions(), columnFamilyHandleList, keys); assertThat(retValues.size()).isEqualTo(2); - assertThat(new String(retValues.get(keys.get(0)))) + assertThat(new String(retValues.get(0))) .isEqualTo("value"); - assertThat(new String(retValues.get(keys.get(1)))) + assertThat(new String(retValues.get(1))) .isEqualTo("value"); } finally { for (final ColumnFamilyHandle columnFamilyHandle : @@ -590,7 +590,7 @@ public class ColumnFamilyTest { cfDescriptors, columnFamilyHandleList)) { try { db.dropColumnFamily(columnFamilyHandleList.get(1)); - db.remove(columnFamilyHandleList.get(1), "key".getBytes()); + db.delete(columnFamilyHandleList.get(1), "key".getBytes()); } finally { for (final ColumnFamilyHandle columnFamilyHandle : columnFamilyHandleList) { @@ -639,7 +639,7 @@ public class ColumnFamilyTest { keys.add("key".getBytes()); keys.add("newcfkey".getBytes()); final List cfCustomList = new ArrayList<>(); - db.multiGet(cfCustomList, keys); + db.multiGetAsList(cfCustomList, keys); } finally { for (final ColumnFamilyHandle columnFamilyHandle : diff --git a/java/src/test/java/org/rocksdb/CompactionJobInfoTest.java b/java/src/test/java/org/rocksdb/CompactionJobInfoTest.java index 6c920439c..c71b0da16 100644 --- a/java/src/test/java/org/rocksdb/CompactionJobInfoTest.java +++ b/java/src/test/java/org/rocksdb/CompactionJobInfoTest.java @@ -13,8 +13,8 @@ import static org.assertj.core.api.Assertions.assertThat; public class CompactionJobInfoTest { @ClassRule - public static final RocksMemoryResource rocksMemoryResource = - new RocksMemoryResource(); + public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE = + new RocksNativeLibraryResource(); @Test public void columnFamilyName() { diff --git a/java/src/test/java/org/rocksdb/CompactionJobStatsTest.java b/java/src/test/java/org/rocksdb/CompactionJobStatsTest.java index 7be7226da..5c1eb2aab 100644 --- a/java/src/test/java/org/rocksdb/CompactionJobStatsTest.java +++ b/java/src/test/java/org/rocksdb/CompactionJobStatsTest.java @@ -13,8 +13,8 @@ import static org.assertj.core.api.Assertions.assertThat; public class CompactionJobStatsTest { @ClassRule - public static final RocksMemoryResource rocksMemoryResource = - new RocksMemoryResource(); + public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE = + new RocksNativeLibraryResource(); @Test public void reset() { diff --git a/java/src/test/java/org/rocksdb/CompactionOptionsTest.java b/java/src/test/java/org/rocksdb/CompactionOptionsTest.java index b1726e866..9b7d79694 100644 --- a/java/src/test/java/org/rocksdb/CompactionOptionsTest.java +++ b/java/src/test/java/org/rocksdb/CompactionOptionsTest.java @@ -13,8 +13,8 @@ import static org.assertj.core.api.Assertions.assertThat; public class CompactionOptionsTest { @ClassRule - public static final RocksMemoryResource rocksMemoryResource = - new RocksMemoryResource(); + public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE = + new RocksNativeLibraryResource(); @Test public void compression() { diff --git a/java/src/test/java/org/rocksdb/ComparatorOptionsTest.java b/java/src/test/java/org/rocksdb/ComparatorOptionsTest.java index a45c7173c..371c5580f 100644 --- a/java/src/test/java/org/rocksdb/ComparatorOptionsTest.java +++ b/java/src/test/java/org/rocksdb/ComparatorOptionsTest.java @@ -13,8 +13,8 @@ import static org.assertj.core.api.Assertions.assertThat; public class ComparatorOptionsTest { @ClassRule - public static final RocksMemoryResource rocksMemoryResource = - new RocksMemoryResource(); + public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE = + new RocksNativeLibraryResource(); @Test public void comparatorOptions() { diff --git a/java/src/test/java/org/rocksdb/ComparatorTest.java b/java/src/test/java/org/rocksdb/ComparatorTest.java index 63dee7257..a34147627 100644 --- a/java/src/test/java/org/rocksdb/ComparatorTest.java +++ b/java/src/test/java/org/rocksdb/ComparatorTest.java @@ -18,8 +18,8 @@ import static org.assertj.core.api.Assertions.assertThat; public class ComparatorTest { @ClassRule - public static final RocksMemoryResource rocksMemoryResource = - new RocksMemoryResource(); + public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE = + new RocksNativeLibraryResource(); @Rule public TemporaryFolder dbFolder = new TemporaryFolder(); @@ -27,9 +27,9 @@ public class ComparatorTest { @Test public void javaComparator() throws IOException, RocksDBException { - final AbstractComparatorTest comparatorTest = new AbstractComparatorTest() { + final AbstractComparatorTest comparatorTest = new AbstractComparatorTest() { @Override - public AbstractComparator getAscendingIntKeyComparator() { + public AbstractComparator getAscendingIntKeyComparator() { return new Comparator(new ComparatorOptions()) { @Override @@ -53,9 +53,9 @@ public class ComparatorTest { @Test public void javaComparatorCf() throws IOException, RocksDBException { - final AbstractComparatorTest comparatorTest = new AbstractComparatorTest() { + final AbstractComparatorTest comparatorTest = new AbstractComparatorTest() { @Override - public AbstractComparator getAscendingIntKeyComparator() { + public AbstractComparator getAscendingIntKeyComparator() { return new Comparator(new ComparatorOptions()) { @Override diff --git a/java/src/test/java/org/rocksdb/DBOptionsTest.java b/java/src/test/java/org/rocksdb/DBOptionsTest.java index 629dbfd10..71cada204 100644 --- a/java/src/test/java/org/rocksdb/DBOptionsTest.java +++ b/java/src/test/java/org/rocksdb/DBOptionsTest.java @@ -16,8 +16,8 @@ import static org.assertj.core.api.Assertions.assertThat; public class DBOptionsTest { @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(); @@ -27,7 +27,7 @@ public class DBOptionsTest { DBOptions origOpts = new DBOptions(); origOpts.setCreateIfMissing(rand.nextBoolean()); origOpts.setAllow2pc(rand.nextBoolean()); - origOpts.setBaseBackgroundCompactions(rand.nextInt(10)); + origOpts.setMaxBackgroundJobs(rand.nextInt(10)); DBOptions copyOpts = new DBOptions(origOpts); assertThat(origOpts.createIfMissing()).isEqualTo(copyOpts.createIfMissing()); assertThat(origOpts.allow2pc()).isEqualTo(copyOpts.allow2pc()); @@ -215,6 +215,7 @@ public class DBOptionsTest { } } + @SuppressWarnings("deprecated") @Test public void baseBackgroundCompactions() { try (final DBOptions opt = new DBOptions()) { @@ -225,6 +226,7 @@ public class DBOptionsTest { } } + @SuppressWarnings("deprecated") @Test public void maxBackgroundCompactions() { try(final DBOptions opt = new DBOptions()) { @@ -244,6 +246,7 @@ public class DBOptionsTest { } } + @SuppressWarnings("deprecated") @Test public void maxBackgroundFlushes() { try(final DBOptions opt = new DBOptions()) { diff --git a/java/src/test/java/org/rocksdb/DefaultEnvTest.java b/java/src/test/java/org/rocksdb/DefaultEnvTest.java index 9e4f04387..3fb563ecb 100644 --- a/java/src/test/java/org/rocksdb/DefaultEnvTest.java +++ b/java/src/test/java/org/rocksdb/DefaultEnvTest.java @@ -18,8 +18,8 @@ import static org.assertj.core.api.Assertions.assertThat; public class DefaultEnvTest { @ClassRule - public static final RocksMemoryResource rocksMemoryResource = - new RocksMemoryResource(); + public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE = + new RocksNativeLibraryResource(); @Rule public TemporaryFolder dbFolder = new TemporaryFolder(); diff --git a/java/src/test/java/org/rocksdb/DirectComparatorTest.java b/java/src/test/java/org/rocksdb/DirectComparatorTest.java index 9b593d056..942952dab 100644 --- a/java/src/test/java/org/rocksdb/DirectComparatorTest.java +++ b/java/src/test/java/org/rocksdb/DirectComparatorTest.java @@ -15,8 +15,8 @@ import java.nio.file.FileSystems; public class DirectComparatorTest { @ClassRule - public static final RocksMemoryResource rocksMemoryResource = - new RocksMemoryResource(); + public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE = + new RocksNativeLibraryResource(); @Rule public TemporaryFolder dbFolder = new TemporaryFolder(); @@ -24,9 +24,9 @@ public class DirectComparatorTest { @Test public void directComparator() throws IOException, RocksDBException { - final AbstractComparatorTest comparatorTest = new AbstractComparatorTest() { + final AbstractComparatorTest comparatorTest = new AbstractComparatorTest() { @Override - public AbstractComparator getAscendingIntKeyComparator() { + public AbstractComparator getAscendingIntKeyComparator() { return new DirectComparator(new ComparatorOptions()) { @Override diff --git a/java/src/test/java/org/rocksdb/DirectSliceTest.java b/java/src/test/java/org/rocksdb/DirectSliceTest.java index 48ae52afd..67385345c 100644 --- a/java/src/test/java/org/rocksdb/DirectSliceTest.java +++ b/java/src/test/java/org/rocksdb/DirectSliceTest.java @@ -13,8 +13,8 @@ import static org.assertj.core.api.Assertions.assertThat; public class DirectSliceTest { @ClassRule - public static final RocksMemoryResource rocksMemoryResource = - new RocksMemoryResource(); + public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE = + new RocksNativeLibraryResource(); @Test public void directSlice() { diff --git a/java/src/test/java/org/rocksdb/EnvOptionsTest.java b/java/src/test/java/org/rocksdb/EnvOptionsTest.java index 9be61b7d7..75768e2ae 100644 --- a/java/src/test/java/org/rocksdb/EnvOptionsTest.java +++ b/java/src/test/java/org/rocksdb/EnvOptionsTest.java @@ -14,7 +14,7 @@ import static org.assertj.core.api.Assertions.assertThat; public class EnvOptionsTest { @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(); diff --git a/java/src/test/java/org/rocksdb/FilterTest.java b/java/src/test/java/org/rocksdb/FilterTest.java index c6109639e..dc5c19fbc 100644 --- a/java/src/test/java/org/rocksdb/FilterTest.java +++ b/java/src/test/java/org/rocksdb/FilterTest.java @@ -11,8 +11,8 @@ import org.junit.Test; public class FilterTest { @ClassRule - public static final RocksMemoryResource rocksMemoryResource = - new RocksMemoryResource(); + public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE = + new RocksNativeLibraryResource(); @Test public void filter() { @@ -21,17 +21,17 @@ public class FilterTest { try(final Options options = new Options()) { try(final Filter bloomFilter = new BloomFilter()) { - blockConfig.setFilter(bloomFilter); + blockConfig.setFilterPolicy(bloomFilter); options.setTableFormatConfig(blockConfig); } try(final Filter bloomFilter = new BloomFilter(10)) { - blockConfig.setFilter(bloomFilter); + blockConfig.setFilterPolicy(bloomFilter); options.setTableFormatConfig(blockConfig); } try(final Filter bloomFilter = new BloomFilter(10, false)) { - blockConfig.setFilter(bloomFilter); + blockConfig.setFilterPolicy(bloomFilter); options.setTableFormatConfig(blockConfig); } } diff --git a/java/src/test/java/org/rocksdb/FlushTest.java b/java/src/test/java/org/rocksdb/FlushTest.java index 46a5cdc68..1a354f4ce 100644 --- a/java/src/test/java/org/rocksdb/FlushTest.java +++ b/java/src/test/java/org/rocksdb/FlushTest.java @@ -14,8 +14,8 @@ import static org.assertj.core.api.Assertions.assertThat; public class FlushTest { @ClassRule - public static final RocksMemoryResource rocksMemoryResource = - new RocksMemoryResource(); + public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE = + new RocksNativeLibraryResource(); @Rule public TemporaryFolder dbFolder = new TemporaryFolder(); diff --git a/java/src/test/java/org/rocksdb/HdfsEnvTest.java b/java/src/test/java/org/rocksdb/HdfsEnvTest.java index 3a91c5cad..c1b064f48 100644 --- a/java/src/test/java/org/rocksdb/HdfsEnvTest.java +++ b/java/src/test/java/org/rocksdb/HdfsEnvTest.java @@ -15,8 +15,8 @@ import static java.nio.charset.StandardCharsets.UTF_8; public class HdfsEnvTest { @ClassRule - public static final RocksMemoryResource rocksMemoryResource = - new RocksMemoryResource(); + public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE = + new RocksNativeLibraryResource(); @Rule public TemporaryFolder dbFolder = new TemporaryFolder(); diff --git a/java/src/test/java/org/rocksdb/InfoLogLevelTest.java b/java/src/test/java/org/rocksdb/InfoLogLevelTest.java index a9b54d52c..12ee537d9 100644 --- a/java/src/test/java/org/rocksdb/InfoLogLevelTest.java +++ b/java/src/test/java/org/rocksdb/InfoLogLevelTest.java @@ -16,8 +16,8 @@ import static org.assertj.core.api.Assertions.assertThat; public class InfoLogLevelTest { @ClassRule - public static final RocksMemoryResource rocksMemoryResource = - new RocksMemoryResource(); + public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE = + new RocksNativeLibraryResource(); @Rule public TemporaryFolder dbFolder = new TemporaryFolder(); diff --git a/java/src/test/java/org/rocksdb/IngestExternalFileOptionsTest.java b/java/src/test/java/org/rocksdb/IngestExternalFileOptionsTest.java index a3973ccd9..ab7e21568 100644 --- a/java/src/test/java/org/rocksdb/IngestExternalFileOptionsTest.java +++ b/java/src/test/java/org/rocksdb/IngestExternalFileOptionsTest.java @@ -14,8 +14,8 @@ import static org.assertj.core.api.Assertions.assertThat; public class IngestExternalFileOptionsTest { @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(); diff --git a/java/src/test/java/org/rocksdb/KeyMayExistTest.java b/java/src/test/java/org/rocksdb/KeyMayExistTest.java index 577fe2ead..a1335ca62 100644 --- a/java/src/test/java/org/rocksdb/KeyMayExistTest.java +++ b/java/src/test/java/org/rocksdb/KeyMayExistTest.java @@ -18,8 +18,8 @@ import static org.assertj.core.api.Assertions.assertThat; public class KeyMayExistTest { @ClassRule - public static final RocksMemoryResource rocksMemoryResource = - new RocksMemoryResource(); + public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE = + new RocksNativeLibraryResource(); @Rule public TemporaryFolder dbFolder = new TemporaryFolder(); diff --git a/java/src/test/java/org/rocksdb/LoggerTest.java b/java/src/test/java/org/rocksdb/LoggerTest.java index 9ece0355b..5bc299f11 100644 --- a/java/src/test/java/org/rocksdb/LoggerTest.java +++ b/java/src/test/java/org/rocksdb/LoggerTest.java @@ -15,8 +15,8 @@ import static org.assertj.core.api.Assertions.assertThat; public class LoggerTest { @ClassRule - public static final RocksMemoryResource rocksMemoryResource = - new RocksMemoryResource(); + public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE = + new RocksNativeLibraryResource(); @Rule public TemporaryFolder dbFolder = new TemporaryFolder(); diff --git a/java/src/test/java/org/rocksdb/MemTableTest.java b/java/src/test/java/org/rocksdb/MemTableTest.java index 59503d481..73ac589a9 100644 --- a/java/src/test/java/org/rocksdb/MemTableTest.java +++ b/java/src/test/java/org/rocksdb/MemTableTest.java @@ -13,8 +13,8 @@ import static org.assertj.core.api.Assertions.assertThat; public class MemTableTest { @ClassRule - public static final RocksMemoryResource rocksMemoryResource = - new RocksMemoryResource(); + public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE = + new RocksNativeLibraryResource(); @Test public void hashSkipListMemTable() throws RocksDBException { diff --git a/java/src/test/java/org/rocksdb/MemoryUtilTest.java b/java/src/test/java/org/rocksdb/MemoryUtilTest.java index 73fcc87c3..72d3ddc3c 100644 --- a/java/src/test/java/org/rocksdb/MemoryUtilTest.java +++ b/java/src/test/java/org/rocksdb/MemoryUtilTest.java @@ -25,8 +25,8 @@ public class MemoryUtilTest { private final byte[] value = "some-value".getBytes(StandardCharsets.UTF_8); @ClassRule - public static final RocksMemoryResource rocksMemoryResource = - new RocksMemoryResource(); + public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE = + new RocksNativeLibraryResource(); @Rule public TemporaryFolder dbFolder1 = new TemporaryFolder(); @Rule public TemporaryFolder dbFolder2 = new TemporaryFolder(); diff --git a/java/src/test/java/org/rocksdb/MergeTest.java b/java/src/test/java/org/rocksdb/MergeTest.java index 554698476..128d694bf 100644 --- a/java/src/test/java/org/rocksdb/MergeTest.java +++ b/java/src/test/java/org/rocksdb/MergeTest.java @@ -20,8 +20,8 @@ import static org.assertj.core.api.Assertions.assertThat; public class MergeTest { @ClassRule - public static final RocksMemoryResource rocksMemoryResource = - new RocksMemoryResource(); + public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE = + new RocksNativeLibraryResource(); @Rule public TemporaryFolder dbFolder = new TemporaryFolder(); diff --git a/java/src/test/java/org/rocksdb/MixedOptionsTest.java b/java/src/test/java/org/rocksdb/MixedOptionsTest.java index ff68b1b00..10c92d49d 100644 --- a/java/src/test/java/org/rocksdb/MixedOptionsTest.java +++ b/java/src/test/java/org/rocksdb/MixedOptionsTest.java @@ -13,8 +13,8 @@ import static org.assertj.core.api.Assertions.assertThat; public class MixedOptionsTest { @ClassRule - public static final RocksMemoryResource rocksMemoryResource = - new RocksMemoryResource(); + public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE = + new RocksNativeLibraryResource(); @Test public void mixedOptionsTest(){ @@ -22,7 +22,7 @@ public class MixedOptionsTest { try(final Filter bloomFilter = new BloomFilter(); final ColumnFamilyOptions cfOptions = new ColumnFamilyOptions() .setTableFormatConfig( - new BlockBasedTableConfig().setFilter(bloomFilter)) + new BlockBasedTableConfig().setFilterPolicy(bloomFilter)) ) { assertThat(cfOptions.tableFactoryName()).isEqualTo( "BlockBasedTable"); diff --git a/java/src/test/java/org/rocksdb/OptionsTest.java b/java/src/test/java/org/rocksdb/OptionsTest.java index 99ea96d7c..b249f95fb 100644 --- a/java/src/test/java/org/rocksdb/OptionsTest.java +++ b/java/src/test/java/org/rocksdb/OptionsTest.java @@ -18,8 +18,8 @@ import static org.assertj.core.api.Assertions.assertThat; public class OptionsTest { @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(); @@ -428,6 +428,7 @@ public class OptionsTest { } } + @SuppressWarnings("deprecated") @Test public void baseBackgroundCompactions() { try (final Options opt = new Options()) { @@ -438,6 +439,7 @@ public class OptionsTest { } } + @SuppressWarnings("deprecated") @Test public void maxBackgroundCompactions() { try (final Options opt = new Options()) { @@ -458,6 +460,7 @@ public class OptionsTest { } } + @SuppressWarnings("deprecated") @Test public void maxBackgroundFlushes() { try (final Options opt = new Options()) { diff --git a/java/src/test/java/org/rocksdb/OptionsUtilTest.java b/java/src/test/java/org/rocksdb/OptionsUtilTest.java index e79951aa8..b84314eec 100644 --- a/java/src/test/java/org/rocksdb/OptionsUtilTest.java +++ b/java/src/test/java/org/rocksdb/OptionsUtilTest.java @@ -16,7 +16,7 @@ import static org.assertj.core.api.Assertions.assertThat; public class OptionsUtilTest { @ClassRule - public static final RocksMemoryResource rocksMemoryResource = new RocksMemoryResource(); + public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE = new RocksNativeLibraryResource(); @Rule public TemporaryFolder dbFolder = new TemporaryFolder(); @@ -94,10 +94,10 @@ public class OptionsUtilTest { assertThat(cfDescs.size()).isEqualTo(2); assertThat(cfDescs.get(0)).isNotNull(); assertThat(cfDescs.get(1)).isNotNull(); - assertThat(cfDescs.get(0).columnFamilyName()).isEqualTo(RocksDB.DEFAULT_COLUMN_FAMILY); - assertThat(cfDescs.get(1).columnFamilyName()).isEqualTo(secondCFName); + assertThat(cfDescs.get(0).getName()).isEqualTo(RocksDB.DEFAULT_COLUMN_FAMILY); + 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.maxWriteBufferNumber()) .isEqualTo(baseDefaultCFOpts.maxWriteBufferNumber()); @@ -110,7 +110,7 @@ public class OptionsUtilTest { assertThat(defaultCFOpts.bottommostCompressionType()) .isEqualTo(baseDefaultCFOpts.bottommostCompressionType()); - ColumnFamilyOptions secondCFOpts = cfDescs.get(1).columnFamilyOptions(); + ColumnFamilyOptions secondCFOpts = cfDescs.get(1).getOptions(); assertThat(secondCFOpts.writeBufferSize()).isEqualTo(baseSecondCFOpts.writeBufferSize()); assertThat(secondCFOpts.maxWriteBufferNumber()) .isEqualTo(baseSecondCFOpts.maxWriteBufferNumber()); diff --git a/java/src/test/java/org/rocksdb/PlainTableConfigTest.java b/java/src/test/java/org/rocksdb/PlainTableConfigTest.java index dcb6cc39f..c813dbbb4 100644 --- a/java/src/test/java/org/rocksdb/PlainTableConfigTest.java +++ b/java/src/test/java/org/rocksdb/PlainTableConfigTest.java @@ -13,8 +13,8 @@ import static org.assertj.core.api.Assertions.assertThat; public class PlainTableConfigTest { @ClassRule - public static final RocksMemoryResource rocksMemoryResource = - new RocksMemoryResource(); + public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE = + new RocksNativeLibraryResource(); @Test public void keySize() { diff --git a/java/src/test/java/org/rocksdb/RateLimiterTest.java b/java/src/test/java/org/rocksdb/RateLimiterTest.java index c78f9876e..e7d6e6c49 100644 --- a/java/src/test/java/org/rocksdb/RateLimiterTest.java +++ b/java/src/test/java/org/rocksdb/RateLimiterTest.java @@ -13,8 +13,8 @@ import static org.rocksdb.RateLimiter.*; public class RateLimiterTest { @ClassRule - public static final RocksMemoryResource rocksMemoryResource = - new RocksMemoryResource(); + public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE = + new RocksNativeLibraryResource(); @Test public void bytesPerSecond() { diff --git a/java/src/test/java/org/rocksdb/ReadOnlyTest.java b/java/src/test/java/org/rocksdb/ReadOnlyTest.java index 6b4c7b259..6d5bc96fc 100644 --- a/java/src/test/java/org/rocksdb/ReadOnlyTest.java +++ b/java/src/test/java/org/rocksdb/ReadOnlyTest.java @@ -18,8 +18,8 @@ import static org.assertj.core.api.Assertions.assertThat; public class ReadOnlyTest { @ClassRule - public static final RocksMemoryResource rocksMemoryResource = - new RocksMemoryResource(); + public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE = + new RocksNativeLibraryResource(); @Rule public TemporaryFolder dbFolder = new TemporaryFolder(); @@ -194,7 +194,7 @@ public class ReadOnlyTest { dbFolder.getRoot().getAbsolutePath(), cfDescriptors, readOnlyColumnFamilyHandleList)) { try { - rDb.remove("key".getBytes()); + rDb.delete("key".getBytes()); } finally { for (final ColumnFamilyHandle columnFamilyHandle : readOnlyColumnFamilyHandleList) { @@ -224,7 +224,7 @@ public class ReadOnlyTest { dbFolder.getRoot().getAbsolutePath(), cfDescriptors, readOnlyColumnFamilyHandleList)) { try { - rDb.remove(readOnlyColumnFamilyHandleList.get(0), + rDb.delete(readOnlyColumnFamilyHandleList.get(0), "key".getBytes()); } finally { for (final ColumnFamilyHandle columnFamilyHandle : diff --git a/java/src/test/java/org/rocksdb/ReadOptionsTest.java b/java/src/test/java/org/rocksdb/ReadOptionsTest.java index 9708cd0b1..675023ef3 100644 --- a/java/src/test/java/org/rocksdb/ReadOptionsTest.java +++ b/java/src/test/java/org/rocksdb/ReadOptionsTest.java @@ -18,8 +18,8 @@ import static org.assertj.core.api.Assertions.assertThat; public class ReadOptionsTest { @ClassRule - public static final RocksMemoryResource rocksMemoryResource = - new RocksMemoryResource(); + public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE = + new RocksNativeLibraryResource(); @Rule public ExpectedException exception = ExpectedException.none(); @@ -94,6 +94,7 @@ public class ReadOptionsTest { } } + @SuppressWarnings("deprecated") @Test public void managed() { try (final ReadOptions opt = new ReadOptions()) { diff --git a/java/src/test/java/org/rocksdb/RocksDBTest.java b/java/src/test/java/org/rocksdb/RocksDBTest.java index 8af4dcaaa..37f17e1a7 100644 --- a/java/src/test/java/org/rocksdb/RocksDBTest.java +++ b/java/src/test/java/org/rocksdb/RocksDBTest.java @@ -18,8 +18,8 @@ import static org.junit.Assert.fail; public class RocksDBTest { @ClassRule - public static final RocksMemoryResource rocksMemoryResource = - new RocksMemoryResource(); + public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE = + new RocksNativeLibraryResource(); @Rule public TemporaryFolder dbFolder = new TemporaryFolder(); @@ -352,8 +352,9 @@ public class RocksDBTest { } } + @SuppressWarnings("deprecated") @Test - public void multiGet() throws RocksDBException, InterruptedException { + public void multiGet() throws RocksDBException { try (final RocksDB db = RocksDB.open(dbFolder.getRoot().getAbsolutePath()); final ReadOptions rOpt = new ReadOptions()) { db.put("key1".getBytes(), "value".getBytes()); @@ -392,7 +393,7 @@ public class RocksDBTest { } @Test - public void multiGetAsList() throws RocksDBException, InterruptedException { + public void multiGetAsList() throws RocksDBException { try (final RocksDB db = RocksDB.open(dbFolder.getRoot().getAbsolutePath()); final ReadOptions rOpt = new ReadOptions()) { db.put("key1".getBytes(), "value".getBytes()); @@ -690,8 +691,13 @@ public class RocksDBTest { db.put((String.valueOf(i)).getBytes(), b); } db.flush(new FlushOptions().setWaitForFlush(true)); - db.compactRange("0".getBytes(), "201".getBytes(), - true, -1, 0); + try (final CompactRangeOptions compactRangeOpts = new CompactRangeOptions() + .setChangeLevel(true) + .setTargetLevel(-1) + .setTargetPathId(0)) { + db.compactRange(null, "0".getBytes(), "201".getBytes(), + compactRangeOpts); + } } } @@ -775,7 +781,10 @@ public class RocksDBTest { dbFolder.getRoot().getAbsolutePath(), columnFamilyDescriptors, columnFamilyHandles)) { - try { + try (final CompactRangeOptions compactRangeOpts = new CompactRangeOptions() + .setChangeLevel(true) + .setTargetLevel(-1) + .setTargetPathId(0)) { // fill database with key/value pairs byte[] b = new byte[10000]; for (int i = 0; i < 200; i++) { @@ -784,7 +793,7 @@ public class RocksDBTest { String.valueOf(i).getBytes(), b); } db.compactRange(columnFamilyHandles.get(1), "0".getBytes(), - "201".getBytes(), true, -1, 0); + "201".getBytes(), compactRangeOpts); } finally { for (final ColumnFamilyHandle handle : columnFamilyHandles) { handle.close(); diff --git a/java/src/test/java/org/rocksdb/RocksIteratorTest.java b/java/src/test/java/org/rocksdb/RocksIteratorTest.java index 4baac744b..96872e595 100644 --- a/java/src/test/java/org/rocksdb/RocksIteratorTest.java +++ b/java/src/test/java/org/rocksdb/RocksIteratorTest.java @@ -14,8 +14,8 @@ import static org.assertj.core.api.Assertions.assertThat; public class RocksIteratorTest { @ClassRule - public static final RocksMemoryResource rocksMemoryResource = - new RocksMemoryResource(); + public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE = + new RocksNativeLibraryResource(); @Rule public TemporaryFolder dbFolder = new TemporaryFolder(); diff --git a/java/src/test/java/org/rocksdb/RocksMemEnvTest.java b/java/src/test/java/org/rocksdb/RocksMemEnvTest.java index 8e429d4ec..a03a0f0ae 100644 --- a/java/src/test/java/org/rocksdb/RocksMemEnvTest.java +++ b/java/src/test/java/org/rocksdb/RocksMemEnvTest.java @@ -6,17 +6,15 @@ package org.rocksdb; import org.junit.ClassRule; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.TemporaryFolder; import static org.assertj.core.api.Assertions.assertThat; public class RocksMemEnvTest { @ClassRule - public static final RocksMemoryResource rocksMemoryResource = - new RocksMemoryResource(); + public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE = + new RocksNativeLibraryResource(); @Test public void memEnvFillAndReopen() throws RocksDBException { diff --git a/java/src/test/java/org/rocksdb/RocksMemoryResource.java b/java/src/test/java/org/rocksdb/RocksMemoryResource.java deleted file mode 100644 index 8463e8624..000000000 --- a/java/src/test/java/org/rocksdb/RocksMemoryResource.java +++ /dev/null @@ -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(); - } -} diff --git a/java/src/test/java/org/rocksdb/RocksNativeLibraryResource.java b/java/src/test/java/org/rocksdb/RocksNativeLibraryResource.java new file mode 100644 index 000000000..6116f2f92 --- /dev/null +++ b/java/src/test/java/org/rocksdb/RocksNativeLibraryResource.java @@ -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(); + } +} diff --git a/java/src/test/java/org/rocksdb/SliceTest.java b/java/src/test/java/org/rocksdb/SliceTest.java index 7ee656cd2..c65b01903 100644 --- a/java/src/test/java/org/rocksdb/SliceTest.java +++ b/java/src/test/java/org/rocksdb/SliceTest.java @@ -12,8 +12,8 @@ import static org.assertj.core.api.Assertions.assertThat; public class SliceTest { @ClassRule - public static final RocksMemoryResource rocksMemoryResource = - new RocksMemoryResource(); + public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE = + new RocksNativeLibraryResource(); @Test public void slice() { diff --git a/java/src/test/java/org/rocksdb/SnapshotTest.java b/java/src/test/java/org/rocksdb/SnapshotTest.java index de48c898b..11f0d560a 100644 --- a/java/src/test/java/org/rocksdb/SnapshotTest.java +++ b/java/src/test/java/org/rocksdb/SnapshotTest.java @@ -14,8 +14,8 @@ import static org.assertj.core.api.Assertions.assertThat; public class SnapshotTest { @ClassRule - public static final RocksMemoryResource rocksMemoryResource = - new RocksMemoryResource(); + public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE = + new RocksNativeLibraryResource(); @Rule public TemporaryFolder dbFolder = new TemporaryFolder(); diff --git a/java/src/test/java/org/rocksdb/SstFileWriterTest.java b/java/src/test/java/org/rocksdb/SstFileWriterTest.java index 6261210b1..22f6c6aa2 100644 --- a/java/src/test/java/org/rocksdb/SstFileWriterTest.java +++ b/java/src/test/java/org/rocksdb/SstFileWriterTest.java @@ -25,8 +25,8 @@ public class SstFileWriterTest { private static final String DB_DIRECTORY_NAME = "test_db"; @ClassRule - public static final RocksMemoryResource rocksMemoryResource - = new RocksMemoryResource(); + public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE + = new RocksNativeLibraryResource(); @Rule public TemporaryFolder parentFolder = new TemporaryFolder(); @@ -68,7 +68,7 @@ public class SstFileWriterTest { comparatorOptions = new ComparatorOptions(); comparator = new BytewiseComparator(comparatorOptions); options.setComparator(comparator); - sstFileWriter = new SstFileWriter(envOptions, options, comparator); + sstFileWriter = new SstFileWriter(envOptions, options); } else { sstFileWriter = new SstFileWriter(envOptions, options); } diff --git a/java/src/test/java/org/rocksdb/StatisticsCollectorTest.java b/java/src/test/java/org/rocksdb/StatisticsCollectorTest.java index 8dd0cd493..36721c80d 100644 --- a/java/src/test/java/org/rocksdb/StatisticsCollectorTest.java +++ b/java/src/test/java/org/rocksdb/StatisticsCollectorTest.java @@ -17,8 +17,8 @@ import static org.assertj.core.api.Assertions.assertThat; public class StatisticsCollectorTest { @ClassRule - public static final RocksMemoryResource rocksMemoryResource = - new RocksMemoryResource(); + public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE = + new RocksNativeLibraryResource(); @Rule public TemporaryFolder dbFolder = new TemporaryFolder(); diff --git a/java/src/test/java/org/rocksdb/StatisticsTest.java b/java/src/test/java/org/rocksdb/StatisticsTest.java index fbd255bdb..de92102ec 100644 --- a/java/src/test/java/org/rocksdb/StatisticsTest.java +++ b/java/src/test/java/org/rocksdb/StatisticsTest.java @@ -17,8 +17,8 @@ import static org.assertj.core.api.Assertions.assertThat; public class StatisticsTest { @ClassRule - public static final RocksMemoryResource rocksMemoryResource = - new RocksMemoryResource(); + public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE = + new RocksNativeLibraryResource(); @Rule public TemporaryFolder dbFolder = new TemporaryFolder(); diff --git a/java/src/test/java/org/rocksdb/TimedEnvTest.java b/java/src/test/java/org/rocksdb/TimedEnvTest.java index 2eb5eea82..c958f96b2 100644 --- a/java/src/test/java/org/rocksdb/TimedEnvTest.java +++ b/java/src/test/java/org/rocksdb/TimedEnvTest.java @@ -15,8 +15,8 @@ import static java.nio.charset.StandardCharsets.UTF_8; public class TimedEnvTest { @ClassRule - public static final RocksMemoryResource rocksMemoryResource = - new RocksMemoryResource(); + public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE = + new RocksNativeLibraryResource(); @Rule public TemporaryFolder dbFolder = new TemporaryFolder(); diff --git a/java/src/test/java/org/rocksdb/TransactionLogIteratorTest.java b/java/src/test/java/org/rocksdb/TransactionLogIteratorTest.java index a85d7c16e..3c4dff7bb 100644 --- a/java/src/test/java/org/rocksdb/TransactionLogIteratorTest.java +++ b/java/src/test/java/org/rocksdb/TransactionLogIteratorTest.java @@ -10,8 +10,8 @@ import static org.assertj.core.api.Assertions.assertThat; public class TransactionLogIteratorTest { @ClassRule - public static final RocksMemoryResource rocksMemoryResource = - new RocksMemoryResource(); + public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE = + new RocksNativeLibraryResource(); @Rule public TemporaryFolder dbFolder = new TemporaryFolder(); diff --git a/java/src/test/java/org/rocksdb/TtlDBTest.java b/java/src/test/java/org/rocksdb/TtlDBTest.java index cd72634a2..ffa15e768 100644 --- a/java/src/test/java/org/rocksdb/TtlDBTest.java +++ b/java/src/test/java/org/rocksdb/TtlDBTest.java @@ -20,8 +20,8 @@ import static org.assertj.core.api.Assertions.assertThat; public class TtlDBTest { @ClassRule - public static final RocksMemoryResource rocksMemoryResource = - new RocksMemoryResource(); + public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE = + new RocksNativeLibraryResource(); @Rule public TemporaryFolder dbFolder = new TemporaryFolder(); diff --git a/java/src/test/java/org/rocksdb/WalFilterTest.java b/java/src/test/java/org/rocksdb/WalFilterTest.java index aeb49165d..01ddb0289 100644 --- a/java/src/test/java/org/rocksdb/WalFilterTest.java +++ b/java/src/test/java/org/rocksdb/WalFilterTest.java @@ -21,8 +21,8 @@ import static org.rocksdb.util.TestUtil.*; public class WalFilterTest { @ClassRule - public static final RocksMemoryResource rocksMemoryResource = - new RocksMemoryResource(); + public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE = + new RocksNativeLibraryResource(); @Rule public TemporaryFolder dbFolder = new TemporaryFolder(); diff --git a/java/src/test/java/org/rocksdb/WriteBatchHandlerTest.java b/java/src/test/java/org/rocksdb/WriteBatchHandlerTest.java index 0c7b0d3ca..2826b128f 100644 --- a/java/src/test/java/org/rocksdb/WriteBatchHandlerTest.java +++ b/java/src/test/java/org/rocksdb/WriteBatchHandlerTest.java @@ -19,8 +19,8 @@ import static org.rocksdb.util.CapturingWriteBatchHandler.Action.*; public class WriteBatchHandlerTest { @ClassRule - public static final RocksMemoryResource rocksMemoryResource = - new RocksMemoryResource(); + public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE = + new RocksNativeLibraryResource(); @Test public void writeBatchHandler() throws RocksDBException { @@ -49,7 +49,7 @@ public class WriteBatchHandlerTest { break; case DELETE: - batch.remove(testEvent.key); + batch.delete(testEvent.key); break; case LOG: diff --git a/java/src/test/java/org/rocksdb/WriteBatchTest.java b/java/src/test/java/org/rocksdb/WriteBatchTest.java index 92bec3dcf..8e79ce2d0 100644 --- a/java/src/test/java/org/rocksdb/WriteBatchTest.java +++ b/java/src/test/java/org/rocksdb/WriteBatchTest.java @@ -26,8 +26,8 @@ import static java.nio.charset.StandardCharsets.UTF_8; */ public class WriteBatchTest { @ClassRule - public static final RocksMemoryResource rocksMemoryResource = - new RocksMemoryResource(); + public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE = + new RocksNativeLibraryResource(); @Rule public TemporaryFolder dbFolder = new TemporaryFolder(); diff --git a/java/src/test/java/org/rocksdb/WriteBatchWithIndexTest.java b/java/src/test/java/org/rocksdb/WriteBatchWithIndexTest.java index fcef00a39..12032dd8f 100644 --- a/java/src/test/java/org/rocksdb/WriteBatchWithIndexTest.java +++ b/java/src/test/java/org/rocksdb/WriteBatchWithIndexTest.java @@ -24,8 +24,8 @@ import static java.nio.charset.StandardCharsets.UTF_8; public class WriteBatchWithIndexTest { @ClassRule - public static final RocksMemoryResource rocksMemoryResource = - new RocksMemoryResource(); + public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE = + new RocksNativeLibraryResource(); @Rule public TemporaryFolder dbFolder = new TemporaryFolder(); diff --git a/java/src/test/java/org/rocksdb/WriteOptionsTest.java b/java/src/test/java/org/rocksdb/WriteOptionsTest.java index 00c1d7239..1d5f3cc8d 100644 --- a/java/src/test/java/org/rocksdb/WriteOptionsTest.java +++ b/java/src/test/java/org/rocksdb/WriteOptionsTest.java @@ -15,8 +15,8 @@ import static org.assertj.core.api.Assertions.assertThat; public class WriteOptionsTest { @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(); diff --git a/java/src/test/java/org/rocksdb/util/BytewiseComparatorTest.java b/java/src/test/java/org/rocksdb/util/BytewiseComparatorTest.java index 8149a4800..31ff88c75 100644 --- a/java/src/test/java/org/rocksdb/util/BytewiseComparatorTest.java +++ b/java/src/test/java/org/rocksdb/util/BytewiseComparatorTest.java @@ -234,7 +234,7 @@ public class BytewiseComparatorTest { if (map.containsKey(key)) { map.remove(key); } - db.remove(new WriteOptions(), bytes(key)); + db.delete(new WriteOptions(), bytes(key)); break; default: @@ -243,7 +243,7 @@ public class BytewiseComparatorTest { } try(final RocksIterator iter = db.newIterator(new ReadOptions())) { - final KVIter result_iter = new KVIter(map); + final KVIter result_iter = new KVIter<>(map); boolean is_valid = false; for (int i = 0; i < num_iter_ops; i++) { @@ -398,7 +398,7 @@ public class BytewiseComparatorTest { }; } - private class KVIter implements RocksIteratorInterface { + private static class KVIter implements RocksIteratorInterface { private final List> entries; private final java.util.Comparator comparator; @@ -409,10 +409,7 @@ public class BytewiseComparatorTest { public KVIter(final TreeMap map) { this.entries = new ArrayList<>(); - final Iterator> iterator = map.entrySet().iterator(); - while(iterator.hasNext()) { - entries.add(iterator.next()); - } + entries.addAll(map.entrySet()); this.comparator = map.comparator(); } @@ -432,6 +429,7 @@ public class BytewiseComparatorTest { offset = entries.size() - 1; } + @SuppressWarnings("unchecked") @Override public void seek(final byte[] target) { for(offset = 0; offset < entries.size(); offset++) { @@ -442,6 +440,7 @@ public class BytewiseComparatorTest { } } + @SuppressWarnings("unchecked") @Override public void seekForPrev(final byte[] target) { for(offset = entries.size()-1; offset >= 0; offset--) { @@ -492,6 +491,7 @@ public class BytewiseComparatorTest { } } + @SuppressWarnings("unchecked") public K key() { if(!isValid()) { if(entries.isEmpty()) { @@ -508,6 +508,7 @@ public class BytewiseComparatorTest { } } + @SuppressWarnings("unchecked") public V value() { if(!isValid()) { return (V)""; diff --git a/java/src/test/java/org/rocksdb/util/EnvironmentTest.java b/java/src/test/java/org/rocksdb/util/EnvironmentTest.java index 5bade90ca..8b57066bd 100644 --- a/java/src/test/java/org/rocksdb/util/EnvironmentTest.java +++ b/java/src/test/java/org/rocksdb/util/EnvironmentTest.java @@ -224,6 +224,7 @@ public class EnvironmentTest { setEnvironmentClassField(MUSL_LIBC_FIELD_NAME, INITIAL_MUSL_LIBC); } + @SuppressWarnings("unchecked") private static T getEnvironmentClassField(String fieldName) { final Field field; try { @@ -235,7 +236,7 @@ public class EnvironmentTest { modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL); */ return (T)field.get(null); - } catch (NoSuchFieldException | IllegalAccessException e) { + } catch (final NoSuchFieldException | IllegalAccessException e) { throw new RuntimeException(e); } } @@ -251,7 +252,7 @@ public class EnvironmentTest { modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL); */ field.set(null, value); - } catch (NoSuchFieldException | IllegalAccessException e) { + } catch (final NoSuchFieldException | IllegalAccessException e) { throw new RuntimeException(e); } }