diff --git a/java/rocksjni/table.cc b/java/rocksjni/table.cc index 1ccc550ab..a4504d917 100644 --- a/java/rocksjni/table.cc +++ b/java/rocksjni/table.cc @@ -85,7 +85,7 @@ jlong Java_org_rocksdb_BlockBasedTableConfig_newTableFactoryHandle( std::shared_ptr *pCache = reinterpret_cast *>(jblock_cache_handle); options.block_cache = *pCache; - } else if (jblock_cache_size > 0) { + } else if (jblock_cache_size >= 0) { if (jblock_cache_num_shard_bits > 0) { options.block_cache = rocksdb::NewLRUCache( static_cast(jblock_cache_size), @@ -94,6 +94,9 @@ jlong Java_org_rocksdb_BlockBasedTableConfig_newTableFactoryHandle( options.block_cache = rocksdb::NewLRUCache( static_cast(jblock_cache_size)); } + } else { + options.no_block_cache = true; + options.block_cache = nullptr; } } if (jpersistent_cache_handle > 0) { diff --git a/java/src/main/java/org/rocksdb/BlockBasedTableConfig.java b/java/src/main/java/org/rocksdb/BlockBasedTableConfig.java index 4c88a0224..bf5c0c1a9 100644 --- a/java/src/main/java/org/rocksdb/BlockBasedTableConfig.java +++ b/java/src/main/java/org/rocksdb/BlockBasedTableConfig.java @@ -725,7 +725,7 @@ public class BlockBasedTableConfig extends TableFormatConfig { /** * Set the size of the cache in bytes that will be used by RocksDB. - * If cacheSize is non-positive, then cache will not be used. + * If cacheSize is negative, then cache will not be used. * DEFAULT: 8M * * @param blockCacheSize block cache size in bytes