[JNI] Each set function of Options / WriteOptions now returns its option instance.

Summary:
Make each set function of Options / WriteOptions return its option instance.
Java developers can now easier specify each option like the following:

    options.setCreateIfMissing(true)
        .setWriteBufferSize(8 * 1024)
        .setMaxWriteBufferNumber(3)
        .setDisableSeekCompaction(true)
        .setBlockSize(64 * 1024)
        .setMaxBackgroundCompactions(10);

Test Plan:
make rocksdbjava
make jtest

Reviewers: haobo, ankgup87, sdong, dhruba

Reviewed By: haobo

CC: leveldb

Differential Revision: https://reviews.facebook.net/D17661
This commit is contained in:
Yueh-Hsuan Chiang
2014-04-14 12:48:50 -07:00
parent be016613c2
commit 2885ad9b77
3 changed files with 55 additions and 31 deletions

View File

@@ -40,9 +40,14 @@ public class WriteOptions {
* system call followed by "fdatasync()".
*
* Default: false
*
* @param flag a boolean flag to indicate whether a write
* should be synchronized.
* @return the instance of the current WriteOptions.
*/
public void setSync(boolean flag) {
public WriteOptions setSync(boolean flag) {
setSync(nativeHandle_, flag);
return this;
}
/**
@@ -68,9 +73,14 @@ public class WriteOptions {
/**
* If true, writes will not first go to the write ahead log,
* and the write may got lost after a crash.
*
* @param flag a boolean flag to specify whether to disable
* write-ahead-log on writes.
* @return the instance of the current WriteOptions.
*/
public void setDisableWAL(boolean flag) {
public WriteOptions setDisableWAL(boolean flag) {
setDisableWAL(nativeHandle_, flag);
return this;
}
/**
@@ -92,5 +102,5 @@ public class WriteOptions {
private native boolean disableWAL(long handle);
private native void dispose0(long handle);
protected long nativeHandle_;
protected long nativeHandle_;
}