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
main
Adam Retter 5 years ago committed by Facebook Github Bot
parent f89dea4fec
commit 4d3264e4ab
  1. 2
      java/CMakeLists.txt
  2. 7
      java/src/main/java/org/rocksdb/AbstractMutableOptions.java
  3. 7
      java/src/main/java/org/rocksdb/BlockBasedTableConfig.java
  4. 2
      java/src/main/java/org/rocksdb/ColumnFamilyOptions.java
  5. 5
      java/src/main/java/org/rocksdb/DBOptions.java
  6. 9
      java/src/main/java/org/rocksdb/Env.java
  7. 26
      java/src/main/java/org/rocksdb/HistogramType.java
  8. 2
      java/src/main/java/org/rocksdb/InfoLogLevel.java
  9. 3
      java/src/main/java/org/rocksdb/MutableDBOptions.java
  10. 4
      java/src/main/java/org/rocksdb/OptimisticTransactionDB.java
  11. 2
      java/src/main/java/org/rocksdb/OptimisticTransactionOptions.java
  12. 5
      java/src/main/java/org/rocksdb/Options.java
  13. 103
      java/src/main/java/org/rocksdb/RocksDB.java
  14. 12
      java/src/main/java/org/rocksdb/SstFileMetaData.java
  15. 10
      java/src/main/java/org/rocksdb/SstFileReader.java
  16. 25
      java/src/main/java/org/rocksdb/TickerType.java
  17. 312
      java/src/main/java/org/rocksdb/Transaction.java
  18. 4
      java/src/main/java/org/rocksdb/TransactionDB.java
  19. 4
      java/src/main/java/org/rocksdb/TransactionDBOptions.java
  20. 2
      java/src/main/java/org/rocksdb/TransactionOptions.java
  21. 6
      java/src/main/java/org/rocksdb/TransactionalOptions.java
  22. 4
      java/src/main/java/org/rocksdb/TtlDB.java
  23. 10
      java/src/test/java/org/rocksdb/AbstractComparatorTest.java
  24. 4
      java/src/test/java/org/rocksdb/BackupEngineTest.java
  25. 4
      java/src/test/java/org/rocksdb/BackupableDBOptionsTest.java
  26. 4
      java/src/test/java/org/rocksdb/BlockBasedTableConfigTest.java
  27. 4
      java/src/test/java/org/rocksdb/CheckPointTest.java
  28. 4
      java/src/test/java/org/rocksdb/ColumnFamilyOptionsTest.java
  29. 30
      java/src/test/java/org/rocksdb/ColumnFamilyTest.java
  30. 4
      java/src/test/java/org/rocksdb/CompactionJobInfoTest.java
  31. 4
      java/src/test/java/org/rocksdb/CompactionJobStatsTest.java
  32. 4
      java/src/test/java/org/rocksdb/CompactionOptionsTest.java
  33. 4
      java/src/test/java/org/rocksdb/ComparatorOptionsTest.java
  34. 12
      java/src/test/java/org/rocksdb/ComparatorTest.java
  35. 9
      java/src/test/java/org/rocksdb/DBOptionsTest.java
  36. 4
      java/src/test/java/org/rocksdb/DefaultEnvTest.java
  37. 8
      java/src/test/java/org/rocksdb/DirectComparatorTest.java
  38. 4
      java/src/test/java/org/rocksdb/DirectSliceTest.java
  39. 2
      java/src/test/java/org/rocksdb/EnvOptionsTest.java
  40. 10
      java/src/test/java/org/rocksdb/FilterTest.java
  41. 4
      java/src/test/java/org/rocksdb/FlushTest.java
  42. 4
      java/src/test/java/org/rocksdb/HdfsEnvTest.java
  43. 4
      java/src/test/java/org/rocksdb/InfoLogLevelTest.java
  44. 4
      java/src/test/java/org/rocksdb/IngestExternalFileOptionsTest.java
  45. 4
      java/src/test/java/org/rocksdb/KeyMayExistTest.java
  46. 4
      java/src/test/java/org/rocksdb/LoggerTest.java
  47. 4
      java/src/test/java/org/rocksdb/MemTableTest.java
  48. 4
      java/src/test/java/org/rocksdb/MemoryUtilTest.java
  49. 4
      java/src/test/java/org/rocksdb/MergeTest.java
  50. 6
      java/src/test/java/org/rocksdb/MixedOptionsTest.java
  51. 7
      java/src/test/java/org/rocksdb/OptionsTest.java
  52. 10
      java/src/test/java/org/rocksdb/OptionsUtilTest.java
  53. 4
      java/src/test/java/org/rocksdb/PlainTableConfigTest.java
  54. 4
      java/src/test/java/org/rocksdb/RateLimiterTest.java
  55. 8
      java/src/test/java/org/rocksdb/ReadOnlyTest.java
  56. 5
      java/src/test/java/org/rocksdb/ReadOptionsTest.java
  57. 25
      java/src/test/java/org/rocksdb/RocksDBTest.java
  58. 4
      java/src/test/java/org/rocksdb/RocksIteratorTest.java
  59. 6
      java/src/test/java/org/rocksdb/RocksMemEnvTest.java
  60. 25
      java/src/test/java/org/rocksdb/RocksMemoryResource.java
  61. 18
      java/src/test/java/org/rocksdb/RocksNativeLibraryResource.java
  62. 4
      java/src/test/java/org/rocksdb/SliceTest.java
  63. 4
      java/src/test/java/org/rocksdb/SnapshotTest.java
  64. 6
      java/src/test/java/org/rocksdb/SstFileWriterTest.java
  65. 4
      java/src/test/java/org/rocksdb/StatisticsCollectorTest.java
  66. 4
      java/src/test/java/org/rocksdb/StatisticsTest.java
  67. 4
      java/src/test/java/org/rocksdb/TimedEnvTest.java
  68. 4
      java/src/test/java/org/rocksdb/TransactionLogIteratorTest.java
  69. 4
      java/src/test/java/org/rocksdb/TtlDBTest.java
  70. 4
      java/src/test/java/org/rocksdb/WalFilterTest.java
  71. 6
      java/src/test/java/org/rocksdb/WriteBatchHandlerTest.java
  72. 4
      java/src/test/java/org/rocksdb/WriteBatchTest.java
  73. 4
      java/src/test/java/org/rocksdb/WriteBatchWithIndexTest.java
  74. 4
      java/src/test/java/org/rocksdb/WriteOptionsTest.java
  75. 15
      java/src/test/java/org/rocksdb/util/BytewiseComparatorTest.java
  76. 5
      java/src/test/java/org/rocksdb/util/EnvironmentTest.java

@ -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

@ -198,18 +198,19 @@ public abstract class AbstractMutableOptions {
return self();
}
@SuppressWarnings("unchecked")
protected <N extends Enum<N>> 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<N>)value).asObject();
return ((MutableOptionValue.MutableOptionEnumValue<N>) value).asObject();
}
public U fromString(

@ -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

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

@ -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_);

@ -59,6 +59,8 @@ public abstract class Env extends RocksObject {
* <p>Gets the number of background worker threads of the pool
* for this environment.</p>
*
* @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<ThreadStatus> getThreadList() throws RocksDBException {
return Arrays.asList(getThreadList(nativeHandle_));

@ -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.");
}
}

@ -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;
}
}

@ -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);
}

@ -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,

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

@ -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());

@ -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<ColumnFamilyHandle> 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<ColumnFamilyHandle> createColumnFamilies(
final List<ColumnFamilyDescriptor> columnFamilyDescriptors)
@ -2676,6 +2682,8 @@ public class RocksDB extends RocksObject {
*
* Note this doesn't reset {@link Options#statistics()} as it is not
* 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<String> 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<String> 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<ColumnFamilyHandle> 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<LogFile> 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<String, TableProperties> 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<String, TableProperties> 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<String, TableProperties> 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<String, TableProperties> getPropertiesOfTablesInRange(
final List<Range> 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<byte[]> ranges,
final boolean includeEnd) throws RocksDBException {
public void deleteFilesInRanges(final ColumnFamilyHandle columnFamily,
final List<byte[]> ranges, final boolean includeEnd)
throws RocksDBException {
if (ranges.size() == 0) {
return;
}

@ -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,

@ -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;
}

@ -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.");
}
}

@ -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,

@ -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_,

@ -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.

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

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

@ -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()];

@ -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<T extends AbstractSlice<?>> {
/**
* 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<T> 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<T> 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<T> comparator = getAscendingIntKeyComparator()) {
final List<ColumnFamilyDescriptor> cfDescriptors = Arrays.asList(
new ColumnFamilyDescriptor(RocksDB.DEFAULT_COLUMN_FAMILY),
new ColumnFamilyDescriptor("new_cf".getBytes(),

@ -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();

@ -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();

@ -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();

@ -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();

@ -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();

@ -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<byte[]> keys = Arrays.asList(new byte[][]{
"key".getBytes(), "newcfkey".getBytes()
});
Map<byte[], byte[]> retValues = db.multiGet(columnFamilyHandleList,
keys);
List<byte[]> 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<ColumnFamilyHandle> cfCustomList = new ArrayList<>();
db.multiGet(cfCustomList, keys);
db.multiGetAsList(cfCustomList, keys);
} finally {
for (final ColumnFamilyHandle columnFamilyHandle :

@ -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() {

@ -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() {

@ -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() {

@ -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() {

@ -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<Slice> comparatorTest = new AbstractComparatorTest<Slice>() {
@Override
public AbstractComparator getAscendingIntKeyComparator() {
public AbstractComparator<Slice> 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<Slice> comparatorTest = new AbstractComparatorTest<Slice>() {
@Override
public AbstractComparator getAscendingIntKeyComparator() {
public AbstractComparator<Slice> getAscendingIntKeyComparator() {
return new Comparator(new ComparatorOptions()) {
@Override

@ -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()) {

@ -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();

@ -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<DirectSlice> comparatorTest = new AbstractComparatorTest<DirectSlice>() {
@Override
public AbstractComparator getAscendingIntKeyComparator() {
public AbstractComparator<DirectSlice> getAscendingIntKeyComparator() {
return new DirectComparator(new ComparatorOptions()) {
@Override

@ -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() {

@ -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();

@ -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);
}
}

@ -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();

@ -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();

@ -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();

@ -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();

@ -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();

@ -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();

@ -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 {

@ -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();

@ -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();

@ -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");

@ -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()) {

@ -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());

@ -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() {

@ -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() {

@ -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 :

@ -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()) {

@ -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();

@ -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();

@ -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 {

@ -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();
}
}

@ -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();
}
}

@ -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() {

@ -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();

@ -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);
}

@ -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();

@ -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();

@ -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();

@ -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();

@ -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();

@ -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();

@ -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:

@ -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();

@ -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();

@ -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();

@ -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<String, String> result_iter = new KVIter(map);
final KVIter<String, String> 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<K, V> implements RocksIteratorInterface {
private static class KVIter<K, V> implements RocksIteratorInterface {
private final List<Map.Entry<K, V>> entries;
private final java.util.Comparator<? super K> comparator;
@ -409,10 +409,7 @@ public class BytewiseComparatorTest {
public KVIter(final TreeMap<K, V> map) {
this.entries = new ArrayList<>();
final Iterator<Map.Entry<K, V>> 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)"";

@ -224,6 +224,7 @@ public class EnvironmentTest {
setEnvironmentClassField(MUSL_LIBC_FIELD_NAME, INITIAL_MUSL_LIBC);
}
@SuppressWarnings("unchecked")
private static <T> 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);
}
}

Loading…
Cancel
Save