Fix getApproximateMemTableStats() return type (#8098)
Summary: Which should return 2 long instead of an array. Pull Request resolved: https://github.com/facebook/rocksdb/pull/8098 Reviewed By: mrambacher Differential Revision: D27308741 Pulled By: jay-zhuang fbshipit-source-id: 44beea2bd28cf6779b048bebc98f2426fe95e25c
This commit is contained in:
parent
493a4e28d9
commit
a781b103da
@ -2428,14 +2428,13 @@ jlongArray Java_org_rocksdb_RocksDB_getApproximateMemTableStats(
|
|||||||
static_cast<jlong>(count),
|
static_cast<jlong>(count),
|
||||||
static_cast<jlong>(sizes)};
|
static_cast<jlong>(sizes)};
|
||||||
|
|
||||||
const jsize jcount = static_cast<jsize>(count);
|
jlongArray jsizes = env->NewLongArray(2);
|
||||||
jlongArray jsizes = env->NewLongArray(jcount);
|
|
||||||
if (jsizes == nullptr) {
|
if (jsizes == nullptr) {
|
||||||
// exception thrown: OutOfMemoryError
|
// exception thrown: OutOfMemoryError
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
env->SetLongArrayRegion(jsizes, 0, jcount, results);
|
env->SetLongArrayRegion(jsizes, 0, 2, results);
|
||||||
if (env->ExceptionCheck()) {
|
if (env->ExceptionCheck()) {
|
||||||
// exception thrown: ArrayIndexOutOfBoundsException
|
// exception thrown: ArrayIndexOutOfBoundsException
|
||||||
env->DeleteLocalRef(jsizes);
|
env->DeleteLocalRef(jsizes);
|
||||||
|
@ -1271,6 +1271,26 @@ public class RocksDBTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getApproximateMemTableStatsSingleKey() throws RocksDBException {
|
||||||
|
final byte key1[] = "key1".getBytes(UTF_8);
|
||||||
|
final byte key2[] = "key2".getBytes(UTF_8);
|
||||||
|
final byte key3[] = "key3".getBytes(UTF_8);
|
||||||
|
try (final Options options = new Options().setCreateIfMissing(true)) {
|
||||||
|
final String dbPath = dbFolder.getRoot().getAbsolutePath();
|
||||||
|
try (final RocksDB db = RocksDB.open(options, dbPath)) {
|
||||||
|
db.put(key1, key1);
|
||||||
|
|
||||||
|
final RocksDB.CountAndSize stats =
|
||||||
|
db.getApproximateMemTableStats(new Range(new Slice(key1), new Slice(key3)));
|
||||||
|
|
||||||
|
assertThat(stats).isNotNull();
|
||||||
|
assertThat(stats.count).isEqualTo(1);
|
||||||
|
assertThat(stats.size).isGreaterThan(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Ignore("TODO(AR) re-enable when ready!")
|
@Ignore("TODO(AR) re-enable when ready!")
|
||||||
@Test
|
@Test
|
||||||
public void compactFiles() throws RocksDBException {
|
public void compactFiles() throws RocksDBException {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user