Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.apache.hadoop.hdds.StringUtils;

import org.rocksdb.ColumnFamilyHandle;
import org.rocksdb.Holder;
import org.rocksdb.ReadOptions;
import org.rocksdb.RocksDB;
import org.rocksdb.RocksDBException;
Expand Down Expand Up @@ -128,11 +129,12 @@ public boolean isExist(byte[] key) throws IOException {
// If the key definitely does not exist in the database, then this
// method returns false, else true.
rdbMetrics.incNumDBKeyMayExistChecks();
StringBuilder outValue = new StringBuilder();
Holder<byte[]> outValue = new Holder<>();
boolean keyMayExist = db.keyMayExist(handle, key, outValue);
if (keyMayExist) {
boolean keyExists = (outValue.length() > 0) ||
(db.get(handle, key) != null);
boolean keyExists =
(outValue.getValue() != null && outValue.getValue().length > 0) ||
(db.get(handle, key) != null);
if (!keyExists) {
rdbMetrics.incNumDBKeyMayExistMisses();
}
Expand Down Expand Up @@ -162,8 +164,7 @@ public byte[] getIfExist(byte[] key) throws IOException {
// If the key definitely does not exist in the database, then this
// method returns false, else true.
rdbMetrics.incNumDBKeyGetIfExistChecks();
StringBuilder outValue = new StringBuilder();
boolean keyMayExist = db.keyMayExist(handle, key, outValue);
boolean keyMayExist = db.keyMayExist(handle, key, null);
if (keyMayExist) {
// Not using out value from string builder, as that is causing
// IllegalArgumentException during protobuf parsing.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ public void testRocksDBKeyMayExistApi() throws Exception {
for (int i = 0; i < 50; i++) {
Assert.assertFalse(db.keyMayExist(
org.apache.commons.codec.binary.StringUtils
.getBytesUtf16("key" + i), new StringBuilder()));
.getBytesUtf16("key" + i), null));
}
end = System.nanoTime();
long keyMayExistLatency = end - start;
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1586,7 +1586,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xs
<dependency>
<groupId>org.rocksdb</groupId>
<artifactId>rocksdbjni</artifactId>
<version>6.6.4</version>
<version>6.8.1</version>
</dependency>
<dependency>
<groupId>org.xerial</groupId>
Expand Down