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:
Jay Zhuang 2021-03-31 09:45:47 -07:00 committed by Facebook GitHub Bot
parent 493a4e28d9
commit a781b103da
2 changed files with 22 additions and 3 deletions

View File

@ -2428,14 +2428,13 @@ jlongArray Java_org_rocksdb_RocksDB_getApproximateMemTableStats(
static_cast<jlong>(count),
static_cast<jlong>(sizes)};
const jsize jcount = static_cast<jsize>(count);
jlongArray jsizes = env->NewLongArray(jcount);
jlongArray jsizes = env->NewLongArray(2);
if (jsizes == nullptr) {
// exception thrown: OutOfMemoryError
return nullptr;
}
env->SetLongArrayRegion(jsizes, 0, jcount, results);
env->SetLongArrayRegion(jsizes, 0, 2, results);
if (env->ExceptionCheck()) {
// exception thrown: ArrayIndexOutOfBoundsException
env->DeleteLocalRef(jsizes);

View File

@ -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!")
@Test
public void compactFiles() throws RocksDBException {