Search in sources :

Example 1 with PlainTableConfig

use of org.rocksdb.PlainTableConfig in project flink by apache.

the class DefaultConfigurableOptionsFactory method createColumnOptions.

@Override
public ColumnFamilyOptions createColumnOptions(ColumnFamilyOptions currentOptions, Collection<AutoCloseable> handlesToClose) {
    if (isOptionConfigured(COMPACTION_STYLE)) {
        currentOptions.setCompactionStyle(getCompactionStyle());
    }
    if (isOptionConfigured(USE_DYNAMIC_LEVEL_SIZE)) {
        currentOptions.setLevelCompactionDynamicLevelBytes(getUseDynamicLevelSize());
    }
    if (isOptionConfigured(TARGET_FILE_SIZE_BASE)) {
        currentOptions.setTargetFileSizeBase(getTargetFileSizeBase());
    }
    if (isOptionConfigured(MAX_SIZE_LEVEL_BASE)) {
        currentOptions.setMaxBytesForLevelBase(getMaxSizeLevelBase());
    }
    if (isOptionConfigured(WRITE_BUFFER_SIZE)) {
        currentOptions.setWriteBufferSize(getWriteBufferSize());
    }
    if (isOptionConfigured(MAX_WRITE_BUFFER_NUMBER)) {
        currentOptions.setMaxWriteBufferNumber(getMaxWriteBufferNumber());
    }
    if (isOptionConfigured(MIN_WRITE_BUFFER_NUMBER_TO_MERGE)) {
        currentOptions.setMinWriteBufferNumberToMerge(getMinWriteBufferNumberToMerge());
    }
    TableFormatConfig tableFormatConfig = currentOptions.tableFormatConfig();
    BlockBasedTableConfig blockBasedTableConfig;
    if (tableFormatConfig == null) {
        blockBasedTableConfig = new BlockBasedTableConfig();
    } else {
        if (tableFormatConfig instanceof PlainTableConfig) {
            // column-family options
            return currentOptions;
        } else {
            blockBasedTableConfig = (BlockBasedTableConfig) tableFormatConfig;
        }
    }
    if (isOptionConfigured(BLOCK_SIZE)) {
        blockBasedTableConfig.setBlockSize(getBlockSize());
    }
    if (isOptionConfigured(METADATA_BLOCK_SIZE)) {
        blockBasedTableConfig.setMetadataBlockSize(getMetadataBlockSize());
    }
    if (isOptionConfigured(BLOCK_CACHE_SIZE)) {
        blockBasedTableConfig.setBlockCacheSize(getBlockCacheSize());
    }
    if (isOptionConfigured(USE_BLOOM_FILTER)) {
        final boolean enabled = Boolean.parseBoolean(getInternal(USE_BLOOM_FILTER.key()));
        if (enabled) {
            final double bitsPerKey = isOptionConfigured(BLOOM_FILTER_BITS_PER_KEY) ? Double.parseDouble(getInternal(BLOOM_FILTER_BITS_PER_KEY.key())) : BLOOM_FILTER_BITS_PER_KEY.defaultValue();
            final boolean blockBasedMode = isOptionConfigured(BLOOM_FILTER_BLOCK_BASED_MODE) ? Boolean.parseBoolean(getInternal(BLOOM_FILTER_BLOCK_BASED_MODE.key())) : BLOOM_FILTER_BLOCK_BASED_MODE.defaultValue();
            BloomFilter bloomFilter = new BloomFilter(bitsPerKey, blockBasedMode);
            handlesToClose.add(bloomFilter);
            blockBasedTableConfig.setFilterPolicy(bloomFilter);
        }
    }
    return currentOptions.setTableFormatConfig(blockBasedTableConfig);
}
Also used : TableFormatConfig(org.rocksdb.TableFormatConfig) BlockBasedTableConfig(org.rocksdb.BlockBasedTableConfig) PlainTableConfig(org.rocksdb.PlainTableConfig) BloomFilter(org.rocksdb.BloomFilter)

Example 2 with PlainTableConfig

use of org.rocksdb.PlainTableConfig in project flink by apache.

the class RocksDBResourceContainer method setColumnFamilyOptionsFromConfigurableOptions.

@SuppressWarnings("ConstantConditions")
private ColumnFamilyOptions setColumnFamilyOptionsFromConfigurableOptions(ColumnFamilyOptions currentOptions, Collection<AutoCloseable> handlesToClose) {
    currentOptions.setCompactionStyle(internalGetOption(RocksDBConfigurableOptions.COMPACTION_STYLE));
    currentOptions.setLevelCompactionDynamicLevelBytes(internalGetOption(RocksDBConfigurableOptions.USE_DYNAMIC_LEVEL_SIZE));
    currentOptions.setTargetFileSizeBase(internalGetOption(RocksDBConfigurableOptions.TARGET_FILE_SIZE_BASE).getBytes());
    currentOptions.setMaxBytesForLevelBase(internalGetOption(RocksDBConfigurableOptions.MAX_SIZE_LEVEL_BASE).getBytes());
    currentOptions.setWriteBufferSize(internalGetOption(RocksDBConfigurableOptions.WRITE_BUFFER_SIZE).getBytes());
    currentOptions.setMaxWriteBufferNumber(internalGetOption(RocksDBConfigurableOptions.MAX_WRITE_BUFFER_NUMBER));
    currentOptions.setMinWriteBufferNumberToMerge(internalGetOption(RocksDBConfigurableOptions.MIN_WRITE_BUFFER_NUMBER_TO_MERGE));
    TableFormatConfig tableFormatConfig = currentOptions.tableFormatConfig();
    BlockBasedTableConfig blockBasedTableConfig;
    if (tableFormatConfig == null) {
        blockBasedTableConfig = new BlockBasedTableConfig();
    } else {
        if (tableFormatConfig instanceof PlainTableConfig) {
            // column-family options
            return currentOptions;
        } else {
            blockBasedTableConfig = (BlockBasedTableConfig) tableFormatConfig;
        }
    }
    blockBasedTableConfig.setBlockSize(internalGetOption(RocksDBConfigurableOptions.BLOCK_SIZE).getBytes());
    blockBasedTableConfig.setMetadataBlockSize(internalGetOption(RocksDBConfigurableOptions.METADATA_BLOCK_SIZE).getBytes());
    blockBasedTableConfig.setBlockCacheSize(internalGetOption(RocksDBConfigurableOptions.BLOCK_CACHE_SIZE).getBytes());
    if (internalGetOption(RocksDBConfigurableOptions.USE_BLOOM_FILTER)) {
        final double bitsPerKey = internalGetOption(RocksDBConfigurableOptions.BLOOM_FILTER_BITS_PER_KEY);
        final boolean blockBasedMode = internalGetOption(RocksDBConfigurableOptions.BLOOM_FILTER_BLOCK_BASED_MODE);
        BloomFilter bloomFilter = new BloomFilter(bitsPerKey, blockBasedMode);
        handlesToClose.add(bloomFilter);
        blockBasedTableConfig.setFilterPolicy(bloomFilter);
    }
    return currentOptions.setTableFormatConfig(blockBasedTableConfig);
}
Also used : TableFormatConfig(org.rocksdb.TableFormatConfig) BlockBasedTableConfig(org.rocksdb.BlockBasedTableConfig) PlainTableConfig(org.rocksdb.PlainTableConfig) BloomFilter(org.rocksdb.BloomFilter)

Aggregations

BlockBasedTableConfig (org.rocksdb.BlockBasedTableConfig)2 BloomFilter (org.rocksdb.BloomFilter)2 PlainTableConfig (org.rocksdb.PlainTableConfig)2 TableFormatConfig (org.rocksdb.TableFormatConfig)2