@ -15,6 +15,7 @@ public class BlockBasedTableConfig extends TableFormatConfig {
noBlockCache_ = false ;
blockCacheSize_ = 8 * 1024 * 1024 ;
blockCacheNumShardBits_ = 0 ;
blockCache_ = null ;
blockSize_ = 4 * 1024 ;
blockSizeDeviation_ = 10 ;
blockRestartInterval_ = 16 ;
@ -71,6 +72,24 @@ public class BlockBasedTableConfig extends TableFormatConfig {
return blockCacheSize_ ;
}
/ * *
* Use the specified cache for blocks .
* When not null this take precedence even if the user sets a block cache size .
*
* { @link org . rocksdb . Cache } should not be disposed before options instances
* using this cache is disposed .
*
* { @link org . rocksdb . Cache } instance can be re - used in multiple options
* instances .
*
* @param cache { @link org . rocksdb . Cache } Cache java instance ( e . g . LRUCache ) .
* @return the reference to the current config .
* /
public BlockBasedTableConfig setBlockCache ( final Cache cache ) {
blockCache_ = cache ;
return this ;
}
/ * *
* Controls the number of shards for the block cache .
* This is applied only if cacheSize is set to non - negative .
@ -413,25 +432,25 @@ public class BlockBasedTableConfig extends TableFormatConfig {
filterHandle = filter_ . nativeHandle_ ;
}
return newTableFactoryHandle ( noBlockCache_ , blockCacheSize_ ,
blockCacheNumShardBits_ , blockSize_ , blockSizeDeviation_ ,
blockRestartInterval_ , wholeKeyFiltering_ ,
filterHandle , cacheIndexAndFilterBlocks_ ,
pinL0FilterAndIndexBlocksInCache_ ,
hashIndexAllowCollision_ , blockCacheCompressedSize_ ,
blockCacheCompressedNumShardBits_ ,
checksumType_ . getValue ( ) , indexType_ . getValue ( ) ,
long blockCacheHandle = 0 ;
if ( blockCache_ ! = null ) {
blockCacheHandle = blockCache_ . nativeHandle_ ;
}
return newTableFactoryHandle ( noBlockCache_ , blockCacheSize_ , blockCacheNumShardBits_ ,
blockCacheHandle , blockSize_ , blockSizeDeviation_ , blockRestartInterval_ ,
wholeKeyFiltering_ , filterHandle , cacheIndexAndFilterBlocks_ ,
pinL0FilterAndIndexBlocksInCache_ , hashIndexAllowCollision_ , blockCacheCompressedSize_ ,
blockCacheCompressedNumShardBits_ , checksumType_ . getValue ( ) , indexType_ . getValue ( ) ,
formatVersion_ ) ;
}
private native long newTableFactoryHandle (
boolean noBlockCache , long blockCacheSize , int blockCacheNumShardBits ,
long blockSize , int blockSizeDeviation , int blockRestartInterval ,
boolean wholeKeyFiltering , long filterPolicyHandle ,
private native long newTableFactoryHandle ( boolean noBlockCache , long blockCacheSize ,
int blockCacheNumShardBits , long blockCacheHandle , long blockSize , int blockSizeDeviation ,
int blockRestartInterval , boolean wholeKeyFiltering , long filterPolicyHandle ,
boolean cacheIndexAndFilterBlocks , boolean pinL0FilterAndIndexBlocksInCache ,
boolean hashIndexAllowCollision , long blockCacheCompressedSize ,
int blockCacheCompressedNumShardBits , byte checkSumType ,
byte indexType , int formatVersion ) ;
int blockCacheCompressedNumShardBits , byte checkSumType , byte indexType , int formatVersion ) ;
private boolean cacheIndexAndFilterBlocks_ ;
private boolean pinL0FilterAndIndexBlocksInCache_ ;
@ -442,6 +461,7 @@ public class BlockBasedTableConfig extends TableFormatConfig {
private long blockSize_ ;
private long blockCacheSize_ ;
private int blockCacheNumShardBits_ ;
private Cache blockCache_ ;
private long blockCacheCompressedSize_ ;
private int blockCacheCompressedNumShardBits_ ;
private int blockSizeDeviation_ ;