Exception thrown from getApproximateMemTableStats when less than 2 records in the range
- Dominant language
- C++
- Stars
- 32.1k
- Forks
- 6.9k
- Avg merge
- 32m
- Merged PRs (30d)
- 1
Description
> Note: Please use Issues only for bug reports. For questions, discussions, feature requests, etc. post to dev group: https://groups.google.com/forum/#!forum/rocksdb or https://www.facebook.com/groups/rocksdb.dev
In rocksdb java[6.13.3], when calling getApproximateMemTableStats with a range containing 0 or 1 record, following exception will be thrown:
java.lang.ArrayIndexOutOfBoundsException: 1
at org.rocksdb.RocksDB.getApproximateMemTableStats(RocksDB.java:3147)
at org.rocksdb.RocksDB.getApproximateMemTableStats(RocksDB.java:3161)
### Expected behavior
No exception thrown
### Actual behavior
ArrayIndexOutOfBoundsException thrown
### Steps to reproduce the behavior
```
@Test
public void getApproximateMemTableStats() 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);
// db.put(key2, key2); <-- uncomment this line will make the test pass
final RocksDB.CountAndSize stats = db.getApproximateMemTableStats(new Range(new Slice(key1), new Slice(key3)));
assertNotNull(stats);
assertTrue(stats.count > 1);
assertTrue(stats.size > 1);
}
}
}
```
Contributor guide
Assessment
This issue has not been assessed yet.