Remove previously deprecated Java where RocksDB also removed it, or where no direct equivalent existed. (#9576)

Summary:
For RocksDB v7 major release. Remove previously deprecated Java API methods and associated tests
- where equivalent/alternative functionality exists and is already tested AND
- where the core RocksDB function/feature has also been removed
- OR the functionality exists only in Java so the previous deprecation only affected Java methods

RETAIN deprecated Java which reflects functionality which is deprecated by, but also still supported by, the core of RocksDB.

Pull Request resolved: https://github.com/facebook/rocksdb/pull/9576

Reviewed By: ajkr

Differential Revision: D34314983

Pulled By: jay-zhuang

fbshipit-source-id: 7cf9c17e3e07be9d289beb99f81b71e8e09ac403
main
Alan Paxton 3 years ago committed by Facebook GitHub Bot
parent 725833a424
commit 8d9c203f69
  1. 26
      java/src/main/java/org/rocksdb/AbstractWriteBatch.java
  2. 25
      java/src/main/java/org/rocksdb/ColumnFamilyDescriptor.java
  3. 463
      java/src/main/java/org/rocksdb/RocksDB.java
  4. 8
      java/src/main/java/org/rocksdb/RocksMemEnv.java
  5. 53
      java/src/main/java/org/rocksdb/SstFileWriter.java
  6. 48
      java/src/main/java/org/rocksdb/WriteBatchInterface.java
  7. 8
      java/src/test/java/org/rocksdb/BytewiseComparatorRegressionTest.java
  8. 27
      java/src/test/java/org/rocksdb/ColumnFamilyTest.java
  9. 40
      java/src/test/java/org/rocksdb/RocksDBTest.java
  10. 8
      java/src/test/java/org/rocksdb/SstFileWriterTest.java

@ -43,32 +43,6 @@ public abstract class AbstractWriteBatch extends RocksObject
columnFamilyHandle.nativeHandle_); columnFamilyHandle.nativeHandle_);
} }
@Override
@Deprecated
public void remove(byte[] key) throws RocksDBException {
delete(nativeHandle_, key, key.length);
}
@Override
@Deprecated
public void remove(ColumnFamilyHandle columnFamilyHandle, byte[] key)
throws RocksDBException {
delete(nativeHandle_, key, key.length, columnFamilyHandle.nativeHandle_);
}
@Override
@Deprecated
public void remove(final ByteBuffer key) throws RocksDBException {
this.delete(key);
}
@Override
@Deprecated
public void remove(ColumnFamilyHandle columnFamilyHandle, final ByteBuffer key)
throws RocksDBException {
this.delete(columnFamilyHandle, key);
}
@Override @Override
public void put(final ByteBuffer key, final ByteBuffer value) throws RocksDBException { public void put(final ByteBuffer key, final ByteBuffer value) throws RocksDBException {
assert key.isDirect() && value.isDirect(); assert key.isDirect() && value.isDirect();

@ -49,19 +49,6 @@ public class ColumnFamilyDescriptor {
return columnFamilyName_; return columnFamilyName_;
} }
/**
* Retrieve name of column family.
*
* @return column family name.
* @since 3.10.0
*
* @deprecated Use {@link #getName()} instead.
*/
@Deprecated
public byte[] columnFamilyName() {
return getName();
}
/** /**
* Retrieve assigned options instance. * Retrieve assigned options instance.
* *
@ -71,18 +58,6 @@ public class ColumnFamilyDescriptor {
return columnFamilyOptions_; return columnFamilyOptions_;
} }
/**
* Retrieve assigned options instance.
*
* @return Options instance assigned to this instance.
*
* @deprecated Use {@link #getOptions()} instead.
*/
@Deprecated
public ColumnFamilyOptions columnFamilyOptions() {
return getOptions();
}
@Override @Override
public boolean equals(final Object o) { public boolean equals(final Object o) {
if (this == o) { if (this == o) {

@ -9,7 +9,6 @@ import java.io.IOException;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;
@ -1040,23 +1039,6 @@ public class RocksDB extends RocksObject {
vOffset, vLen, columnFamilyHandle.nativeHandle_); vOffset, vLen, columnFamilyHandle.nativeHandle_);
} }
/**
* Remove the database entry (if any) for "key". Returns OK on
* success, and a non-OK status on error. It is not an error if "key"
* did not exist in the database.
*
* @param key Key to delete within database
*
* @throws RocksDBException thrown if error happens in underlying
* native library.
*
* @deprecated Use {@link #delete(byte[])}
*/
@Deprecated
public void remove(final byte[] key) throws RocksDBException {
delete(key);
}
/** /**
* Delete the database entry (if any) for "key". Returns OK on * Delete the database entry (if any) for "key". Returns OK on
* success, and a non-OK status on error. It is not an error if "key" * success, and a non-OK status on error. It is not an error if "key"
@ -1090,26 +1072,6 @@ public class RocksDB extends RocksObject {
delete(nativeHandle_, key, offset, len); delete(nativeHandle_, key, offset, len);
} }
/**
* Remove the database entry (if any) for "key". Returns OK on
* success, and a non-OK status on error. It is not an error if "key"
* did not exist in the database.
*
* @param columnFamilyHandle {@link org.rocksdb.ColumnFamilyHandle}
* instance
* @param key Key to delete within database
*
* @throws RocksDBException thrown if error happens in underlying
* native library.
*
* @deprecated Use {@link #delete(ColumnFamilyHandle, byte[])}
*/
@Deprecated
public void remove(final ColumnFamilyHandle columnFamilyHandle,
final byte[] key) throws RocksDBException {
delete(columnFamilyHandle, key);
}
/** /**
* Delete the database entry (if any) for "key". Returns OK on * Delete the database entry (if any) for "key". Returns OK on
* success, and a non-OK status on error. It is not an error if "key" * success, and a non-OK status on error. It is not an error if "key"
@ -1149,25 +1111,6 @@ public class RocksDB extends RocksObject {
delete(nativeHandle_, key, offset, len, columnFamilyHandle.nativeHandle_); delete(nativeHandle_, key, offset, len, columnFamilyHandle.nativeHandle_);
} }
/**
* Remove the database entry (if any) for "key". Returns OK on
* success, and a non-OK status on error. It is not an error if "key"
* did not exist in the database.
*
* @param writeOpt WriteOptions to be used with delete operation
* @param key Key to delete within database
*
* @throws RocksDBException thrown if error happens in underlying
* native library.
*
* @deprecated Use {@link #delete(WriteOptions, byte[])}
*/
@Deprecated
public void remove(final WriteOptions writeOpt, final byte[] key)
throws RocksDBException {
delete(writeOpt, key);
}
/** /**
* Delete the database entry (if any) for "key". Returns OK on * Delete the database entry (if any) for "key". Returns OK on
* success, and a non-OK status on error. It is not an error if "key" * success, and a non-OK status on error. It is not an error if "key"
@ -1204,27 +1147,6 @@ public class RocksDB extends RocksObject {
delete(nativeHandle_, writeOpt.nativeHandle_, key, offset, len); delete(nativeHandle_, writeOpt.nativeHandle_, key, offset, len);
} }
/**
* Remove the database entry (if any) for "key". Returns OK on
* success, and a non-OK status on error. It is not an error if "key"
* did not exist in the database.
*
* @param columnFamilyHandle {@link org.rocksdb.ColumnFamilyHandle}
* instance
* @param writeOpt WriteOptions to be used with delete operation
* @param key Key to delete within database
*
* @throws RocksDBException thrown if error happens in underlying
* native library.
*
* @deprecated Use {@link #delete(ColumnFamilyHandle, WriteOptions, byte[])}
*/
@Deprecated
public void remove(final ColumnFamilyHandle columnFamilyHandle,
final WriteOptions writeOpt, final byte[] key) throws RocksDBException {
delete(columnFamilyHandle, writeOpt, key);
}
/** /**
* Delete the database entry (if any) for "key". Returns OK on * Delete the database entry (if any) for "key". Returns OK on
* success, and a non-OK status on error. It is not an error if "key" * success, and a non-OK status on error. It is not an error if "key"
@ -2200,205 +2122,6 @@ public class RocksDB extends RocksObject {
columnFamilyHandle.nativeHandle_); columnFamilyHandle.nativeHandle_);
} }
/**
* Returns a map of keys for which values were found in DB.
*
* @param keys List of keys for which values need to be retrieved.
* @return Map where key of map is the key passed by user and value for map
* entry is the corresponding value in DB.
*
* @throws RocksDBException thrown if error happens in underlying
* native library.
*
* @deprecated Consider {@link #multiGetAsList(List)} instead.
*/
@Deprecated
public Map<byte[], byte[]> multiGet(final List<byte[]> keys)
throws RocksDBException {
assert(keys.size() != 0);
final byte[][] keysArray = keys.toArray(new byte[0][]);
final int[] keyOffsets = new int[keysArray.length];
final int[] keyLengths = new int[keysArray.length];
for(int i = 0; i < keyLengths.length; i++) {
keyLengths[i] = keysArray[i].length;
}
final byte[][] values = multiGet(nativeHandle_, keysArray, keyOffsets,
keyLengths);
final Map<byte[], byte[]> keyValueMap =
new HashMap<>(computeCapacityHint(values.length));
for(int i = 0; i < values.length; i++) {
if(values[i] == null) {
continue;
}
keyValueMap.put(keys.get(i), values[i]);
}
return keyValueMap;
}
/**
* Returns a map of keys for which values were found in DB.
* <p>
* Note: Every key needs to have a related column family name in
* {@code columnFamilyHandleList}.
* </p>
*
* @param columnFamilyHandleList {@link java.util.List} containing
* {@link org.rocksdb.ColumnFamilyHandle} instances.
* @param keys List of keys for which values need to be retrieved.
* @return Map where key of map is the key passed by user and value for map
* entry is the corresponding value in DB.
*
* @throws RocksDBException thrown if error happens in underlying
* native library.
* @throws IllegalArgumentException thrown if the size of passed keys is not
* equal to the amount of passed column family handles.
*
* @deprecated Consider {@link #multiGetAsList(List, List)} instead.
*/
@Deprecated
public Map<byte[], byte[]> multiGet(
final List<ColumnFamilyHandle> columnFamilyHandleList,
final List<byte[]> keys) throws RocksDBException,
IllegalArgumentException {
assert(keys.size() != 0);
// Check if key size equals cfList size. If not a exception must be
// thrown. If not a Segmentation fault happens.
if (keys.size() != columnFamilyHandleList.size()) {
throw new IllegalArgumentException(
"For each key there must be a ColumnFamilyHandle.");
}
final long[] cfHandles = new long[columnFamilyHandleList.size()];
for (int i = 0; i < columnFamilyHandleList.size(); i++) {
cfHandles[i] = columnFamilyHandleList.get(i).nativeHandle_;
}
final byte[][] keysArray = keys.toArray(new byte[0][]);
final int[] keyOffsets = new int[keysArray.length];
final int[] keyLengths = new int[keysArray.length];
for(int i = 0; i < keyLengths.length; i++) {
keyLengths[i] = keysArray[i].length;
}
final byte[][] values = multiGet(nativeHandle_, keysArray, keyOffsets,
keyLengths, cfHandles);
final Map<byte[], byte[]> keyValueMap =
new HashMap<>(computeCapacityHint(values.length));
for(int i = 0; i < values.length; i++) {
if (values[i] == null) {
continue;
}
keyValueMap.put(keys.get(i), values[i]);
}
return keyValueMap;
}
/**
* Returns a map of keys for which values were found in DB.
*
* @param opt Read options.
* @param keys of keys for which values need to be retrieved.
* @return Map where key of map is the key passed by user and value for map
* entry is the corresponding value in DB.
*
* @throws RocksDBException thrown if error happens in underlying
* native library.
*
* @deprecated Consider {@link #multiGetAsList(ReadOptions, List)} instead.
*/
@Deprecated
public Map<byte[], byte[]> multiGet(final ReadOptions opt,
final List<byte[]> keys) throws RocksDBException {
assert(keys.size() != 0);
final byte[][] keysArray = keys.toArray(new byte[0][]);
final int[] keyOffsets = new int[keysArray.length];
final int[] keyLengths = new int[keysArray.length];
for(int i = 0; i < keyLengths.length; i++) {
keyLengths[i] = keysArray[i].length;
}
final byte[][] values = multiGet(nativeHandle_, opt.nativeHandle_,
keysArray, keyOffsets, keyLengths);
final Map<byte[], byte[]> keyValueMap =
new HashMap<>(computeCapacityHint(values.length));
for(int i = 0; i < values.length; i++) {
if(values[i] == null) {
continue;
}
keyValueMap.put(keys.get(i), values[i]);
}
return keyValueMap;
}
/**
* Returns a map of keys for which values were found in DB.
* <p>
* Note: Every key needs to have a related column family name in
* {@code columnFamilyHandleList}.
* </p>
*
* @param opt Read options.
* @param columnFamilyHandleList {@link java.util.List} containing
* {@link org.rocksdb.ColumnFamilyHandle} instances.
* @param keys of keys for which values need to be retrieved.
* @return Map where key of map is the key passed by user and value for map
* entry is the corresponding value in DB.
*
* @throws RocksDBException thrown if error happens in underlying
* native library.
* @throws IllegalArgumentException thrown if the size of passed keys is not
* equal to the amount of passed column family handles.
*
* @deprecated Consider {@link #multiGetAsList(ReadOptions, List, List)}
* instead.
*/
@Deprecated
public Map<byte[], byte[]> multiGet(final ReadOptions opt,
final List<ColumnFamilyHandle> columnFamilyHandleList,
final List<byte[]> keys) throws RocksDBException {
assert(keys.size() != 0);
// Check if key size equals cfList size. If not a exception must be
// thrown. If not a Segmentation fault happens.
if (keys.size()!=columnFamilyHandleList.size()){
throw new IllegalArgumentException(
"For each key there must be a ColumnFamilyHandle.");
}
final long[] cfHandles = new long[columnFamilyHandleList.size()];
for (int i = 0; i < columnFamilyHandleList.size(); i++) {
cfHandles[i] = columnFamilyHandleList.get(i).nativeHandle_;
}
final byte[][] keysArray = keys.toArray(new byte[0][]);
final int[] keyOffsets = new int[keysArray.length];
final int[] keyLengths = new int[keysArray.length];
for(int i = 0; i < keyLengths.length; i++) {
keyLengths[i] = keysArray[i].length;
}
final byte[][] values = multiGet(nativeHandle_, opt.nativeHandle_,
keysArray, keyOffsets, keyLengths, cfHandles);
final Map<byte[], byte[]> keyValueMap
= new HashMap<>(computeCapacityHint(values.length));
for(int i = 0; i < values.length; i++) {
if(values[i] == null) {
continue;
}
keyValueMap.put(keys.get(i), values[i]);
}
return keyValueMap;
}
/** /**
* Takes a list of keys, and returns a list of values for the given list of * Takes a list of keys, and returns a list of values for the given list of
* keys. List will contain null for keys which could not be found. * keys. List will contain null for keys which could not be found.
@ -3581,9 +3304,7 @@ public class RocksDB extends RocksObject {
* *
* <p><strong>See also</strong></p> * <p><strong>See also</strong></p>
* <ul> * <ul>
* <li>{@link #compactRange(boolean, int, int)}</li>
* <li>{@link #compactRange(byte[], byte[])}</li> * <li>{@link #compactRange(byte[], byte[])}</li>
* <li>{@link #compactRange(byte[], byte[], boolean, int, int)}</li>
* </ul> * </ul>
* *
* @throws RocksDBException thrown if an error occurs within the native * @throws RocksDBException thrown if an error occurs within the native
@ -3602,15 +3323,8 @@ public class RocksDB extends RocksObject {
* <p><strong>See also</strong></p> * <p><strong>See also</strong></p>
* <ul> * <ul>
* <li> * <li>
* {@link #compactRange(ColumnFamilyHandle, boolean, int, int)}
* </li>
* <li>
* {@link #compactRange(ColumnFamilyHandle, byte[], byte[])} * {@link #compactRange(ColumnFamilyHandle, byte[], byte[])}
* </li> * </li>
* <li>
* {@link #compactRange(ColumnFamilyHandle, byte[], byte[],
* boolean, int, int)}
* </li>
* </ul> * </ul>
* *
* @param columnFamilyHandle {@link org.rocksdb.ColumnFamilyHandle} * @param columnFamilyHandle {@link org.rocksdb.ColumnFamilyHandle}
@ -3635,8 +3349,6 @@ public class RocksDB extends RocksObject {
* <p><strong>See also</strong></p> * <p><strong>See also</strong></p>
* <ul> * <ul>
* <li>{@link #compactRange()}</li> * <li>{@link #compactRange()}</li>
* <li>{@link #compactRange(boolean, int, int)}</li>
* <li>{@link #compactRange(byte[], byte[], boolean, int, int)}</li>
* </ul> * </ul>
* *
* @param begin start of key range (included in range) * @param begin start of key range (included in range)
@ -3659,13 +3371,6 @@ public class RocksDB extends RocksObject {
* <p><strong>See also</strong></p> * <p><strong>See also</strong></p>
* <ul> * <ul>
* <li>{@link #compactRange(ColumnFamilyHandle)}</li> * <li>{@link #compactRange(ColumnFamilyHandle)}</li>
* <li>
* {@link #compactRange(ColumnFamilyHandle, boolean, int, int)}
* </li>
* <li>
* {@link #compactRange(ColumnFamilyHandle, byte[], byte[],
* boolean, int, int)}
* </li>
* </ul> * </ul>
* *
* @param columnFamilyHandle {@link org.rocksdb.ColumnFamilyHandle} * @param columnFamilyHandle {@link org.rocksdb.ColumnFamilyHandle}
@ -3685,174 +3390,6 @@ public class RocksDB extends RocksObject {
0, columnFamilyHandle == null ? 0: columnFamilyHandle.nativeHandle_); 0, columnFamilyHandle == null ? 0: columnFamilyHandle.nativeHandle_);
} }
/**
* <p>Range compaction of database.</p>
* <p><strong>Note</strong>: After the database has been compacted,
* all data will have been pushed down to the last level containing
* any data.</p>
*
* <p>Compaction outputs should be placed in options.db_paths
* [target_path_id]. Behavior is undefined if target_path_id is
* out of range.</p>
*
* <p><strong>See also</strong></p>
* <ul>
* <li>{@link #compactRange()}</li>
* <li>{@link #compactRange(byte[], byte[])}</li>
* <li>{@link #compactRange(byte[], byte[], boolean, int, int)}</li>
* </ul>
*
* @deprecated Use {@link #compactRange(ColumnFamilyHandle, byte[], byte[], CompactRangeOptions)} instead
*
* @param changeLevel reduce level after compaction
* @param targetLevel target level to compact to
* @param targetPathId the target path id of output path
*
* @throws RocksDBException thrown if an error occurs within the native
* part of the library.
*/
@Deprecated
public void compactRange(final boolean changeLevel, final int targetLevel,
final int targetPathId) throws RocksDBException {
compactRange(null, changeLevel, targetLevel, targetPathId);
}
/**
* <p>Range compaction of column family.</p>
* <p><strong>Note</strong>: After the database has been compacted,
* all data will have been pushed down to the last level containing
* any data.</p>
*
* <p>Compaction outputs should be placed in options.db_paths
* [target_path_id]. Behavior is undefined if target_path_id is
* out of range.</p>
*
* <p><strong>See also</strong></p>
* <ul>
* <li>{@link #compactRange(ColumnFamilyHandle)}</li>
* <li>
* {@link #compactRange(ColumnFamilyHandle, byte[], byte[])}
* </li>
* <li>
* {@link #compactRange(ColumnFamilyHandle, byte[], byte[],
* boolean, int, int)}
* </li>
* </ul>
*
* @deprecated Use {@link #compactRange(ColumnFamilyHandle, byte[], byte[], CompactRangeOptions)} instead
*
* @param columnFamilyHandle {@link org.rocksdb.ColumnFamilyHandle}
* instance, or null for the default column family.
* @param changeLevel reduce level after compaction
* @param targetLevel target level to compact to
* @param targetPathId the target path id of output path
*
* @throws RocksDBException thrown if an error occurs within the native
* part of the library.
*/
@Deprecated
public void compactRange(
/* @Nullable */ final ColumnFamilyHandle columnFamilyHandle,
final boolean changeLevel, final int targetLevel, final int targetPathId)
throws RocksDBException {
final CompactRangeOptions options = new CompactRangeOptions();
options.setChangeLevel(changeLevel);
options.setTargetLevel(targetLevel);
options.setTargetPathId(targetPathId);
compactRange(nativeHandle_,
null, -1,
null, -1,
options.nativeHandle_,
columnFamilyHandle == null ? 0 : columnFamilyHandle.nativeHandle_);
}
/**
* <p>Range compaction of database.</p>
* <p><strong>Note</strong>: After the database has been compacted,
* all data will have been pushed down to the last level containing
* any data.</p>
*
* <p>Compaction outputs should be placed in options.db_paths
* [target_path_id]. Behavior is undefined if target_path_id is
* out of range.</p>
*
* <p><strong>See also</strong></p>
* <ul>
* <li>{@link #compactRange()}</li>
* <li>{@link #compactRange(boolean, int, int)}</li>
* <li>{@link #compactRange(byte[], byte[])}</li>
* </ul>
*
* @deprecated Use {@link #compactRange(ColumnFamilyHandle, byte[], byte[], CompactRangeOptions)}
* instead
*
* @param begin start of key range (included in range)
* @param end end of key range (excluded from range)
* @param changeLevel reduce level after compaction
* @param targetLevel target level to compact to
* @param targetPathId the target path id of output path
*
* @throws RocksDBException thrown if an error occurs within the native
* part of the library.
*/
@Deprecated
public void compactRange(final byte[] begin, final byte[] end,
final boolean changeLevel, final int targetLevel,
final int targetPathId) throws RocksDBException {
compactRange(null, begin, end, changeLevel, targetLevel, targetPathId);
}
/**
* <p>Range compaction of column family.</p>
* <p><strong>Note</strong>: After the database has been compacted,
* all data will have been pushed down to the last level containing
* any data.</p>
*
* <p>Compaction outputs should be placed in options.db_paths
* [target_path_id]. Behavior is undefined if target_path_id is
* out of range.</p>
*
* <p><strong>See also</strong></p>
* <ul>
* <li>{@link #compactRange(ColumnFamilyHandle)}</li>
* <li>
* {@link #compactRange(ColumnFamilyHandle, boolean, int, int)}
* </li>
* <li>
* {@link #compactRange(ColumnFamilyHandle, byte[], byte[])}
* </li>
* </ul>
*
* @deprecated Use {@link #compactRange(ColumnFamilyHandle, byte[], byte[], CompactRangeOptions)} instead
*
* @param columnFamilyHandle {@link org.rocksdb.ColumnFamilyHandle}
* instance.
* @param begin start of key range (included in range)
* @param end end of key range (excluded from range)
* @param changeLevel reduce level after compaction
* @param targetLevel target level to compact to
* @param targetPathId the target path id of output path
*
* @throws RocksDBException thrown if an error occurs within the native
* part of the library.
*/
@Deprecated
public void compactRange(
/* @Nullable */ final ColumnFamilyHandle columnFamilyHandle,
final byte[] begin, final byte[] end, final boolean changeLevel,
final int targetLevel, final int targetPathId)
throws RocksDBException {
final CompactRangeOptions options = new CompactRangeOptions();
options.setChangeLevel(changeLevel);
options.setTargetLevel(targetLevel);
options.setTargetPathId(targetPathId);
compactRange(nativeHandle_,
begin, begin == null ? -1 : begin.length,
end, end == null ? -1 : end.length,
options.nativeHandle_,
columnFamilyHandle == null ? 0 : columnFamilyHandle.nativeHandle_);
}
/** /**
* <p>Range compaction of column family.</p> * <p>Range compaction of column family.</p>
* <p><strong>Note</strong>: After the database has been compacted, * <p><strong>Note</strong>: After the database has been compacted,

@ -26,14 +26,6 @@ public class RocksMemEnv extends Env {
super(createMemEnv(baseEnv.nativeHandle_)); super(createMemEnv(baseEnv.nativeHandle_));
} }
/**
* @deprecated Use {@link #RocksMemEnv(Env)}.
*/
@Deprecated
public RocksMemEnv() {
this(Env.getDefault());
}
private static native long createMemEnv(final long baseEnvHandle); private static native long createMemEnv(final long baseEnvHandle);
@Override protected final native void disposeInternal(final long handle); @Override protected final native void disposeInternal(final long handle);
} }

@ -17,25 +17,6 @@ public class SstFileWriter extends RocksObject {
RocksDB.loadLibrary(); RocksDB.loadLibrary();
} }
/**
* SstFileWriter Constructor.
*
* @param envOptions {@link org.rocksdb.EnvOptions} instance.
* @param options {@link org.rocksdb.Options} instance.
* @param comparator the comparator to specify the ordering of keys.
*
* @deprecated Use {@link #SstFileWriter(EnvOptions, Options)}.
* Passing an explicit comparator is deprecated in lieu of passing the
* comparator as part of options. Use the other constructor instead.
*/
@Deprecated
public SstFileWriter(final EnvOptions envOptions, final Options options,
final AbstractComparator comparator) {
super(newSstFileWriter(
envOptions.nativeHandle_, options.nativeHandle_, comparator.nativeHandle_,
comparator.getComparatorType().getValue()));
}
/** /**
* SstFileWriter Constructor. * SstFileWriter Constructor.
* *
@ -59,40 +40,6 @@ public class SstFileWriter extends RocksObject {
open(nativeHandle_, filePath); open(nativeHandle_, filePath);
} }
/**
* Add a Put key with value to currently opened file.
*
* @param key the specified key to be inserted.
* @param value the value associated with the specified key.
*
* @throws RocksDBException thrown if error happens in underlying
* native library.
*
* @deprecated Use {@link #put(Slice, Slice)}
*/
@Deprecated
public void add(final Slice key, final Slice value)
throws RocksDBException {
put(nativeHandle_, key.getNativeHandle(), value.getNativeHandle());
}
/**
* Add a Put key with value to currently opened file.
*
* @param key the specified key to be inserted.
* @param value the value associated with the specified key.
*
* @throws RocksDBException thrown if error happens in underlying
* native library.
*
* @deprecated Use {@link #put(DirectSlice, DirectSlice)}
*/
@Deprecated
public void add(final DirectSlice key, final DirectSlice value)
throws RocksDBException {
put(nativeHandle_, key.getNativeHandle(), value.getNativeHandle());
}
/** /**
* Add a Put key with value to currently opened file. * Add a Put key with value to currently opened file.
* *

@ -93,54 +93,6 @@ public interface WriteBatchInterface {
void merge(ColumnFamilyHandle columnFamilyHandle, byte[] key, byte[] value) void merge(ColumnFamilyHandle columnFamilyHandle, byte[] key, byte[] value)
throws RocksDBException; throws RocksDBException;
/**
* <p>If the database contains a mapping for "key", erase it. Else do nothing.</p>
*
* @param key Key to delete within database
*
* @deprecated Use {@link #delete(byte[])}
* @throws RocksDBException thrown if error happens in underlying native library.
*/
@Deprecated
void remove(byte[] key) throws RocksDBException;
/**
* <p>If column family contains a mapping for "key", erase it. Else do nothing.</p>
*
* @param columnFamilyHandle {@link ColumnFamilyHandle} instance
* @param key Key to delete within database
*
* @deprecated Use {@link #delete(ColumnFamilyHandle, byte[])}
* @throws RocksDBException thrown if error happens in underlying native library.
*/
@Deprecated
void remove(ColumnFamilyHandle columnFamilyHandle, byte[] key) throws RocksDBException;
/**
* <p>If column family contains a mapping for "key", erase it. Else do nothing.</p>
*
* @param key Key to delete within database. It is using position and limit.
* Supports direct buffer only.
*
* @deprecated Use {@link #delete(ByteBuffer)}
* @throws RocksDBException thrown if error happens in underlying native library.
*/
@Deprecated void remove(final ByteBuffer key) throws RocksDBException;
/**
* <p>If column family contains a mapping for "key", erase it. Else do nothing.</p>
*
* @param columnFamilyHandle {@link ColumnFamilyHandle} instance
* @param key Key to delete within database. It is using position and limit.
* Supports direct buffer only.
*
* @deprecated Use {@link #delete(ColumnFamilyHandle, ByteBuffer)}
* @throws RocksDBException thrown if error happens in underlying native library.
*/
@Deprecated
void remove(ColumnFamilyHandle columnFamilyHandle, final ByteBuffer key)
throws RocksDBException;
/** /**
* <p>If the database contains a mapping for "key", erase it. Else do nothing.</p> * <p>If the database contains a mapping for "key", erase it. Else do nothing.</p>
* *

@ -112,15 +112,15 @@ public class BytewiseComparatorRegressionTest {
final EnvOptions envOpts = new EnvOptions(); final EnvOptions envOpts = new EnvOptions();
final Options opts = new Options(); final Options opts = new Options();
final SstFileWriter writer = opts.setComparator(new BytewiseComparator(new ComparatorOptions()));
new SstFileWriter(envOpts, opts, new BytewiseComparator(new ComparatorOptions())); final SstFileWriter writer = new SstFileWriter(envOpts, opts);
writer.open(tempSSTFile.getAbsolutePath()); writer.open(tempSSTFile.getAbsolutePath());
final byte[] gKey = final byte[] gKey =
hexToByte("000000293030303030303030303030303030303030303032303736343730696E666F33"); hexToByte("000000293030303030303030303030303030303030303032303736343730696E666F33");
final byte[] wKey = final byte[] wKey =
hexToByte("0000008d3030303030303030303030303030303030303030303437363433696e666f34"); hexToByte("0000008d3030303030303030303030303030303030303030303437363433696e666f34");
writer.add(new Slice(gKey), new Slice("dummyV1")); writer.put(new Slice(gKey), new Slice("dummyV1"));
writer.add(new Slice(wKey), new Slice("dummyV2")); writer.put(new Slice(wKey), new Slice("dummyV2"));
writer.finish(); writer.finish();
} }
} }

@ -579,31 +579,4 @@ public class ColumnFamilyTest {
assertTrue(cf2.isOwningHandle()); assertTrue(cf2.isOwningHandle());
} }
} }
@Test
@Deprecated
/**
* @deprecated Now explicitly closing instances of ColumnFamilyHandle is not required.
* RocksDB instance will take care of closing its associated ColumnFamilyHandle objects.
*/
public void testColumnFamilyCloseBeforeDb() throws RocksDBException {
final List<ColumnFamilyDescriptor> cfNames =
Arrays.asList(new ColumnFamilyDescriptor(RocksDB.DEFAULT_COLUMN_FAMILY),
new ColumnFamilyDescriptor("new_cf".getBytes()));
final List<ColumnFamilyHandle> columnFamilyHandleList = new ArrayList<>();
try (final DBOptions options =
new DBOptions().setCreateIfMissing(true).setCreateMissingColumnFamilies(true);
final RocksDB db = RocksDB.open(
options, dbFolder.getRoot().getAbsolutePath(), cfNames, columnFamilyHandleList)) {
try {
db.put("testKey".getBytes(), "tstValue".getBytes());
// Do something...
} finally {
for (final ColumnFamilyHandle columnFamilyHandle : columnFamilyHandleList) {
columnFamilyHandle.close();
}
}
}
}
} }

@ -393,46 +393,6 @@ public class RocksDBTest {
} }
} }
@SuppressWarnings("deprecated")
@Test
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());
db.put("key2".getBytes(), "12345678".getBytes());
List<byte[]> lookupKeys = new ArrayList<>();
lookupKeys.add("key1".getBytes());
lookupKeys.add("key2".getBytes());
Map<byte[], byte[]> results = db.multiGet(lookupKeys);
assertThat(results).isNotNull();
assertThat(results.values()).isNotNull();
assertThat(results.values()).
contains("value".getBytes(), "12345678".getBytes());
// test same method with ReadOptions
results = db.multiGet(rOpt, lookupKeys);
assertThat(results).isNotNull();
assertThat(results.values()).isNotNull();
assertThat(results.values()).
contains("value".getBytes(), "12345678".getBytes());
// remove existing key
lookupKeys.remove("key2".getBytes());
// add non existing key
lookupKeys.add("key3".getBytes());
results = db.multiGet(lookupKeys);
assertThat(results).isNotNull();
assertThat(results.values()).isNotNull();
assertThat(results.values()).
contains("value".getBytes());
// test same call with readOptions
results = db.multiGet(rOpt, lookupKeys);
assertThat(results).isNotNull();
assertThat(results.values()).isNotNull();
assertThat(results.values()).
contains("value".getBytes());
}
}
@Test @Test
public void multiGetAsList() throws RocksDBException { public void multiGetAsList() throws RocksDBException {
try (final RocksDB db = RocksDB.open(dbFolder.getRoot().getAbsolutePath()); try (final RocksDB db = RocksDB.open(dbFolder.getRoot().getAbsolutePath());

@ -32,7 +32,7 @@ public class SstFileWriterTest {
enum OpType { PUT, PUT_BYTES, PUT_DIRECT, MERGE, MERGE_BYTES, DELETE, DELETE_BYTES } enum OpType { PUT, PUT_BYTES, PUT_DIRECT, MERGE, MERGE_BYTES, DELETE, DELETE_BYTES }
class KeyValueWithOp { static class KeyValueWithOp {
KeyValueWithOp(String key, String value, OpType opType) { KeyValueWithOp(String key, String value, OpType opType) {
this.key = key; this.key = key;
this.value = value; this.value = value;
@ -51,9 +51,9 @@ public class SstFileWriterTest {
return opType; return opType;
} }
private String key; private final String key;
private String value; private final String value;
private OpType opType; private final OpType opType;
}; };
private File newSstFile(final List<KeyValueWithOp> keyValues, private File newSstFile(final List<KeyValueWithOp> keyValues,

Loading…
Cancel
Save