Created
October 12, 2021 22:00
-
-
Save sap1ens/77c27924e00dbcf05781fdbfde8fd6fb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.apache.flink.contrib.streaming.state.{ConfigurableRocksDBOptionsFactory, RocksDBOptionsFactory} | |
import org.rocksdb.DBOptions | |
import org.rocksdb.ColumnFamilyOptions | |
import org.rocksdb.BlockBasedTableConfig | |
import org.apache.flink.configuration.ReadableConfig | |
import java.util | |
class NoBlockCacheRocksDbOptionsFactory extends ConfigurableRocksDBOptionsFactory { | |
override def createDBOptions(currentOptions: DBOptions, handlesToClose: util.Collection[AutoCloseable]): DBOptions = { | |
currentOptions | |
} | |
override def createColumnOptions( | |
currentOptions: ColumnFamilyOptions, | |
handlesToClose: util.Collection[AutoCloseable] | |
): ColumnFamilyOptions = { | |
val blockBasedTableConfig = new BlockBasedTableConfig() | |
blockBasedTableConfig.setNoBlockCache(true) | |
// Needed in order to disable block cache | |
blockBasedTableConfig.setCacheIndexAndFilterBlocks(false) | |
blockBasedTableConfig.setCacheIndexAndFilterBlocksWithHighPriority(false) | |
blockBasedTableConfig.setPinL0FilterAndIndexBlocksInCache(false) | |
currentOptions.setTableFormatConfig(blockBasedTableConfig) | |
currentOptions | |
} | |
override def configure(configuration: ReadableConfig): RocksDBOptionsFactory = { | |
this | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment