[Java] Add SizeUnit in org.rocksdb.util to store const like KB, GB.

Summary:
* Add a class SizeUnit to store frequently used consts.  Currently
  it has KB, MB, GB, TB, and PB.

* Change the parameter type of Options.writeBufferSize and Options.blockSize
  from int to long.

Test Plan:
make rocksdbjava
make jtest

Reviewers: haobo, ankgup87, sdong, dhruba

Reviewed By: haobo

CC: leveldb

Differential Revision: https://reviews.facebook.net/D17703
This commit is contained in:
Yueh-Hsuan Chiang
2014-04-14 14:03:43 -07:00
parent 31e7e7fe84
commit 51f4b5090d
5 changed files with 39 additions and 22 deletions

View File

@@ -6,6 +6,7 @@
import java.util.*;
import java.lang.*;
import org.rocksdb.*;
import org.rocksdb.util.SizeUnit;
import java.io.IOException;
public class RocksDBSample {
@@ -33,17 +34,17 @@ public class RocksDBSample {
}
options.setCreateIfMissing(true)
.setWriteBufferSize(8 * 1024)
.setWriteBufferSize(8 * SizeUnit.KB)
.setMaxWriteBufferNumber(3)
.setDisableSeekCompaction(true)
.setBlockSize(64 * 1024)
.setBlockSize(64 * SizeUnit.KB)
.setMaxBackgroundCompactions(10);
assert(options.createIfMissing() == true);
assert(options.writeBufferSize() == 8192);
assert(options.writeBufferSize() == 8 * SizeUnit.KB);
assert(options.maxWriteBufferNumber() == 3);
assert(options.disableSeekCompaction() == true);
assert(options.blockSize() == 65536);
assert(options.blockSize() == 64 * SizeUnit.KB);
assert(options.maxBackgroundCompactions() == 10);
try {