|
|
@ -15,7 +15,7 @@ public class BlockBasedTableConfig extends TableFormatConfig { |
|
|
|
public BlockBasedTableConfig() { |
|
|
|
public BlockBasedTableConfig() { |
|
|
|
//TODO(AR) flushBlockPolicyFactory
|
|
|
|
//TODO(AR) flushBlockPolicyFactory
|
|
|
|
cacheIndexAndFilterBlocks = false; |
|
|
|
cacheIndexAndFilterBlocks = false; |
|
|
|
cacheIndexAndFilterBlocksWithHighPriority = false; |
|
|
|
cacheIndexAndFilterBlocksWithHighPriority = true; |
|
|
|
pinL0FilterAndIndexBlocksInCache = false; |
|
|
|
pinL0FilterAndIndexBlocksInCache = false; |
|
|
|
pinTopLevelIndexAndFilter = true; |
|
|
|
pinTopLevelIndexAndFilter = true; |
|
|
|
indexType = IndexType.kBinarySearch; |
|
|
|
indexType = IndexType.kBinarySearch; |
|
|
@ -32,14 +32,16 @@ public class BlockBasedTableConfig extends TableFormatConfig { |
|
|
|
indexBlockRestartInterval = 1; |
|
|
|
indexBlockRestartInterval = 1; |
|
|
|
metadataBlockSize = 4096; |
|
|
|
metadataBlockSize = 4096; |
|
|
|
partitionFilters = false; |
|
|
|
partitionFilters = false; |
|
|
|
|
|
|
|
optimizeFiltersForMemory = false; |
|
|
|
useDeltaEncoding = true; |
|
|
|
useDeltaEncoding = true; |
|
|
|
filterPolicy = null; |
|
|
|
filterPolicy = null; |
|
|
|
wholeKeyFiltering = true; |
|
|
|
wholeKeyFiltering = true; |
|
|
|
verifyCompression = true; |
|
|
|
verifyCompression = false; |
|
|
|
readAmpBytesPerBit = 0; |
|
|
|
readAmpBytesPerBit = 0; |
|
|
|
formatVersion = 2; |
|
|
|
formatVersion = 4; |
|
|
|
enableIndexCompression = true; |
|
|
|
enableIndexCompression = true; |
|
|
|
blockAlign = false; |
|
|
|
blockAlign = false; |
|
|
|
|
|
|
|
indexShortening = IndexShorteningMode.kShortenSeparators; |
|
|
|
|
|
|
|
|
|
|
|
// NOTE: ONLY used if blockCache == null
|
|
|
|
// NOTE: ONLY used if blockCache == null
|
|
|
|
blockCacheSize = 8 * 1024 * 1024; |
|
|
|
blockCacheSize = 8 * 1024 * 1024; |
|
|
@ -77,7 +79,7 @@ public class BlockBasedTableConfig extends TableFormatConfig { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Indicates if index and filter blocks will be treated as high-priority in the block cache. |
|
|
|
* Indicates if index and filter blocks will be treated as high-priority in the block cache. |
|
|
|
* See note below about applicability. If not specified, defaults to false. |
|
|
|
* See note below about applicability. If not specified, defaults to true. |
|
|
|
* |
|
|
|
* |
|
|
|
* @return if index and filter blocks will be treated as high-priority. |
|
|
|
* @return if index and filter blocks will be treated as high-priority. |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -453,6 +455,65 @@ public class BlockBasedTableConfig extends TableFormatConfig { |
|
|
|
return this; |
|
|
|
return this; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*** |
|
|
|
|
|
|
|
* Option to generate Bloom filters that minimize memory |
|
|
|
|
|
|
|
* internal fragmentation. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* See {@link #setOptimizeFiltersForMemory(boolean)}. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @return true if bloom filters are used to minimize memory internal |
|
|
|
|
|
|
|
* fragmentation |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Experimental("Option to generate Bloom filters that minimize memory internal fragmentation") |
|
|
|
|
|
|
|
public boolean optimizeFiltersForMemory() { |
|
|
|
|
|
|
|
return optimizeFiltersForMemory; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Option to generate Bloom filters that minimize memory |
|
|
|
|
|
|
|
* internal fragmentation. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* When false, malloc_usable_size is not available, or format_version < 5, |
|
|
|
|
|
|
|
* filters are generated without regard to internal fragmentation when |
|
|
|
|
|
|
|
* loaded into memory (historical behavior). When true (and |
|
|
|
|
|
|
|
* malloc_usable_size is available and {@link #formatVersion()} >= 5), |
|
|
|
|
|
|
|
* then Bloom filters are generated to "round up" and "round down" their |
|
|
|
|
|
|
|
* sizes to minimize internal fragmentation when loaded into memory, assuming |
|
|
|
|
|
|
|
* the reading DB has the same memory allocation characteristics as the |
|
|
|
|
|
|
|
* generating DB. This option does not break forward or backward |
|
|
|
|
|
|
|
* compatibility. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* While individual filters will vary in bits/key and false positive rate |
|
|
|
|
|
|
|
* when setting is true, the implementation attempts to maintain a weighted |
|
|
|
|
|
|
|
* average FP rate for filters consistent with this option set to false. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* With Jemalloc for example, this setting is expected to save about 10% of |
|
|
|
|
|
|
|
* the memory footprint and block cache charge of filters, while increasing |
|
|
|
|
|
|
|
* disk usage of filters by about 1-2% due to encoding efficiency losses |
|
|
|
|
|
|
|
* with variance in bits/key. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* NOTE: Because some memory counted by block cache might be unmapped pages |
|
|
|
|
|
|
|
* within internal fragmentation, this option can increase observed RSS |
|
|
|
|
|
|
|
* memory usage. With {@link #cacheIndexAndFilterBlocks()} == true, |
|
|
|
|
|
|
|
* this option makes the block cache better at using space it is allowed. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* NOTE: Do not set to true if you do not trust malloc_usable_size. With |
|
|
|
|
|
|
|
* this option, RocksDB might access an allocated memory object beyond its |
|
|
|
|
|
|
|
* original size if malloc_usable_size says it is safe to do so. While this |
|
|
|
|
|
|
|
* can be considered bad practice, it should not produce undefined behavior |
|
|
|
|
|
|
|
* unless malloc_usable_size is buggy or broken. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param optimizeFiltersForMemory true to enable Bloom filters that minimize |
|
|
|
|
|
|
|
* memory internal fragmentation, or false to disable. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @return the reference to the current config. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Experimental("Option to generate Bloom filters that minimize memory internal fragmentation") |
|
|
|
|
|
|
|
public BlockBasedTableConfig setOptimizeFiltersForMemory(final boolean optimizeFiltersForMemory) { |
|
|
|
|
|
|
|
this.optimizeFiltersForMemory = optimizeFiltersForMemory; |
|
|
|
|
|
|
|
return this; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Determine if delta encoding is being used to compress block keys. |
|
|
|
* Determine if delta encoding is being used to compress block keys. |
|
|
|
* |
|
|
|
* |
|
|
@ -717,6 +778,28 @@ public class BlockBasedTableConfig extends TableFormatConfig { |
|
|
|
return this; |
|
|
|
return this; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Get the index shortening mode. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @return the index shortening mode. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public IndexShorteningMode indexShortening() { |
|
|
|
|
|
|
|
return indexShortening; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Set the index shortening mode. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* See {@link IndexShorteningMode}. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param indexShortening the index shortening mode. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @return the reference to the current option. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public BlockBasedTableConfig setIndexShortening(final IndexShorteningMode indexShortening) { |
|
|
|
|
|
|
|
this.indexShortening = indexShortening; |
|
|
|
|
|
|
|
return this; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Get the size of the cache in bytes that will be used by RocksDB. |
|
|
|
* Get the size of the cache in bytes that will be used by RocksDB. |
|
|
@ -900,54 +983,35 @@ public class BlockBasedTableConfig extends TableFormatConfig { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return newTableFactoryHandle(cacheIndexAndFilterBlocks, |
|
|
|
return newTableFactoryHandle(cacheIndexAndFilterBlocks, |
|
|
|
cacheIndexAndFilterBlocksWithHighPriority, |
|
|
|
cacheIndexAndFilterBlocksWithHighPriority, pinL0FilterAndIndexBlocksInCache, |
|
|
|
pinL0FilterAndIndexBlocksInCache, pinTopLevelIndexAndFilter, |
|
|
|
pinTopLevelIndexAndFilter, indexType.getValue(), dataBlockIndexType.getValue(), |
|
|
|
indexType.getValue(), dataBlockIndexType.getValue(), |
|
|
|
dataBlockHashTableUtilRatio, checksumType.getValue(), noBlockCache, blockCacheHandle, |
|
|
|
dataBlockHashTableUtilRatio, checksumType.getValue(), noBlockCache, |
|
|
|
persistentCacheHandle, blockCacheCompressedHandle, blockSize, blockSizeDeviation, |
|
|
|
blockCacheHandle, persistentCacheHandle, blockCacheCompressedHandle, |
|
|
|
blockRestartInterval, indexBlockRestartInterval, metadataBlockSize, partitionFilters, |
|
|
|
blockSize, blockSizeDeviation, blockRestartInterval, |
|
|
|
optimizeFiltersForMemory, useDeltaEncoding, filterPolicyHandle, wholeKeyFiltering, |
|
|
|
indexBlockRestartInterval, metadataBlockSize, partitionFilters, |
|
|
|
verifyCompression, readAmpBytesPerBit, formatVersion, enableIndexCompression, blockAlign, |
|
|
|
useDeltaEncoding, filterPolicyHandle, wholeKeyFiltering, |
|
|
|
indexShortening.getValue(), blockCacheSize, blockCacheNumShardBits, |
|
|
|
verifyCompression, readAmpBytesPerBit, formatVersion, |
|
|
|
|
|
|
|
enableIndexCompression, blockAlign, |
|
|
|
|
|
|
|
blockCacheSize, blockCacheNumShardBits, |
|
|
|
|
|
|
|
blockCacheCompressedSize, blockCacheCompressedNumShardBits); |
|
|
|
blockCacheCompressedSize, blockCacheCompressedNumShardBits); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private native long newTableFactoryHandle( |
|
|
|
private native long newTableFactoryHandle(final boolean cacheIndexAndFilterBlocks, |
|
|
|
final boolean cacheIndexAndFilterBlocks, |
|
|
|
|
|
|
|
final boolean cacheIndexAndFilterBlocksWithHighPriority, |
|
|
|
final boolean cacheIndexAndFilterBlocksWithHighPriority, |
|
|
|
final boolean pinL0FilterAndIndexBlocksInCache, |
|
|
|
final boolean pinL0FilterAndIndexBlocksInCache, final boolean pinTopLevelIndexAndFilter, |
|
|
|
final boolean pinTopLevelIndexAndFilter, |
|
|
|
final byte indexTypeValue, final byte dataBlockIndexTypeValue, |
|
|
|
final byte indexTypeValue, |
|
|
|
final double dataBlockHashTableUtilRatio, final byte checksumTypeValue, |
|
|
|
final byte dataBlockIndexTypeValue, |
|
|
|
final boolean noBlockCache, final long blockCacheHandle, final long persistentCacheHandle, |
|
|
|
final double dataBlockHashTableUtilRatio, |
|
|
|
final long blockCacheCompressedHandle, final long blockSize, final int blockSizeDeviation, |
|
|
|
final byte checksumTypeValue, |
|
|
|
final int blockRestartInterval, final int indexBlockRestartInterval, |
|
|
|
final boolean noBlockCache, |
|
|
|
final long metadataBlockSize, final boolean partitionFilters, |
|
|
|
final long blockCacheHandle, |
|
|
|
final boolean optimizeFiltersForMemory, final boolean useDeltaEncoding, |
|
|
|
final long persistentCacheHandle, |
|
|
|
final long filterPolicyHandle, final boolean wholeKeyFiltering, |
|
|
|
final long blockCacheCompressedHandle, |
|
|
|
final boolean verifyCompression, final int readAmpBytesPerBit, final int formatVersion, |
|
|
|
final long blockSize, |
|
|
|
final boolean enableIndexCompression, final boolean blockAlign, final byte indexShortening, |
|
|
|
final int blockSizeDeviation, |
|
|
|
|
|
|
|
final int blockRestartInterval, |
|
|
|
@Deprecated final long blockCacheSize, @Deprecated final int blockCacheNumShardBits, |
|
|
|
final int indexBlockRestartInterval, |
|
|
|
|
|
|
|
final long metadataBlockSize, |
|
|
|
|
|
|
|
final boolean partitionFilters, |
|
|
|
|
|
|
|
final boolean useDeltaEncoding, |
|
|
|
|
|
|
|
final long filterPolicyHandle, |
|
|
|
|
|
|
|
final boolean wholeKeyFiltering, |
|
|
|
|
|
|
|
final boolean verifyCompression, |
|
|
|
|
|
|
|
final int readAmpBytesPerBit, |
|
|
|
|
|
|
|
final int formatVersion, |
|
|
|
|
|
|
|
final boolean enableIndexCompression, |
|
|
|
|
|
|
|
final boolean blockAlign, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Deprecated final long blockCacheSize, |
|
|
|
|
|
|
|
@Deprecated final int blockCacheNumShardBits, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Deprecated final long blockCacheCompressedSize, |
|
|
|
@Deprecated final long blockCacheCompressedSize, |
|
|
|
@Deprecated final int blockCacheCompressedNumShardBits |
|
|
|
@Deprecated final int blockCacheCompressedNumShardBits); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//TODO(AR) flushBlockPolicyFactory
|
|
|
|
//TODO(AR) flushBlockPolicyFactory
|
|
|
|
private boolean cacheIndexAndFilterBlocks; |
|
|
|
private boolean cacheIndexAndFilterBlocks; |
|
|
@ -968,6 +1032,7 @@ public class BlockBasedTableConfig extends TableFormatConfig { |
|
|
|
private int indexBlockRestartInterval; |
|
|
|
private int indexBlockRestartInterval; |
|
|
|
private long metadataBlockSize; |
|
|
|
private long metadataBlockSize; |
|
|
|
private boolean partitionFilters; |
|
|
|
private boolean partitionFilters; |
|
|
|
|
|
|
|
private boolean optimizeFiltersForMemory; |
|
|
|
private boolean useDeltaEncoding; |
|
|
|
private boolean useDeltaEncoding; |
|
|
|
private Filter filterPolicy; |
|
|
|
private Filter filterPolicy; |
|
|
|
private boolean wholeKeyFiltering; |
|
|
|
private boolean wholeKeyFiltering; |
|
|
@ -976,6 +1041,7 @@ public class BlockBasedTableConfig extends TableFormatConfig { |
|
|
|
private int formatVersion; |
|
|
|
private int formatVersion; |
|
|
|
private boolean enableIndexCompression; |
|
|
|
private boolean enableIndexCompression; |
|
|
|
private boolean blockAlign; |
|
|
|
private boolean blockAlign; |
|
|
|
|
|
|
|
private IndexShorteningMode indexShortening; |
|
|
|
|
|
|
|
|
|
|
|
// NOTE: ONLY used if blockCache == null
|
|
|
|
// NOTE: ONLY used if blockCache == null
|
|
|
|
@Deprecated private long blockCacheSize; |
|
|
|
@Deprecated private long blockCacheSize; |
|
|
|