mirror of
https://github.com/XRPLF/rippled.git
synced 2026-04-29 15:37:57 +00:00
Squashed 'src/rocksdb2/' changes from 25888ae..1fdd726
1fdd726 Hotfix RocksDB 3.5 d67500a Add `make install` to Makefile in 3.5.fb. 4cb631a update HISTORY.md cfd0946 comments about the BlockBasedTableOptions migration in Options REVERT: 25888ae Merge pull request #329 from fyrz/master REVERT: 89833e5 Fixed signed-unsigned comparison warning in db_test.cc REVERT: fcac705 Fixed compile warning on Mac caused by unused variables. REVERT: b3343fd resolution for java build problem introduced by 5ec53f3edf62bec1b690ce12fb21a6c52203f3c8 REVERT: 187b299 ForwardIterator: update prev_key_ only if prefix hasn't changed REVERT: 5ec53f3 make compaction related options changeable REVERT: d122e7b Update INSTALL.md REVERT: 986dad0 Merge pull request #324 from dalgaaf/wip-da-SCA-20140930 REVERT: 8ee75dc db/memtable.cc: remove unused variable merge_result REVERT: 0fd8bbc db/db_impl.cc: reduce scope of prefix_initialized REVERT: 676ff7b compaction_picker.cc: remove check for >=0 for unsigned REVERT: e55aea5 document_db.cc: fix assert REVERT: d517c83 in_table_factory.cc: use correct format specifier REVERT: b140375 ttl/ttl_test.cc: prefer prefix ++operator for non-primitive types REVERT: 43c789c spatialdb/spatial_db.cc: use !empty() instead of 'size() > 0' REVERT: 0de452e document_db.cc: pass const parameter by reference REVERT: 4cc8643 util/ldb_cmd.cc: prefer prefix ++operator for non-primitive types REVERT: af8c2b2 util/signal_test.cc: suppress intentional null pointer deref REVERT: 33580fa db/db_impl.cc: fix object handling, remove double lines REVERT: 873f135 db_ttl_impl.h: pass func parameter by reference REVERT: 8558457 ldb_cmd_execute_result.h: perform init in initialization list REVERT: 063471b table/table_test.cc: pass func parameter by reference REVERT: 93548ce table/cuckoo_table_reader.cc: pass func parameter by ref REVERT: b8b7117 db/version_set.cc: use !empty() instead of 'size() > 0' REVERT: 8ce050b table/bloom_block.*: pass func parameter by reference REVERT: 53910dd db_test.cc: pass parameter by reference REVERT: 68ca534 corruption_test.cc: pass parameter by reference REVERT: 7506198 cuckoo_table_db_test.cc: add flush after delete REVERT: 1f96330 Print MB per second compaction throughput separately for reads and writes REVERT: ffe3d49 Add an instruction about SSE in INSTALL.md REVERT: ee1f3cc Package generation for Ubuntu and CentOS REVERT: f0f7955 Fixing comile errors on OS X REVERT: 99fb613 remove 2 space linter REVERT: b2d64a4 Fix linters, second try REVERT: 747523d Print per column family metrics in db_bench REVERT: 56ebd40 Fix arc lint (should fix #238) REVERT: 637f891 Merge pull request #321 from eonnen/master REVERT: 827e31c Make test use a compatible type in the size checks. REVERT: fd5d80d CompactedDB: log using the correct info_log REVERT: 2faf49d use GetContext to replace callback function pointer REVERT: 983d2de Add AUTHORS file. Fix #203 REVERT: abd70c5 Merge pull request #316 from fyrz/ReverseBytewiseComparator REVERT: 2dc6f62 handle kDelete type in cuckoo builder REVERT: 8b8011a Changed name of ReverseBytewiseComparator based on review comment REVERT: 389edb6 universal compaction picker: use double for potential overflow REVERT: 5340484 Built-in comparator(s) in RocksJava REVERT: d439451 delay initialization of cuckoo table iterator REVERT: 94997ea reduce memory usage of cuckoo table builder REVERT: c627595 improve memory efficiency of cuckoo reader REVERT: 581442d option to choose module when calculating CuckooTable hash REVERT: fbd2daf CompactedDBImpl::MultiGet() for better CuckooTable performance REVERT: 3c68006 CompactedDBImpl REVERT: f7375f3 Fix double deletes REVERT: 21ddcf6 Remove allow_thread_local REVERT: fb4a492 Merge pull request #311 from ankgup87/master REVERT: 611e286 Merge branch 'master' of https://github.com/facebook/rocksdb REVERT: 0103b44 Merge branch 'master' of ssh://github.com/ankgup87/rocksdb REVERT: 1dfb7bb Add block based table config options REVERT: cdaf44f Enlarge log size cap when printing file summary REVERT: 7cc1ed7 Merge pull request #309 from naveenatceg/staticbuild REVERT: ba6d660 Resolving merge conflict REVERT: 51eeaf6 Addressing review comments REVERT: fd7d3fe Addressing review comments (adding a env variable to override temp directory) REVERT: cf7ace8 Addressing review comments REVERT: 0a29ce5 re-enable BlockBasedTable::SetupForCompaction() REVERT: 55af370 Remove TODO for checking index checksums REVERT: 3d74f09 Fix compile REVERT: 53b0039 Fix release compile REVERT: d0de413 WriteBatchWithIndex to allow different Comparators for different column families REVERT: 57a32f1 change target_file_size_base to uint64_t REVERT: 5e6aee4 dont create backup_input if compaction filter v2 is not used REVERT: 49b5f94 Merge pull request #306 from Liuchang0812/fix_cast REVERT: 787cb4d remove cast, replace %llu with % PRIu64 REVERT: a7574d4 Update logging.cc REVERT: 7e0dcb9 Update logging.cc REVERT: 57fa3cc Merge pull request #304 from Liuchang0812/fix-check REVERT: cd44522 Merge pull request #305 from Liuchang0812/fix-logging REVERT: 6a031b6 remove unused variable REVERT: 4436f17 fixed #303: replace %ld with % PRId64 REVERT: 7a1bd05 Merge pull request #302 from ankgup87/master REVERT: 423e52c Merge branch 'master' of https://github.com/facebook/rocksdb REVERT: bfeef94 Add rate limiter REVERT: 32f2532 Print compression_size_percent as a signed int REVERT: 976caca Skip AllocateTest if fallocate() is not supported in the file system REVERT: 3b897cd Enable no-fbcode RocksDB build REVERT: f445947 RocksDB: Format uint64 using PRIu64 in db_impl.cc REVERT: e17bc65 Merge pull request #299 from ankgup87/master REVERT: b93797a Fix build REVERT: adae3ca [Java] Fix JNI link error caused by the removal of options.db_stats_log_interval REVERT: 90b8c07 Fix unit tests errors REVERT: 51af7c3 CuckooTable: add one option to allow identity function for the first hash function REVERT: 0350435 Fixed a signed-unsigned comparison in spatial_db.cc -- issue #293 REVERT: 2fb1fea Fix syncronization issues REVERT: ff76895 Remove some unnecessary constructors REVERT: feadb9d fix cuckoo table builder test REVERT: 3c232e1 Fix mac compile REVERT: 54cada9 Run make format on PR #249 REVERT: 27b22f1 Merge pull request #249 from tdfischer/decompression-refactoring REVERT: fb6456b Replace naked calls to operator new and delete (Fixes #222) REVERT: 5600c8f cuckoo table: return estimated size - 1 REVERT: a062e1f SetOptions() for memtable related options REVERT: e4eca6a Options conversion function for convenience REVERT: a7c2094 Merge pull request #292 from saghmrossi/master REVERT: 4d05234 Merge branch 'master' of github.com:saghmrossi/rocksdb REVERT: 60a4aa1 Test use_mmap_reads REVERT: 94e43a1 [Java] Fixed 32-bit overflowing issue when converting jlong to size_t REVERT: f9eaaa6 added include for inttypes.h to fix nonworking printf statements REVERT: f090575 Replaced "built on on earlier work" by "built on earlier work" in README.md REVERT: faad439 Fix #284 REVERT: 49aacd8 Fix make install REVERT: acb9348 [Java] Include WriteBatch into RocksDBSample.java, fix how DbBenchmark.java handles WriteBatch. REVERT: 4a27a2f Don't sync manifest when disableDataSync = true REVERT: 9b8480d Merge pull request #287 from yinqiwen/rate-limiter-crash-fix REVERT: 28be16b fix rate limiter crash #286 REVERT: 04ce1b2 Fix #284 REVERT: add22e3 standardize scripts to run RocksDB benchmarks REVERT: dee91c2 WriteThread REVERT: 540a257 Fix WAL synced REVERT: 24f034b Merge pull request #282 from Chilledheart/develop REVERT: 49fe329 Fix build issue under macosx REVERT: ebb5c65 Add make install REVERT: 0352a9f add_wrapped_bloom_test REVERT: 9c0e66c Don't run background jobs (flush, compactions) when bg_error_ is set REVERT: a9639bd Fix valgrind test REVERT: d1f24dc Relax FlushSchedule test REVERT: 3d9e6f7 Push model for flushing memtables REVERT: 059e584 [unit test] CompactRange should fail if we don't have space REVERT: dd641b2 fix RocksDB java build REVERT: 53404d9 add_qps_info_in cache bench REVERT: a52cecb Fix Mac compile REVERT: 092f97e Fix comments and typos REVERT: 6cc1286 Added a few statistics for BackupableDB REVERT: 0a42295 Fix SimpleWriteTimeoutTest REVERT: 06d9862 Always pass MergeContext as pointer, not reference REVERT: d343c3f Improve db recovery REVERT: 6bb7e3e Merger test REVERT: 88841bd Explicitly cast char to signed char in Hash() REVERT: 5231146 MemTableOptions REVERT: 1d284db Addressing review comments REVERT: 55114e7 Some updates for SpatialDB REVERT: 171d4ff remove TailingIterator reference in db_impl.h REVERT: 9b0f7ff rename version_set options_ to db_options_ to avoid confusion REVERT: 2d57828 Check stop level trigger-0 before slowdown level-0 trigger REVERT: 659d2d5 move compaction_filter to immutable_options REVERT: 048560a reduce references to cfd->options() in DBImpl REVERT: 011241b DB::Flush() Do not wait for background threads when there is nothing in mem table REVERT: a2bb7c3 Push- instead of pull-model for managing Write stalls REVERT: 0af157f Implement full filter for block based table. REVERT: 9360cc6 Fix valgrind issue REVERT: 02d5bff Merge pull request #277 from wankai/master REVERT: 88a2f44 fix comments REVERT: 7c16e39 Merge pull request #276 from wankai/master REVERT: 8237738 replace hard-coded number with named variable REVERT: db8ca52 Merge pull request #273 from nbougalis/static-analysis REVERT: b7b031f Merge pull request #274 from wankai/master REVERT: 4c2b1f0 Merge remote-tracking branch 'upstream/master' REVERT: a5d2863 typo improvement REVERT: 9f8aa09 Don't leak data returned by opendir REVERT: d1cfb71 Remove unused member(s) REVERT: bfee319 sizeof(int*) where sizeof(int) was intended REVERT: d40c1f7 Add missing break statement REVERT: 2e97c38 Avoid off-by-one error when using readlink REVERT: 40ddc3d add cache bench REVERT: 9f1c80b Drop column family from write thread REVERT: 8de151b Add db_bench with lots of column families to regression tests REVERT: c9e419c rename options_ to db_options_ in DBImpl to avoid confusion REVERT: 5cd0576 Fix compaction bug in Cuckoo Table Builder. Use kvs_.size() instead of num_entries in FileSize() method. REVERT: 0fbb3fa fixed memory leak in unit test DBIteratorBoundTest REVERT: adcd253 fix asan check REVERT: 4092b7a Merge pull request #272 from project-zerus/patch-1 REVERT: bb6ae0f fix more compile warnings REVERT: 6d31441 Merge pull request #271 from nbougalis/cleanups REVERT: 0cd0ec4 Plug memory leak during index creation REVERT: 4329d74 Fix swapped variable names to accurately reflect usage REVERT: 45a5e3e Remove path with arena==nullptr from NewInternalIterator REVERT: 5665e5e introduce ImmutableOptions REVERT: e0b99d4 created a new ReadOptions parameter 'iterate_upper_bound' REVERT: 51ea889 Fix travis builds REVERT: a481626 Relax backupable rate limiting test REVERT: f7f973d Merge pull request #269 from huahang/patch-2 REVERT: ef5b384 fix a few compile warnings REVERT: 2fd3806 Merge pull request #263 from wankai/master REVERT: 1785114 delete unused Comparator REVERT: 1b1d961 update HISTORY.md REVERT: 703c3ea comments about the BlockBasedTableOptions migration in Options REVERT: 4b5ad88 Merge pull request #260 from wankai/master REVERT: 19cc588 change to filter_block std::unique_ptr support RAII REVERT: 9b976e3 Merge pull request #259 from wankai/master REVERT: 5d25a46 Merge remote-tracking branch 'upstream/master' REVERT: dff2b1a typo improvement REVERT: 343e98a Reverting import change REVERT: ddb8039 RocksDB static build Make file changes to download and build the dependencies .Load the shared library when RocksDB is initialized git-subtree-dir: src/rocksdb2 git-subtree-split: 1fdd726a8254c13d0c66d8db8130ad17c13d7bcc
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
NATIVE_JAVA_CLASSES = org.rocksdb.RocksDB org.rocksdb.Options org.rocksdb.WriteBatch org.rocksdb.WriteBatchInternal org.rocksdb.WriteBatchTest org.rocksdb.WriteOptions org.rocksdb.BackupableDB org.rocksdb.BackupableDBOptions org.rocksdb.Statistics org.rocksdb.RocksIterator org.rocksdb.VectorMemTableConfig org.rocksdb.SkipListMemTableConfig org.rocksdb.HashLinkedListMemTableConfig org.rocksdb.HashSkipListMemTableConfig org.rocksdb.PlainTableConfig org.rocksdb.BlockBasedTableConfig org.rocksdb.ReadOptions org.rocksdb.Filter org.rocksdb.BloomFilter org.rocksdb.RestoreOptions org.rocksdb.RestoreBackupableDB org.rocksdb.RocksEnv org.rocksdb.GenericRateLimiterConfig
|
||||
NATIVE_JAVA_CLASSES = org.rocksdb.RocksDB org.rocksdb.Options org.rocksdb.WriteBatch org.rocksdb.WriteBatchInternal org.rocksdb.WriteBatchTest org.rocksdb.WriteOptions org.rocksdb.BackupableDB org.rocksdb.BackupableDBOptions org.rocksdb.Statistics org.rocksdb.RocksIterator org.rocksdb.VectorMemTableConfig org.rocksdb.SkipListMemTableConfig org.rocksdb.HashLinkedListMemTableConfig org.rocksdb.HashSkipListMemTableConfig org.rocksdb.PlainTableConfig org.rocksdb.BlockBasedTableConfig org.rocksdb.ReadOptions org.rocksdb.Filter org.rocksdb.BloomFilter org.rocksdb.RestoreOptions org.rocksdb.RestoreBackupableDB org.rocksdb.RocksEnv
|
||||
|
||||
NATIVE_INCLUDE = ./include
|
||||
ROCKSDB_JAR = rocksdbjni.jar
|
||||
|
||||
@@ -72,34 +72,14 @@ 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"));
|
||||
|
||||
options.setRateLimiterConfig(new GenericRateLimiterConfig(10000000,
|
||||
10000, 10));
|
||||
options.setRateLimiterConfig(new GenericRateLimiterConfig(10000000));
|
||||
|
||||
BlockBasedTableConfig table_options = new BlockBasedTableConfig();
|
||||
table_options.setBlockCacheSize(64 * SizeUnit.KB)
|
||||
.setFilterBitsPerKey(10)
|
||||
.setCacheNumShardBits(6)
|
||||
.setBlockSizeDeviation(5)
|
||||
.setBlockRestartInterval(10)
|
||||
.setCacheIndexAndFilterBlocks(true)
|
||||
.setHashIndexAllowCollision(false)
|
||||
.setBlockCacheCompressedSize(64 * SizeUnit.KB)
|
||||
.setBlockCacheCompressedNumShardBits(10);
|
||||
|
||||
.setCacheNumShardBits(6);
|
||||
assert(table_options.blockCacheSize() == 64 * SizeUnit.KB);
|
||||
assert(table_options.cacheNumShardBits() == 6);
|
||||
assert(table_options.blockSizeDeviation() == 5);
|
||||
assert(table_options.blockRestartInterval() == 10);
|
||||
assert(table_options.cacheIndexAndFilterBlocks() == true);
|
||||
assert(table_options.hashIndexAllowCollision() == false);
|
||||
assert(table_options.blockCacheCompressedSize() == 64 * SizeUnit.KB);
|
||||
assert(table_options.blockCacheCompressedNumShardBits() == 10);
|
||||
|
||||
options.setTableFormatConfig(table_options);
|
||||
assert(options.tableFactoryName().equals("BlockBasedTable"));
|
||||
|
||||
@@ -108,8 +88,6 @@ public class RocksDBSample {
|
||||
db.put("hello".getBytes(), "world".getBytes());
|
||||
byte[] value = db.get("hello".getBytes());
|
||||
assert("world".equals(new String(value)));
|
||||
String str = db.getProperty("rocksdb.stats");
|
||||
assert(str != null && str != "");
|
||||
} catch (RocksDBException e) {
|
||||
System.out.format("[ERROR] caught the unexpceted exception -- %s\n", e);
|
||||
assert(db == null);
|
||||
@@ -143,29 +121,6 @@ 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());
|
||||
|
||||
@@ -14,14 +14,11 @@ public class BlockBasedTableConfig extends TableFormatConfig {
|
||||
public BlockBasedTableConfig() {
|
||||
noBlockCache_ = false;
|
||||
blockCacheSize_ = 8 * 1024 * 1024;
|
||||
blockSize_ = 4 * 1024;
|
||||
blockSizeDeviation_ = 10;
|
||||
blockRestartInterval_ = 16;
|
||||
blockSize_ = 4 * 1024;
|
||||
blockSizeDeviation_ =10;
|
||||
blockRestartInterval_ =16;
|
||||
wholeKeyFiltering_ = true;
|
||||
bitsPerKey_ = 10;
|
||||
cacheIndexAndFilterBlocks_ = false;
|
||||
hashIndexAllowCollision_ = true;
|
||||
blockCacheCompressedSize_ = 0;
|
||||
bitsPerKey_ = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -74,8 +71,8 @@ public class BlockBasedTableConfig extends TableFormatConfig {
|
||||
* number means use default settings."
|
||||
* @return the reference to the current option.
|
||||
*/
|
||||
public BlockBasedTableConfig setCacheNumShardBits(int blockCacheNumShardBits) {
|
||||
blockCacheNumShardBits_ = blockCacheNumShardBits;
|
||||
public BlockBasedTableConfig setCacheNumShardBits(int numShardBits) {
|
||||
numShardBits_ = numShardBits;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -87,7 +84,7 @@ public class BlockBasedTableConfig extends TableFormatConfig {
|
||||
* @return the number of shard bits used in the block cache.
|
||||
*/
|
||||
public int cacheNumShardBits() {
|
||||
return blockCacheNumShardBits_;
|
||||
return numShardBits_;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -189,135 +186,25 @@ public class BlockBasedTableConfig extends TableFormatConfig {
|
||||
bitsPerKey_ = bitsPerKey;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicating if we'd put index/filter blocks to the block cache.
|
||||
If not specified, each "table reader" object will pre-load index/filter
|
||||
block during table initialization.
|
||||
*
|
||||
* @return if index and filter blocks should be put in block cache.
|
||||
*/
|
||||
public boolean cacheIndexAndFilterBlocks() {
|
||||
return cacheIndexAndFilterBlocks_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicating if we'd put index/filter blocks to the block cache.
|
||||
If not specified, each "table reader" object will pre-load index/filter
|
||||
block during table initialization.
|
||||
*
|
||||
* @param index and filter blocks should be put in block cache.
|
||||
* @return the reference to the current config.
|
||||
*/
|
||||
public BlockBasedTableConfig setCacheIndexAndFilterBlocks(
|
||||
boolean cacheIndexAndFilterBlocks) {
|
||||
cacheIndexAndFilterBlocks_ = cacheIndexAndFilterBlocks;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Influence the behavior when kHashSearch is used.
|
||||
if false, stores a precise prefix to block range mapping
|
||||
if true, does not store prefix and allows prefix hash collision
|
||||
(less memory consumption)
|
||||
*
|
||||
* @return if hash collisions should be allowed.
|
||||
*/
|
||||
public boolean hashIndexAllowCollision() {
|
||||
return hashIndexAllowCollision_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Influence the behavior when kHashSearch is used.
|
||||
if false, stores a precise prefix to block range mapping
|
||||
if true, does not store prefix and allows prefix hash collision
|
||||
(less memory consumption)
|
||||
*
|
||||
* @param if hash collisions should be allowed.
|
||||
* @return the reference to the current config.
|
||||
*/
|
||||
public BlockBasedTableConfig setHashIndexAllowCollision(
|
||||
boolean hashIndexAllowCollision) {
|
||||
hashIndexAllowCollision_ = hashIndexAllowCollision;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Size of compressed block cache. If 0, then block_cache_compressed is set
|
||||
* to null.
|
||||
*
|
||||
* @return size of compressed block cache.
|
||||
*/
|
||||
public long blockCacheCompressedSize() {
|
||||
return blockCacheCompressedSize_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Size of compressed block cache. If 0, then block_cache_compressed is set
|
||||
* to null.
|
||||
*
|
||||
* @param size of compressed block cache.
|
||||
* @return the reference to the current config.
|
||||
*/
|
||||
public BlockBasedTableConfig setBlockCacheCompressedSize(
|
||||
long blockCacheCompressedSize) {
|
||||
blockCacheCompressedSize_ = blockCacheCompressedSize;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Controls the number of shards for the block compressed cache.
|
||||
* This is applied only if blockCompressedCacheSize is set to non-negative.
|
||||
*
|
||||
* @return numShardBits the number of shard bits. The resulting
|
||||
* number of shards would be 2 ^ numShardBits. Any negative
|
||||
* number means use default settings.
|
||||
*/
|
||||
public int blockCacheCompressedNumShardBits() {
|
||||
return blockCacheCompressedNumShardBits_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Controls the number of shards for the block compressed cache.
|
||||
* This is applied only if blockCompressedCacheSize is set to non-negative.
|
||||
*
|
||||
* @param numShardBits the number of shard bits. The resulting
|
||||
* number of shards would be 2 ^ numShardBits. Any negative
|
||||
* number means use default settings."
|
||||
* @return the reference to the current option.
|
||||
*/
|
||||
public BlockBasedTableConfig setBlockCacheCompressedNumShardBits(
|
||||
int blockCacheCompressedNumShardBits) {
|
||||
blockCacheCompressedNumShardBits_ = blockCacheCompressedNumShardBits;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override protected long newTableFactoryHandle() {
|
||||
return newTableFactoryHandle(noBlockCache_, blockCacheSize_,
|
||||
blockCacheNumShardBits_, blockSize_, blockSizeDeviation_,
|
||||
blockRestartInterval_, wholeKeyFiltering_, bitsPerKey_,
|
||||
cacheIndexAndFilterBlocks_, hashIndexAllowCollision_,
|
||||
blockCacheCompressedSize_, blockCacheCompressedNumShardBits_);
|
||||
return newTableFactoryHandle(noBlockCache_, blockCacheSize_, numShardBits_,
|
||||
blockSize_, blockSizeDeviation_, blockRestartInterval_,
|
||||
wholeKeyFiltering_, bitsPerKey_);
|
||||
}
|
||||
|
||||
private native long newTableFactoryHandle(
|
||||
boolean noBlockCache, long blockCacheSize, int blockCacheNumShardBits,
|
||||
boolean noBlockCache, long blockCacheSize, int numShardbits,
|
||||
long blockSize, int blockSizeDeviation, int blockRestartInterval,
|
||||
boolean wholeKeyFiltering, int bitsPerKey,
|
||||
boolean cacheIndexAndFilterBlocks, boolean hashIndexAllowCollision,
|
||||
long blockCacheCompressedSize, int blockCacheCompressedNumShardBits);
|
||||
boolean wholeKeyFiltering, int bitsPerKey);
|
||||
|
||||
private boolean noBlockCache_;
|
||||
private long blockCacheSize_;
|
||||
private int blockCacheNumShardBits_;
|
||||
private int numShardBits_;
|
||||
private long shard;
|
||||
private long blockSize_;
|
||||
private int blockSizeDeviation_;
|
||||
private int blockRestartInterval_;
|
||||
private boolean wholeKeyFiltering_;
|
||||
private int bitsPerKey_;
|
||||
private boolean cacheIndexAndFilterBlocks_;
|
||||
private boolean hashIndexAllowCollision_;
|
||||
private long blockCacheCompressedSize_;
|
||||
private int blockCacheCompressedNumShardBits_;
|
||||
}
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
// Copyright (c) 2014, Facebook, Inc. All rights reserved.
|
||||
// This source code is licensed under the BSD-style license found in the
|
||||
// LICENSE file in the root directory of this source tree. An additional grant
|
||||
// of patent rights can be found in the PATENTS file in the same directory.
|
||||
package org.rocksdb;
|
||||
|
||||
/**
|
||||
* Config for rate limiter, which is used to control write rate of flush and
|
||||
* compaction.
|
||||
*/
|
||||
public class GenericRateLimiterConfig extends RateLimiterConfig {
|
||||
private static final long DEFAULT_REFILL_PERIOD_MICROS = (100 * 1000);
|
||||
private static final int DEFAULT_FAIRNESS = 10;
|
||||
|
||||
public GenericRateLimiterConfig(long rateBytesPerSecond,
|
||||
long refillPeriodMicros, int fairness) {
|
||||
rateBytesPerSecond_ = rateBytesPerSecond;
|
||||
refillPeriodMicros_ = refillPeriodMicros;
|
||||
fairness_ = fairness;
|
||||
}
|
||||
|
||||
public GenericRateLimiterConfig(long rateBytesPerSecond) {
|
||||
this(rateBytesPerSecond, DEFAULT_REFILL_PERIOD_MICROS, DEFAULT_FAIRNESS);
|
||||
}
|
||||
|
||||
@Override protected long newRateLimiterHandle() {
|
||||
return newRateLimiterHandle(rateBytesPerSecond_, refillPeriodMicros_,
|
||||
fairness_);
|
||||
}
|
||||
|
||||
private native long newRateLimiterHandle(long rateBytesPerSecond,
|
||||
long refillPeriodMicros, int fairness);
|
||||
private final long rateBytesPerSecond_;
|
||||
private final long refillPeriodMicros_;
|
||||
private final int fairness_;
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
package org.rocksdb;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
|
||||
/**
|
||||
* This class is used to load the RocksDB shared library from within the jar.
|
||||
* The shared library is extracted to a temp folder and loaded from there.
|
||||
*/
|
||||
public class NativeLibraryLoader {
|
||||
private static String sharedLibraryName = "librocksdbjni.so";
|
||||
private static String tempFilePrefix = "librocksdbjni";
|
||||
private static String tempFileSuffix = ".so";
|
||||
|
||||
public static void loadLibraryFromJar(String tmpDir)
|
||||
throws IOException {
|
||||
File temp;
|
||||
if(tmpDir == null || tmpDir.equals(""))
|
||||
temp = File.createTempFile(tempFilePrefix, tempFileSuffix);
|
||||
else
|
||||
temp = new File(tmpDir + "/" + sharedLibraryName);
|
||||
|
||||
temp.deleteOnExit();
|
||||
|
||||
if (!temp.exists()) {
|
||||
throw new RuntimeException("File " + temp.getAbsolutePath() + " does not exist.");
|
||||
}
|
||||
|
||||
byte[] buffer = new byte[102400];
|
||||
int readBytes;
|
||||
|
||||
InputStream is = ClassLoader.getSystemClassLoader().getResourceAsStream(sharedLibraryName);
|
||||
if (is == null) {
|
||||
throw new RuntimeException(sharedLibraryName + " was not found inside JAR.");
|
||||
}
|
||||
|
||||
OutputStream os = null;
|
||||
try {
|
||||
os = new FileOutputStream(temp);
|
||||
while ((readBytes = is.read(buffer)) != -1) {
|
||||
os.write(buffer, 0, readBytes);
|
||||
}
|
||||
} finally {
|
||||
if(os != null)
|
||||
os.close();
|
||||
|
||||
if(is != null)
|
||||
is.close();
|
||||
}
|
||||
|
||||
System.load(temp.getAbsolutePath());
|
||||
}
|
||||
/**
|
||||
* Private constructor to disallow instantiation
|
||||
*/
|
||||
private NativeLibraryLoader() {
|
||||
}
|
||||
}
|
||||
@@ -13,19 +13,8 @@ package org.rocksdb;
|
||||
* native resources will be released as part of the process.
|
||||
*/
|
||||
public class Options extends RocksObject {
|
||||
static {
|
||||
RocksDB.loadLibrary();
|
||||
}
|
||||
static final long DEFAULT_CACHE_SIZE = 8 << 20;
|
||||
static final int DEFAULT_NUM_SHARD_BITS = -1;
|
||||
|
||||
/**
|
||||
* Builtin RocksDB comparators
|
||||
*/
|
||||
public enum BuiltinComparator {
|
||||
BYTEWISE_COMPARATOR, REVERSE_BYTEWISE_COMPARATOR;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct options for opening a RocksDB.
|
||||
*
|
||||
@@ -86,21 +75,6 @@ public class Options extends RocksObject {
|
||||
return createIfMissing(nativeHandle_);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set BuiltinComparator to be used with RocksDB.
|
||||
*
|
||||
* Note: Comparator can be set once upon database creation.
|
||||
*
|
||||
* Default: BytewiseComparator.
|
||||
* @param builtinComparator a BuiltinComparator type.
|
||||
*/
|
||||
public void setBuiltinComparator(BuiltinComparator builtinComparator) {
|
||||
assert(isInitialized());
|
||||
setBuiltinComparator(nativeHandle_, builtinComparator.ordinal());
|
||||
}
|
||||
|
||||
private native void setBuiltinComparator(long handle, int builtinComparator);
|
||||
|
||||
/**
|
||||
* Amount of data to build up in memory (backed by an unsorted log
|
||||
* on disk) before converting to a sorted on-disk file.
|
||||
@@ -331,6 +305,40 @@ public class Options extends RocksObject {
|
||||
}
|
||||
private native void setUseFsync(long handle, boolean useFsync);
|
||||
|
||||
/**
|
||||
* The time interval in seconds between each two consecutive stats logs.
|
||||
* This number controls how often a new scribe log about
|
||||
* db deploy stats is written out.
|
||||
* -1 indicates no logging at all.
|
||||
*
|
||||
* @return the time interval in seconds between each two consecutive
|
||||
* stats logs.
|
||||
*/
|
||||
public int dbStatsLogInterval() {
|
||||
assert(isInitialized());
|
||||
return dbStatsLogInterval(nativeHandle_);
|
||||
}
|
||||
private native int dbStatsLogInterval(long handle);
|
||||
|
||||
/**
|
||||
* The time interval in seconds between each two consecutive stats logs.
|
||||
* This number controls how often a new scribe log about
|
||||
* db deploy stats is written out.
|
||||
* -1 indicates no logging at all.
|
||||
* Default value is 1800 (half an hour).
|
||||
*
|
||||
* @param dbStatsLogInterval the time interval in seconds between each
|
||||
* two consecutive stats logs.
|
||||
* @return the reference to the current option.
|
||||
*/
|
||||
public Options setDbStatsLogInterval(int dbStatsLogInterval) {
|
||||
assert(isInitialized());
|
||||
setDbStatsLogInterval(nativeHandle_, dbStatsLogInterval);
|
||||
return this;
|
||||
}
|
||||
private native void setDbStatsLogInterval(
|
||||
long handle, int dbStatsLogInterval);
|
||||
|
||||
/**
|
||||
* Returns the directory of info log.
|
||||
*
|
||||
@@ -1093,6 +1101,33 @@ public class Options extends RocksObject {
|
||||
private native void setBytesPerSync(
|
||||
long handle, long bytesPerSync);
|
||||
|
||||
/**
|
||||
* Allow RocksDB to use thread local storage to optimize performance.
|
||||
* Default: true
|
||||
*
|
||||
* @return true if thread-local storage is allowed
|
||||
*/
|
||||
public boolean allowThreadLocal() {
|
||||
assert(isInitialized());
|
||||
return allowThreadLocal(nativeHandle_);
|
||||
}
|
||||
private native boolean allowThreadLocal(long handle);
|
||||
|
||||
/**
|
||||
* Allow RocksDB to use thread local storage to optimize performance.
|
||||
* Default: true
|
||||
*
|
||||
* @param allowThreadLocal true if thread-local storage is allowed.
|
||||
* @return the reference to the current option.
|
||||
*/
|
||||
public Options setAllowThreadLocal(boolean allowThreadLocal) {
|
||||
assert(isInitialized());
|
||||
setAllowThreadLocal(nativeHandle_, allowThreadLocal);
|
||||
return this;
|
||||
}
|
||||
private native void setAllowThreadLocal(
|
||||
long handle, boolean allowThreadLocal);
|
||||
|
||||
/**
|
||||
* Set the config for mem-table.
|
||||
*
|
||||
@@ -1103,19 +1138,6 @@ public class Options extends RocksObject {
|
||||
setMemTableFactory(nativeHandle_, config.newMemTableFactoryHandle());
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use to control write rate of flush and compaction. Flush has higher
|
||||
* priority than compaction. Rate limiting is disabled if nullptr.
|
||||
* Default: nullptr
|
||||
*
|
||||
* @param config rate limiter config.
|
||||
* @return the instance of the current Options.
|
||||
*/
|
||||
public Options setRateLimiterConfig(RateLimiterConfig config) {
|
||||
setRateLimiter(nativeHandle_, config.newRateLimiterHandle());
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the current mem table representation.
|
||||
@@ -2204,8 +2226,6 @@ public class Options extends RocksObject {
|
||||
private native long statisticsPtr(long optHandle);
|
||||
|
||||
private native void setMemTableFactory(long handle, long factoryHandle);
|
||||
private native void setRateLimiter(long handle,
|
||||
long rateLimiterHandle);
|
||||
private native String memTableFactoryName(long handle);
|
||||
|
||||
private native void setTableFactory(long handle, long factoryHandle);
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
// Copyright (c) 2014, Facebook, Inc. All rights reserved.
|
||||
// This source code is licensed under the BSD-style license found in the
|
||||
// LICENSE file in the root directory of this source tree. An additional grant
|
||||
// of patent rights can be found in the PATENTS file in the same directory.
|
||||
package org.rocksdb;
|
||||
|
||||
/**
|
||||
* Config for rate limiter, which is used to control write rate of flush and
|
||||
* compaction.
|
||||
*/
|
||||
public abstract class RateLimiterConfig {
|
||||
/**
|
||||
* This function should only be called by Options.setRateLimiter(),
|
||||
* which will create a c++ shared-pointer to the c++ RateLimiter
|
||||
* that is associated with the Java RateLimtierConifg.
|
||||
*
|
||||
* @see Options.setRateLimiter()
|
||||
*/
|
||||
abstract protected long newRateLimiterHandle();
|
||||
}
|
||||
@@ -11,7 +11,6 @@ import java.util.HashMap;
|
||||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
import org.rocksdb.util.Environment;
|
||||
import org.rocksdb.NativeLibraryLoader;
|
||||
|
||||
/**
|
||||
* A RocksDB is a persistent ordered map from keys to values. It is safe for
|
||||
@@ -24,19 +23,11 @@ public class RocksDB extends RocksObject {
|
||||
private static final String[] compressionLibs_ = {
|
||||
"snappy", "z", "bzip2", "lz4", "lz4hc"};
|
||||
|
||||
static {
|
||||
RocksDB.loadLibrary();
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the necessary library files.
|
||||
* Calling this method twice will have no effect.
|
||||
* By default the method extracts the shared library for loading at
|
||||
* java.io.tmpdir, however, you can override this temporary location by
|
||||
* setting the environment variable ROCKSDB_SHAREDLIB_DIR.
|
||||
*/
|
||||
public static synchronized void loadLibrary() {
|
||||
String tmpDir = System.getenv("ROCKSDB_SHAREDLIB_DIR");
|
||||
// loading possibly necessary libraries.
|
||||
for (String lib : compressionLibs_) {
|
||||
try {
|
||||
@@ -45,14 +36,8 @@ public class RocksDB extends RocksObject {
|
||||
// since it may be optional, we ignore its loading failure here.
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
NativeLibraryLoader.loadLibraryFromJar(tmpDir);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
throw new RuntimeException("Unable to load the RocksDB shared library" + e);
|
||||
}
|
||||
// However, if any of them is required. We will see error here.
|
||||
System.loadLibrary("rocksdbjni");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -324,26 +309,6 @@ public class RocksDB extends RocksObject {
|
||||
throws RocksDBException {
|
||||
remove(nativeHandle_, writeOpt.nativeHandle_, key, key.length);
|
||||
}
|
||||
|
||||
/**
|
||||
* DB implementations can export properties about their state
|
||||
via this method. If "property" is a valid property understood by this
|
||||
DB implementation, fills "*value" with its current value and returns
|
||||
true. Otherwise returns false.
|
||||
|
||||
|
||||
Valid property names include:
|
||||
|
||||
"rocksdb.num-files-at-level<N>" - return the number of files at level <N>,
|
||||
where <N> is an ASCII representation of a level number (e.g. "0").
|
||||
"rocksdb.stats" - returns a multi-line string that describes statistics
|
||||
about the internal operation of the DB.
|
||||
"rocksdb.sstables" - returns a multi-line string that describes all
|
||||
of the sstables that make up the db contents.
|
||||
*/
|
||||
public String getProperty(String property) throws RocksDBException {
|
||||
return getProperty0(nativeHandle_, property, property.length());
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a heap-allocated iterator over the contents of the database.
|
||||
@@ -398,8 +363,6 @@ public class RocksDB extends RocksObject {
|
||||
protected native void remove(
|
||||
long handle, long writeOptHandle,
|
||||
byte[] key, int keyLen) throws RocksDBException;
|
||||
protected native String getProperty0(long nativeHandle,
|
||||
String property, int propertyLength) throws RocksDBException;
|
||||
protected native long iterator0(long optHandle);
|
||||
private native void disposeInternal(long handle);
|
||||
|
||||
|
||||
@@ -255,7 +255,7 @@ public class DbBenchmark {
|
||||
for (long j = 0; j < entriesPerBatch_; j++) {
|
||||
getKey(key, i + j, keyRange_);
|
||||
DbBenchmark.this.gen_.generate(value);
|
||||
batch.put(key, value);
|
||||
db_.put(writeOpt_, key, value);
|
||||
stats_.finishedSingleOp(keySize_ + valueSize_);
|
||||
}
|
||||
db_.write(writeOpt_, batch);
|
||||
|
||||
@@ -52,6 +52,12 @@ public class OptionsTest {
|
||||
assert(opt.useFsync() == boolValue);
|
||||
}
|
||||
|
||||
{ // DbStatsLogInterval test
|
||||
int intValue = rand.nextInt();
|
||||
opt.setDbStatsLogInterval(intValue);
|
||||
assert(opt.dbStatsLogInterval() == intValue);
|
||||
}
|
||||
|
||||
{ // DbLogDir test
|
||||
String str = "path/to/DbLogDir";
|
||||
opt.setDbLogDir(str);
|
||||
@@ -184,6 +190,12 @@ public class OptionsTest {
|
||||
assert(opt.bytesPerSync() == longValue);
|
||||
}
|
||||
|
||||
{ // AllowThreadLocal test
|
||||
boolean boolValue = rand.nextBoolean();
|
||||
opt.setAllowThreadLocal(boolValue);
|
||||
assert(opt.allowThreadLocal() == boolValue);
|
||||
}
|
||||
|
||||
{ // WriteBufferSize test
|
||||
long longValue = rand.nextLong();
|
||||
opt.setWriteBufferSize(longValue);
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
//
|
||||
// This file implements the "bridge" between Java and C++ for MemTables.
|
||||
|
||||
#include "rocksjni/portal.h"
|
||||
#include "include/org_rocksdb_HashSkipListMemTableConfig.h"
|
||||
#include "include/org_rocksdb_HashLinkedListMemTableConfig.h"
|
||||
#include "include/org_rocksdb_VectorMemTableConfig.h"
|
||||
@@ -21,7 +20,7 @@ jlong Java_org_rocksdb_HashSkipListMemTableConfig_newMemTableFactoryHandle(
|
||||
JNIEnv* env, jobject jobj, jlong jbucket_count,
|
||||
jint jheight, jint jbranching_factor) {
|
||||
return reinterpret_cast<jlong>(rocksdb::NewHashSkipListRepFactory(
|
||||
rocksdb::jlong_to_size_t(jbucket_count),
|
||||
static_cast<size_t>(jbucket_count),
|
||||
static_cast<int32_t>(jheight),
|
||||
static_cast<int32_t>(jbranching_factor)));
|
||||
}
|
||||
@@ -34,7 +33,7 @@ jlong Java_org_rocksdb_HashSkipListMemTableConfig_newMemTableFactoryHandle(
|
||||
jlong Java_org_rocksdb_HashLinkedListMemTableConfig_newMemTableFactoryHandle(
|
||||
JNIEnv* env, jobject jobj, jlong jbucket_count) {
|
||||
return reinterpret_cast<jlong>(rocksdb::NewHashLinkListRepFactory(
|
||||
rocksdb::jlong_to_size_t(jbucket_count)));
|
||||
static_cast<size_t>(jbucket_count)));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -45,7 +44,7 @@ jlong Java_org_rocksdb_HashLinkedListMemTableConfig_newMemTableFactoryHandle(
|
||||
jlong Java_org_rocksdb_VectorMemTableConfig_newMemTableFactoryHandle(
|
||||
JNIEnv* env, jobject jobj, jlong jreserved_size) {
|
||||
return reinterpret_cast<jlong>(new rocksdb::VectorRepFactory(
|
||||
rocksdb::jlong_to_size_t(jreserved_size)));
|
||||
static_cast<size_t>(jreserved_size)));
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -21,8 +21,6 @@
|
||||
#include "rocksdb/memtablerep.h"
|
||||
#include "rocksdb/table.h"
|
||||
#include "rocksdb/slice_transform.h"
|
||||
#include "rocksdb/rate_limiter.h"
|
||||
#include "rocksdb/comparator.h"
|
||||
|
||||
/*
|
||||
* Class: org_rocksdb_Options
|
||||
@@ -64,23 +62,6 @@ jboolean Java_org_rocksdb_Options_createIfMissing(
|
||||
return reinterpret_cast<rocksdb::Options*>(jhandle)->create_if_missing;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_rocksdb_Options
|
||||
* Method: useReverseBytewiseComparator
|
||||
* Signature: (JI)V
|
||||
*/
|
||||
void Java_org_rocksdb_Options_setBuiltinComparator(
|
||||
JNIEnv* env, jobject jobj, jlong jhandle, jint builtinComparator) {
|
||||
switch (builtinComparator){
|
||||
case 1:
|
||||
reinterpret_cast<rocksdb::Options*>(jhandle)->comparator = rocksdb::ReverseBytewiseComparator();
|
||||
break;
|
||||
default:
|
||||
reinterpret_cast<rocksdb::Options*>(jhandle)->comparator = rocksdb::BytewiseComparator();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_rocksdb_Options
|
||||
* Method: setWriteBufferSize
|
||||
@@ -89,7 +70,7 @@ void Java_org_rocksdb_Options_setBuiltinComparator(
|
||||
void Java_org_rocksdb_Options_setWriteBufferSize(
|
||||
JNIEnv* env, jobject jobj, jlong jhandle, jlong jwrite_buffer_size) {
|
||||
reinterpret_cast<rocksdb::Options*>(jhandle)->write_buffer_size =
|
||||
rocksdb::jlong_to_size_t(jwrite_buffer_size);
|
||||
static_cast<size_t>(jwrite_buffer_size);
|
||||
}
|
||||
|
||||
|
||||
@@ -381,7 +362,7 @@ jlong Java_org_rocksdb_Options_maxLogFileSize(
|
||||
void Java_org_rocksdb_Options_setMaxLogFileSize(
|
||||
JNIEnv* env, jobject jobj, jlong jhandle, jlong max_log_file_size) {
|
||||
reinterpret_cast<rocksdb::Options*>(jhandle)->max_log_file_size =
|
||||
rocksdb::jlong_to_size_t(max_log_file_size);
|
||||
static_cast<size_t>(max_log_file_size);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -402,7 +383,7 @@ jlong Java_org_rocksdb_Options_logFileTimeToRoll(
|
||||
void Java_org_rocksdb_Options_setLogFileTimeToRoll(
|
||||
JNIEnv* env, jobject jobj, jlong jhandle, jlong log_file_time_to_roll) {
|
||||
reinterpret_cast<rocksdb::Options*>(jhandle)->log_file_time_to_roll =
|
||||
rocksdb::jlong_to_size_t(log_file_time_to_roll);
|
||||
static_cast<size_t>(log_file_time_to_roll);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -423,7 +404,7 @@ jlong Java_org_rocksdb_Options_keepLogFileNum(
|
||||
void Java_org_rocksdb_Options_setKeepLogFileNum(
|
||||
JNIEnv* env, jobject jobj, jlong jhandle, jlong keep_log_file_num) {
|
||||
reinterpret_cast<rocksdb::Options*>(jhandle)->keep_log_file_num =
|
||||
rocksdb::jlong_to_size_t(keep_log_file_num);
|
||||
static_cast<size_t>(keep_log_file_num);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -478,17 +459,6 @@ void Java_org_rocksdb_Options_setMemTableFactory(
|
||||
reinterpret_cast<rocksdb::MemTableRepFactory*>(jfactory_handle));
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_rocksdb_Options
|
||||
* Method: setRateLimiter
|
||||
* Signature: (JJ)V
|
||||
*/
|
||||
void Java_org_rocksdb_Options_setRateLimiter(
|
||||
JNIEnv* env, jobject jobj, jlong jhandle, jlong jrate_limiter_handle) {
|
||||
reinterpret_cast<rocksdb::Options*>(jhandle)->rate_limiter.reset(
|
||||
reinterpret_cast<rocksdb::RateLimiter*>(jrate_limiter_handle));
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_rocksdb_Options
|
||||
* Method: tableCacheNumshardbits
|
||||
@@ -539,8 +509,7 @@ void Java_org_rocksdb_Options_setTableCacheRemoveScanCountLimit(
|
||||
void Java_org_rocksdb_Options_useFixedLengthPrefixExtractor(
|
||||
JNIEnv* env, jobject jobj, jlong jhandle, jint jprefix_length) {
|
||||
reinterpret_cast<rocksdb::Options*>(jhandle)->prefix_extractor.reset(
|
||||
rocksdb::NewFixedPrefixTransform(
|
||||
rocksdb::jlong_to_size_t(jprefix_length)));
|
||||
rocksdb::NewFixedPrefixTransform(static_cast<size_t>(jprefix_length)));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -604,7 +573,7 @@ jlong Java_org_rocksdb_Options_manifestPreallocationSize(
|
||||
void Java_org_rocksdb_Options_setManifestPreallocationSize(
|
||||
JNIEnv* env, jobject jobj, jlong jhandle, jlong preallocation_size) {
|
||||
reinterpret_cast<rocksdb::Options*>(jhandle)->manifest_preallocation_size =
|
||||
rocksdb::jlong_to_size_t(preallocation_size);
|
||||
static_cast<size_t>(preallocation_size);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -807,6 +776,27 @@ void Java_org_rocksdb_Options_setBytesPerSync(
|
||||
static_cast<int64_t>(bytes_per_sync);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_rocksdb_Options
|
||||
* Method: allowThreadLocal
|
||||
* Signature: (J)Z
|
||||
*/
|
||||
jboolean Java_org_rocksdb_Options_allowThreadLocal(
|
||||
JNIEnv* env, jobject jobj, jlong jhandle) {
|
||||
return reinterpret_cast<rocksdb::Options*>(jhandle)->allow_thread_local;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_rocksdb_Options
|
||||
* Method: setAllowThreadLocal
|
||||
* Signature: (JZ)V
|
||||
*/
|
||||
void Java_org_rocksdb_Options_setAllowThreadLocal(
|
||||
JNIEnv* env, jobject jobj, jlong jhandle, jboolean allow_thread_local) {
|
||||
reinterpret_cast<rocksdb::Options*>(jhandle)->allow_thread_local =
|
||||
static_cast<bool>(allow_thread_local);
|
||||
}
|
||||
|
||||
/*
|
||||
* Method: tableFactoryName
|
||||
* Signature: (J)Ljava/lang/String
|
||||
@@ -1255,7 +1245,7 @@ jlong Java_org_rocksdb_Options_arenaBlockSize(
|
||||
void Java_org_rocksdb_Options_setArenaBlockSize(
|
||||
JNIEnv* env, jobject jobj, jlong jhandle, jlong jarena_block_size) {
|
||||
reinterpret_cast<rocksdb::Options*>(jhandle)->arena_block_size =
|
||||
rocksdb::jlong_to_size_t(jarena_block_size);
|
||||
static_cast<size_t>(jarena_block_size);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1420,7 +1410,7 @@ void Java_org_rocksdb_Options_setInplaceUpdateNumLocks(
|
||||
jlong jinplace_update_num_locks) {
|
||||
reinterpret_cast<rocksdb::Options*>(
|
||||
jhandle)->inplace_update_num_locks =
|
||||
rocksdb::jlong_to_size_t(jinplace_update_num_locks);
|
||||
static_cast<size_t>(jinplace_update_num_locks);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1511,7 +1501,7 @@ void Java_org_rocksdb_Options_setMaxSuccessiveMerges(
|
||||
JNIEnv* env, jobject jobj, jlong jhandle,
|
||||
jlong jmax_successive_merges) {
|
||||
reinterpret_cast<rocksdb::Options*>(jhandle)->max_successive_merges =
|
||||
rocksdb::jlong_to_size_t(jmax_successive_merges);
|
||||
static_cast<size_t>(jmax_successive_merges);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -11,19 +11,12 @@
|
||||
#define JAVA_ROCKSJNI_PORTAL_H_
|
||||
|
||||
#include <jni.h>
|
||||
#include <limits>
|
||||
#include "rocksdb/db.h"
|
||||
#include "rocksdb/filter_policy.h"
|
||||
#include "rocksdb/utilities/backupable_db.h"
|
||||
|
||||
namespace rocksdb {
|
||||
|
||||
inline size_t jlong_to_size_t(const jlong& jvalue) {
|
||||
return static_cast<uint64_t>(jvalue) <=
|
||||
static_cast<uint64_t>(std::numeric_limits<size_t>::max()) ?
|
||||
static_cast<size_t>(jvalue) : std::numeric_limits<size_t>::max();
|
||||
}
|
||||
|
||||
// The portal class for org.rocksdb.RocksDB
|
||||
class RocksDBJni {
|
||||
public:
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
// Copyright (c) 2014, Facebook, Inc. All rights reserved.
|
||||
// This source code is licensed under the BSD-style license found in the
|
||||
// LICENSE file in the root directory of this source tree. An additional grant
|
||||
// of patent rights can be found in the PATENTS file in the same directory.
|
||||
//
|
||||
// This file implements the "bridge" between Java and C++ for RateLimiter.
|
||||
|
||||
#include "rocksjni/portal.h"
|
||||
#include "include/org_rocksdb_GenericRateLimiterConfig.h"
|
||||
#include "rocksdb/rate_limiter.h"
|
||||
|
||||
/*
|
||||
* Class: org_rocksdb_GenericRateLimiterConfig
|
||||
* Method: newRateLimiterHandle
|
||||
* Signature: (JJI)J
|
||||
*/
|
||||
jlong Java_org_rocksdb_GenericRateLimiterConfig_newRateLimiterHandle(
|
||||
JNIEnv* env, jobject jobj, jlong jrate_bytes_per_second,
|
||||
jlong jrefill_period_micros, jint jfairness) {
|
||||
return reinterpret_cast<jlong>(rocksdb::NewGenericRateLimiter(
|
||||
rocksdb::jlong_to_size_t(jrate_bytes_per_second),
|
||||
rocksdb::jlong_to_size_t(jrefill_period_micros),
|
||||
static_cast<int32_t>(jfairness)));
|
||||
}
|
||||
@@ -425,27 +425,3 @@ jlong Java_org_rocksdb_RocksDB_iterator0(
|
||||
rocksdb::Iterator* iterator = db->NewIterator(rocksdb::ReadOptions());
|
||||
return reinterpret_cast<jlong>(iterator);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_rocksdb_RocksDB
|
||||
* Method: getProperty0
|
||||
* Signature: (JLjava/lang/String;I)Ljava/lang/String;
|
||||
*/
|
||||
jstring Java_org_rocksdb_RocksDB_getProperty0(
|
||||
JNIEnv* env, jobject jdb, jlong db_handle, jstring jproperty,
|
||||
jint jproperty_len) {
|
||||
auto db = reinterpret_cast<rocksdb::DB*>(db_handle);
|
||||
|
||||
const char* property = env->GetStringUTFChars(jproperty, 0);
|
||||
rocksdb::Slice property_slice(property, jproperty_len);
|
||||
|
||||
std::string property_value;
|
||||
bool retCode = db->GetProperty(property_slice, &property_value);
|
||||
env->ReleaseStringUTFChars(jproperty, property);
|
||||
|
||||
if (!retCode) {
|
||||
rocksdb::RocksDBExceptionJni::ThrowNew(env, rocksdb::Status::NotFound());
|
||||
}
|
||||
|
||||
return env->NewStringUTF(property_value.data());
|
||||
}
|
||||
|
||||
@@ -31,22 +31,20 @@ jlong Java_org_rocksdb_PlainTableConfig_newTableFactoryHandle(
|
||||
/*
|
||||
* Class: org_rocksdb_BlockBasedTableConfig
|
||||
* Method: newTableFactoryHandle
|
||||
* Signature: (ZJIJIIZIZZJI)J
|
||||
* Signature: (ZJIJIIZI)J
|
||||
*/
|
||||
jlong Java_org_rocksdb_BlockBasedTableConfig_newTableFactoryHandle(
|
||||
JNIEnv* env, jobject jobj, jboolean no_block_cache, jlong block_cache_size,
|
||||
jint block_cache_num_shardbits, jlong block_size, jint block_size_deviation,
|
||||
jint num_shardbits, jlong block_size, jint block_size_deviation,
|
||||
jint block_restart_interval, jboolean whole_key_filtering,
|
||||
jint bits_per_key, jboolean cache_index_and_filter_blocks,
|
||||
jboolean hash_index_allow_collision, jlong block_cache_compressed_size,
|
||||
jint block_cache_compressd_num_shard_bits) {
|
||||
jint bits_per_key) {
|
||||
rocksdb::BlockBasedTableOptions options;
|
||||
options.no_block_cache = no_block_cache;
|
||||
|
||||
if (!no_block_cache && block_cache_size > 0) {
|
||||
if (block_cache_num_shardbits > 0) {
|
||||
if (num_shardbits > 0) {
|
||||
options.block_cache =
|
||||
rocksdb::NewLRUCache(block_cache_size, block_cache_num_shardbits);
|
||||
rocksdb::NewLRUCache(block_cache_size, num_shardbits);
|
||||
} else {
|
||||
options.block_cache = rocksdb::NewLRUCache(block_cache_size);
|
||||
}
|
||||
@@ -58,17 +56,5 @@ jlong Java_org_rocksdb_BlockBasedTableConfig_newTableFactoryHandle(
|
||||
if (bits_per_key > 0) {
|
||||
options.filter_policy.reset(rocksdb::NewBloomFilterPolicy(bits_per_key));
|
||||
}
|
||||
options.cache_index_and_filter_blocks = cache_index_and_filter_blocks;
|
||||
options.hash_index_allow_collision = hash_index_allow_collision;
|
||||
if (block_cache_compressed_size > 0) {
|
||||
if (block_cache_compressd_num_shard_bits > 0) {
|
||||
options.block_cache =
|
||||
rocksdb::NewLRUCache(block_cache_compressed_size,
|
||||
block_cache_compressd_num_shard_bits);
|
||||
} else {
|
||||
options.block_cache = rocksdb::NewLRUCache(block_cache_compressed_size);
|
||||
}
|
||||
}
|
||||
|
||||
return reinterpret_cast<jlong>(rocksdb::NewBlockBasedTableFactory(options));
|
||||
}
|
||||
|
||||
@@ -12,14 +12,12 @@
|
||||
#include "include/org_rocksdb_WriteBatchTest.h"
|
||||
#include "rocksjni/portal.h"
|
||||
#include "rocksdb/db.h"
|
||||
#include "rocksdb/immutable_options.h"
|
||||
#include "db/memtable.h"
|
||||
#include "rocksdb/write_batch.h"
|
||||
#include "db/write_batch_internal.h"
|
||||
#include "rocksdb/env.h"
|
||||
#include "rocksdb/memtablerep.h"
|
||||
#include "util/logging.h"
|
||||
#include "util/scoped_arena_iterator.h"
|
||||
#include "util/testharness.h"
|
||||
|
||||
/*
|
||||
@@ -30,7 +28,7 @@
|
||||
void Java_org_rocksdb_WriteBatch_newWriteBatch(
|
||||
JNIEnv* env, jobject jobj, jint jreserved_bytes) {
|
||||
rocksdb::WriteBatch* wb = new rocksdb::WriteBatch(
|
||||
rocksdb::jlong_to_size_t(jreserved_bytes));
|
||||
static_cast<size_t>(jreserved_bytes));
|
||||
|
||||
rocksdb::WriteBatchJni::setHandle(env, jobj, wb);
|
||||
}
|
||||
@@ -204,19 +202,14 @@ jbyteArray Java_org_rocksdb_WriteBatchTest_getContents(
|
||||
auto factory = std::make_shared<rocksdb::SkipListFactory>();
|
||||
rocksdb::Options options;
|
||||
options.memtable_factory = factory;
|
||||
rocksdb::MemTable* mem = new rocksdb::MemTable(
|
||||
cmp, rocksdb::ImmutableCFOptions(options),
|
||||
rocksdb::MemTableOptions(rocksdb::MutableCFOptions(options,
|
||||
rocksdb::ImmutableCFOptions(options)), options));
|
||||
rocksdb::MemTable* mem = new rocksdb::MemTable(cmp, options);
|
||||
mem->Ref();
|
||||
std::string state;
|
||||
rocksdb::ColumnFamilyMemTablesDefault cf_mems_default(mem, &options);
|
||||
rocksdb::Status s =
|
||||
rocksdb::WriteBatchInternal::InsertInto(b, &cf_mems_default);
|
||||
int count = 0;
|
||||
rocksdb::Arena arena;
|
||||
rocksdb::ScopedArenaIterator iter(mem->NewIterator(
|
||||
rocksdb::ReadOptions(), &arena));
|
||||
rocksdb::Iterator* iter = mem->NewIterator(rocksdb::ReadOptions());
|
||||
for (iter->SeekToFirst(); iter->Valid(); iter->Next()) {
|
||||
rocksdb::ParsedInternalKey ikey;
|
||||
memset(reinterpret_cast<void*>(&ikey), 0, sizeof(ikey));
|
||||
@@ -251,6 +244,7 @@ jbyteArray Java_org_rocksdb_WriteBatchTest_getContents(
|
||||
state.append("@");
|
||||
state.append(rocksdb::NumberToString(ikey.sequence));
|
||||
}
|
||||
delete iter;
|
||||
if (!s.ok()) {
|
||||
state.append(s.ToString());
|
||||
} else if (count != rocksdb::WriteBatchInternal::Count(b)) {
|
||||
|
||||
Reference in New Issue
Block a user