[Java] Include WriteBatch into RocksDBSample.java, fix how DbBenchmark.java handles WriteBatch.
Summary: Include WriteBatch into RocksDBSample.java, fix how DbBenchmark.java handles WriteBatch. Previously DbBenchmark.java does not use WriteBatch when benchmarks is set to fillbatch. Test Plan: make rocksdbjava -j32 make jtest make jdb_bench cd java ./jdb_bench.sh --benchmarks=fillbatch Reviewers: naveenatceg, ljin, sdong, ankgup87 Reviewed By: ankgup87 Subscribers: leveldb Differential Revision: https://reviews.facebook.net/D22983
This commit is contained in:
parent
4a27a2f193
commit
acb9348ff3
@ -72,6 +72,8 @@ public class RocksDBSample {
|
||||
assert(options.memTableFactoryName().equals("SkipListFactory"));
|
||||
|
||||
options.setTableFormatConfig(new PlainTableConfig());
|
||||
// Plain-Table requires mmap read
|
||||
options.setAllowMmapReads(true);
|
||||
assert(options.tableFactoryName().equals("PlainTable"));
|
||||
|
||||
BlockBasedTableConfig table_options = new BlockBasedTableConfig();
|
||||
@ -121,6 +123,29 @@ public class RocksDBSample {
|
||||
System.out.println("");
|
||||
}
|
||||
|
||||
// write batch test
|
||||
WriteOptions writeOpt = new WriteOptions();
|
||||
for (int i = 10; i <= 19; ++i) {
|
||||
WriteBatch batch = new WriteBatch();
|
||||
for (int j = 10; j <= 19; ++j) {
|
||||
batch.put(String.format("%dx%d", i, j).getBytes(),
|
||||
String.format("%d", i * j).getBytes());
|
||||
}
|
||||
db.write(writeOpt, batch);
|
||||
batch.dispose();
|
||||
}
|
||||
for (int i = 10; i <= 19; ++i) {
|
||||
for (int j = 10; j <= 19; ++j) {
|
||||
assert(new String(
|
||||
db.get(String.format("%dx%d", i, j).getBytes())).equals(
|
||||
String.format("%d", i * j)));
|
||||
System.out.format("%s ", new String(db.get(
|
||||
String.format("%dx%d", i, j).getBytes())));
|
||||
}
|
||||
System.out.println("");
|
||||
}
|
||||
writeOpt.dispose();
|
||||
|
||||
value = db.get("1x1".getBytes());
|
||||
assert(value != null);
|
||||
value = db.get("world".getBytes());
|
||||
|
@ -255,7 +255,7 @@ public class DbBenchmark {
|
||||
for (long j = 0; j < entriesPerBatch_; j++) {
|
||||
getKey(key, i + j, keyRange_);
|
||||
DbBenchmark.this.gen_.generate(value);
|
||||
db_.put(writeOpt_, key, value);
|
||||
batch.put(key, value);
|
||||
stats_.finishedSingleOp(keySize_ + valueSize_);
|
||||
}
|
||||
db_.write(writeOpt_, batch);
|
||||
|
Loading…
x
Reference in New Issue
Block a user