Skip to content

Instantly share code, notes, and snippets.

@sap1ens
Created October 12, 2021 22:00
Show Gist options
  • Save sap1ens/77c27924e00dbcf05781fdbfde8fd6fb to your computer and use it in GitHub Desktop.
Save sap1ens/77c27924e00dbcf05781fdbfde8fd6fb to your computer and use it in GitHub Desktop.
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