Fix statistics in RocksJava sample

Summary:
I observed while doing a `make jtest` that the java sample was broken, due to the changes in #2551 .
Closes https://github.com/facebook/rocksdb/pull/2674

Differential Revision: D5539807

Pulled By: sagar0

fbshipit-source-id: 2c7e9d84778099dfa1c611996b444efe3c9fd466
This commit is contained in:
Sagar Vemuri 2017-08-01 16:42:42 -07:00 committed by Facebook Github Bot
parent 1900771bd2
commit 3453870677

View File

@ -31,6 +31,7 @@ public class RocksDBSample {
final Filter bloomFilter = new BloomFilter(10); final Filter bloomFilter = new BloomFilter(10);
final ReadOptions readOptions = new ReadOptions() final ReadOptions readOptions = new ReadOptions()
.setFillCache(false); .setFillCache(false);
final Statistics stats = new Statistics();
final RateLimiter rateLimiter = new RateLimiter(10000000,10000, 10)) { final RateLimiter rateLimiter = new RateLimiter(10000000,10000, 10)) {
try (final RocksDB db = RocksDB.open(options, db_path_not_found)) { try (final RocksDB db = RocksDB.open(options, db_path_not_found)) {
@ -41,7 +42,7 @@ public class RocksDBSample {
try { try {
options.setCreateIfMissing(true) options.setCreateIfMissing(true)
.createStatistics() .setStatistics(stats)
.setWriteBufferSize(8 * SizeUnit.KB) .setWriteBufferSize(8 * SizeUnit.KB)
.setMaxWriteBufferNumber(3) .setMaxWriteBufferNumber(3)
.setMaxBackgroundCompactions(10) .setMaxBackgroundCompactions(10)
@ -51,8 +52,6 @@ public class RocksDBSample {
assert (false); assert (false);
} }
final Statistics stats = options.statisticsPtr();
assert (options.createIfMissing() == true); assert (options.createIfMissing() == true);
assert (options.writeBufferSize() == 8 * SizeUnit.KB); assert (options.writeBufferSize() == 8 * SizeUnit.KB);
assert (options.maxWriteBufferNumber() == 3); assert (options.maxWriteBufferNumber() == 3);
@ -221,7 +220,9 @@ public class RocksDBSample {
try { try {
for (final TickerType statsType : TickerType.values()) { for (final TickerType statsType : TickerType.values()) {
stats.getTickerCount(statsType); if (statsType != TickerType.TICKER_ENUM_MAX) {
stats.getTickerCount(statsType);
}
} }
System.out.println("getTickerCount() passed."); System.out.println("getTickerCount() passed.");
} catch (final Exception e) { } catch (final Exception e) {
@ -231,7 +232,9 @@ public class RocksDBSample {
try { try {
for (final HistogramType histogramType : HistogramType.values()) { for (final HistogramType histogramType : HistogramType.values()) {
HistogramData data = stats.getHistogramData(histogramType); if (histogramType != HistogramType.HISTOGRAM_ENUM_MAX) {
HistogramData data = stats.getHistogramData(histogramType);
}
} }
System.out.println("getHistogramData() passed."); System.out.println("getHistogramData() passed.");
} catch (final Exception e) { } catch (final Exception e) {