[JAVA] Add java binding for Options.block_cache.

Summary:
Add java bindings for Options.block_cache and allow DbBenchmark to
set cache_size.

Test Plan:
make rocksdbjava
make jtest
make jdb_Bench

Reviewers: haobo, sdong, ankgup87

Reviewed By: ankgup87

CC: leveldb, dhruba

Differential Revision: https://reviews.facebook.net/D17481
This commit is contained in:
Yueh-Hsuan Chiang
2014-04-14 13:42:36 -07:00
parent 2885ad9b77
commit 31e7e7fe84
6 changed files with 84 additions and 44 deletions

View File

@@ -13,6 +13,7 @@ package org.rocksdb;
* become out-of-scope to release the allocated memory in c++.
*/
public class Options {
static final long DEFAULT_CACHE_SIZE = 8 << 20;
/**
* Construct options for opening a RocksDB.
*
@@ -21,6 +22,7 @@ public class Options {
*/
public Options() {
nativeHandle_ = 0;
cacheSize_ = DEFAULT_CACHE_SIZE;
newOptions();
}
@@ -198,6 +200,24 @@ public class Options {
return maxBackgroundCompactions(nativeHandle_);
}
/**
* Set the amount of cache in bytes that will be used by RocksDB.
* If cacheSize is non-positive, then cache will not be used.
*
* DEFAULT: 8M
*/
public Options setCacheSize(long cacheSize) {
cacheSize_ = cacheSize;
return this;
}
/**
* @return the amount of cache in bytes that will be used by RocksDB.
*/
public long cacheSize() {
return cacheSize_;
}
/**
* Release the memory allocated for the current instance
* in the c++ side.
@@ -231,4 +251,5 @@ public class Options {
private native int maxBackgroundCompactions(long handle);
long nativeHandle_;
long cacheSize_;
}