Created
March 3, 2022 22:03
-
-
Save sap1ens/7d232ad6a9296b48079717077b90c783 to your computer and use it in GitHub Desktop.
This file contains 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