[Java] Add Java support for cache sharding.

Summary:
Add setCacheNumShardBits() and cacheNumShardBits() to Options.  This allows
developers to control the number of shards for the block cache.

Test Plan:
make rocksdbjava
cd java
make db_bench
./jdb_bench.sh --cache_size=1048576 --cache_numshardbits=6

Reviewers: sdong, ljin, ankgup87

Reviewed By: ankgup87

Subscribers: leveldb

Differential Revision: https://reviews.facebook.net/D19347
This commit is contained in:
Yueh-Hsuan Chiang
2014-07-22 09:48:37 -07:00
parent ae7743f226
commit d19aa25594
5 changed files with 49 additions and 5 deletions

View File

@@ -106,7 +106,8 @@ public class RocksDB extends RocksObject {
// in RocksDB can prevent Java to GC during the life-time of
// the currently-created RocksDB.
RocksDB db = new RocksDB();
db.open(options.nativeHandle_, options.cacheSize_, path);
db.open(options.nativeHandle_, options.cacheSize_,
options.numShardBits_, path);
db.transferCppRawPointersOwnershipFrom(options);
return db;
}
@@ -330,7 +331,8 @@ public class RocksDB extends RocksObject {
// native methods
protected native void open(
long optionsHandle, long cacheSize, String path) throws RocksDBException;
long optionsHandle, long cacheSize, int numShardBits,
String path) throws RocksDBException;
protected native void put(
long handle, byte[] key, int keyLen,
byte[] value, int valueLen) throws RocksDBException;