Skip to content

Commit

Permalink
[Java] Include WriteBatch into RocksDBSample.java, fix how DbBenchmar…
Browse files Browse the repository at this point in the history
…k.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
  • Loading branch information
yhchiang committed Sep 15, 2014
1 parent 4a27a2f commit acb9348
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
25 changes: 25 additions & 0 deletions java/RocksDBSample.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ public static void main(String[] args) {
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();
Expand Down Expand Up @@ -121,6 +123,29 @@ public static void main(String[] args) {
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());
Expand Down
2 changes: 1 addition & 1 deletion java/org/rocksdb/benchmark/DbBenchmark.java
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ public WriteTask(
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);
Expand Down

0 comments on commit acb9348

Please sign in to comment.