Interface DBOptionsInterface<T extends DBOptionsInterface<T>>
-
Method Summary
Modifier and TypeMethodDescriptionbooleanIf set true, will hint the underlying file system that the file access pattern is random, when a sst file is opened.booleanallow2pc()if set to false then recovery will fail when a prepared transaction is encountered in the WAL Default: falsebooleanIf true, allow multi-writers to update mem tables in parallel.booleanWhether fallocate calls are allowedbooleanReturns true if ingest behind is allowed.booleanAllow the OS to mmap file for reading sst tables.booleanAllow the OS to mmap file for writing.booleanDetermine if atomic flush of multiple column families is enabled.booleanBy default RocksDB replay WAL logs and flush them on DB open, which may create very small SST files.booleanIf true, working thread may avoid doing unnecessary and long-latency operation (such as deleting obsolete files directly or deleting memtable) and will instead schedule a background job to do it.booleanBy default, RocksDB recovery fails if any table file referenced in MANIFEST are missing after scanning the MANIFEST.longIf max_bgerror_resume_count is ≥ 2, db resume is called multiple times.booleanReturn true if the create_if_missing flag is set to true.booleanReturn true if the create_missing_column_families flag is set to true.dbLogDir()Returns the directory of info log.dbPaths()A list of paths where SST files can be put into, with its target size.longAmount of data to build up in memtables across all column families before writing to disk.longThe periodicity when obsolete files get deleted.booleanIf true, then print malloc stats together with rocksdb.stats when printing to LOG.booleanReturns true if pipelined writes are enabled.booleanIf true, then the status of the threads involved in this DB will be tracked and available via GetThreadList() API.booleanIf true, threads synchronizing with the write batch group leader will wait for up towriteThreadMaxYieldUsec()before blocking on a mutex.booleanIf true, an error will be thrown during RocksDB.open() if the database already exists.booleanIf true, then DB::Open / CreateColumnFamily / DropColumnFamily / SetOptions will fail if options file is not detected or properly persisted.getEnv()Returns the set RocksEnv instance.Returns currently set log level.booleanDisable child process inherit open files.longReturns the maximum number of info log files to be kept.Sets theEventListeners whose callback functions will be called when specific RocksDB event happens.longReturns the time interval for the info log file to roll (in seconds).longThe number of bytes to prefetch when reading the log.longNumber of bytes to preallocate (via fallocate) the manifest files.booleanReturns true if automatic WAL flushing is disabled.intDeprecated.intIt defines how many times db resume is called by a separate thread when background retryable IO Error happens.intIfMutableDBOptionsInterface.maxOpenFiles()is -1, DB will open all files on DB::Open().longReturns the maximum size of a info log file.longManifest file is rolled over on reaching this limit.intThis value represents the maximum number of threads that will concurrently perform a compaction job by breaking it into multiple, smaller ones that are run simultaneously.longThe maximum limit of number of bytes that are written in a single batch of WAL or memtable write.Use this if your DB is very small (like under 1GB) and you don't want to spend lots of memory for memtables.booleanIf true, the implementation will do aggressive checking of the data it is processing and will stop early if it detects any errors.booleanIf true, automatically persist stats to a hidden column family (column family name: ___rocksdb_stats_history___) every stats_persist_period_sec seconds; otherwise, write to an in-memory struct.longThis is a maximum buffer size that is used by WinMmapReadableFile in unbuffered disk I/O mode.longRecycle log files.rowCache()A global cache for table-level rows.setAdviseRandomOnOpen(boolean adviseRandomOnOpen) If set true, will hint the underlying file system that the file access pattern is random, when a sst file is opened.setAllow2pc(boolean allow2pc) if set to false then recovery will fail when a prepared transaction is encountered in the WAL Default: falsesetAllowConcurrentMemtableWrite(boolean allowConcurrentMemtableWrite) If true, allow multi-writers to update mem tables in parallel.setAllowFAllocate(boolean allowFAllocate) Whether fallocate calls are allowedsetAllowIngestBehind(boolean allowIngestBehind) Set this option to true during creation of database if you want to be able to ingest behind (call IngestExternalFile() skipping keys that already exist, rather than overwriting matching keys).setAllowMmapReads(boolean allowMmapReads) Allow the OS to mmap file for reading sst tables.setAllowMmapWrites(boolean allowMmapWrites) Allow the OS to mmap file for writing.setAtomicFlush(boolean atomicFlush) If true, RocksDB supports flushing multiple column families and committing their results atomically to MANIFEST.setAvoidFlushDuringRecovery(boolean avoidFlushDuringRecovery) By default RocksDB replay WAL logs and flush them on DB open, which may create very small SST files.setAvoidUnnecessaryBlockingIO(boolean avoidUnnecessaryBlockingIO) If true, working thread may avoid doing unnecessary and long-latency operation (such as deleting obsolete files directly or deleting memtable) and will instead schedule a background job to do it.setBestEffortsRecovery(boolean bestEffortsRecovery) By default, RocksDB recovery fails if any table file referenced in MANIFEST are missing after scanning the MANIFEST.setBgerrorResumeRetryInterval(long bgerrorResumeRetryInterval) If max_bgerror_resume_count is ≥ 2, db resume is called multiple times.setCreateIfMissing(boolean flag) If this value is set to true, then the database will be created if it is missing duringRocksDB.open().setCreateMissingColumnFamilies(boolean flag) If true, missing column families will be automatically createdsetDbLogDir(String dbLogDir) This specifies the info LOG dir.setDbPaths(Collection<DbPath> dbPaths) A list of paths where SST files can be put into, with its target size.setDbWriteBufferSize(long dbWriteBufferSize) Amount of data to build up in memtables across all column families before writing to disk.setDeleteObsoleteFilesPeriodMicros(long micros) The periodicity when obsolete files get deleted.setDumpMallocStats(boolean dumpMallocStats) If true, then print malloc stats together with rocksdb.stats when printing to LOG.setEnablePipelinedWrite(boolean enablePipelinedWrite) By default, a single write thread queue is maintained.setEnableThreadTracking(boolean enableThreadTracking) If true, then the status of the threads involved in this DB will be tracked and available via GetThreadList() API.setEnableWriteThreadAdaptiveYield(boolean enableWriteThreadAdaptiveYield) If true, threads synchronizing with the write batch group leader will wait for up towriteThreadMaxYieldUsec()before blocking on a mutex.Use the specified object to interact with the environment, e.g.setErrorIfExists(boolean errorIfExists) If true, an error will be thrown during RocksDB.open() if the database already exists.setFailIfOptionsFileError(boolean failIfOptionsFileError) If true, then DB::Open / CreateColumnFamily / DropColumnFamily / SetOptions will fail if options file is not detected or properly persisted.setIncreaseParallelism(int totalThreads) By default, RocksDB uses only one background thread for flush and compaction.setInfoLogLevel(InfoLogLevel infoLogLevel) Sets the RocksDB log level.setIsFdCloseOnExec(boolean isFdCloseOnExec) Disable child process inherit open files.setKeepLogFileNum(long keepLogFileNum) Specifies the maximum number of info log files to be kept.setListeners(List<AbstractEventListener> listeners) Sets theEventListeners whose callback functions will be called when specific RocksDB event happens.setLogFileTimeToRoll(long logFileTimeToRoll) Specifies the time interval for the info log file to roll (in seconds).setLogger(LoggerInterface logger) Any internal progress/error information generated by the db will be written to the Logger if it is non-nullptr, or to a file stored in the same directory as the DB contents if info_log is nullptr.setLogReadaheadSize(long logReadaheadSize) The number of bytes to prefetch when reading the log.setManifestPreallocationSize(long size) Number of bytes to preallocate (via fallocate) the manifest files.setManualWalFlush(boolean manualWalFlush) If true WAL is not flushed automatically after each write.setMaxBackgroundFlushes(int maxBackgroundFlushes) Deprecated.setMaxBgErrorResumeCount(int maxBgerrorResumeCount) It defines how many times db resume is called by a separate thread when background retryable IO Error happens.setMaxFileOpeningThreads(int maxFileOpeningThreads) IfMutableDBOptionsInterface.maxOpenFiles()is -1, DB will open all files on DB::Open().setMaxLogFileSize(long maxLogFileSize) Specifies the maximum size of a info log file.setMaxManifestFileSize(long maxManifestFileSize) Manifest file is rolled over on reaching this limit.setMaxSubcompactions(int maxSubcompactions) This value represents the maximum number of threads that will concurrently perform a compaction job by breaking it into multiple, smaller ones that are run simultaneously.setMaxWriteBatchGroupSizeBytes(long maxWriteBatchGroupSizeBytes) The maximum limit of number of bytes that are written in a single batch of WAL or memtable write.setParanoidChecks(boolean paranoidChecks) If true, the implementation will do aggressive checking of the data it is processing and will stop early if it detects any errors.setPersistStatsToDisk(boolean persistStatsToDisk) If true, automatically persist stats to a hidden column family (column family name: ___rocksdb_stats_history___) every stats_persist_period_sec seconds; otherwise, write to an in-memory struct.setRandomAccessMaxBufferSize(long randomAccessMaxBufferSize) This is a maximum buffer size that is used by WinMmapReadableFile in unbuffered disk I/O mode.setRateLimiter(RateLimiter rateLimiter) Use to control write rate of flush and compaction.setRecycleLogFileNum(long recycleLogFileNum) Recycle log files.setRowCache(Cache rowCache) A global cache for table-level rows.setSkipCheckingSstFileSizesOnDbOpen(boolean skipCheckingSstFileSizesOnDbOpen) If true, thenRocksDB.open(String)will not fetch and check sizes of all sst files.setSkipStatsUpdateOnDbOpen(boolean skipStatsUpdateOnDbOpen) If true, then DB::Open() will not update the statistics used to optimize compaction decision by loading table properties from many files.setSstFileManager(SstFileManager sstFileManager) Use to track SST files and control their file deletion rate.setStatistics(Statistics statistics) Sets the statistics object which collects metrics about database operations.setTableCacheNumshardbits(int tableCacheNumshardbits) Number of shards used for table cache.setTwoWriteQueues(boolean twoWriteQueues) If enabled it uses two queues for writes, one for the ones with disable_memtable and one for the ones that also write to memtable.setUnorderedWrite(boolean unorderedWrite) SettingunorderedWrite()to true trades higher write throughput with relaxing the immutability guarantee of snapshots.setUseAdaptiveMutex(boolean useAdaptiveMutex) Use adaptive mutex, which spins in the user space before resorting to kernel.setUseDirectIoForFlushAndCompaction(boolean useDirectIoForFlushAndCompaction) Enable the OS to use direct reads and writes in flush and compaction Default: falsesetUseDirectReads(boolean useDirectReads) Enable the OS to use direct I/O for reading sst tables.setUseFsync(boolean useFsync) If true, then every store to stable storage will issue a fsync.This specifies the absolute dir path for write-ahead logs (WAL).setWalFilter(AbstractWalFilter walFilter) A filter object supplied to be invoked while processing write-ahead-logs (WALs) during recovery.setWalRecoveryMode(WALRecoveryMode walRecoveryMode) Recovery mode to control the consistency while replaying WAL Default:WALRecoveryMode.PointInTimeRecoverysetWalSizeLimitMB(long sizeLimitMB) WalTtlSeconds() and walSizeLimitMB() affect how archived logs will be deleted.setWalTtlSeconds(long walTtlSeconds) walTtlSeconds()andwalSizeLimitMB()affect when WALs will be archived and deleted.setWriteBufferManager(WriteBufferManager writeBufferManager) Use passedWriteBufferManagerto control memory usage across multiple column families and/or DB instances.setWriteDbidToManifest(boolean writeDbidToManifest) Historically DB ID has always been stored in Identity File in DB folder.setWriteThreadMaxYieldUsec(long writeThreadMaxYieldUsec) The maximum number of microseconds that a write operation will use a yielding spin loop to coordinate with other write threads before blocking on a mutex.setWriteThreadSlowYieldUsec(long writeThreadSlowYieldUsec) The latency in microseconds after which a std::this_thread::yield call (sched_yield on Linux) is considered to be a signal that other processes or threads would like to use the current core.booleanIf true, thenRocksDB.open(String)will not fetch and check sizes of all sst files.booleanIf true, then DB::Open() will not update the statistics used to optimize compaction decision by loading table properties from many files.Returns statistics object.intNumber of shards used for table cache.booleanReturns true if two write queues are enabled.booleanReturns true if unordered write are enabled.booleanUse adaptive mutex, which spins in the user space before resorting to kernel.booleanEnable the OS to use direct reads and writes in flush and compactionbooleanEnable the OS to use direct I/O for reading sst tables.booleanuseFsync()If true, then every store to stable storage will issue a fsync.walDir()Returns the path to the write-ahead-logs (WAL) directory.Get's the filter for processing WALs during recovery.Recovery mode to control the consistency while replaying WAL Default:WALRecoveryMode.PointInTimeRecoverylongWalTtlSeconds() and walSizeLimitMB() affect when WALs will be archived and deleted.longWalTtlSeconds() and walSizeLimitMB() affect when WALs will be archived and deleted.Reference toWriteBufferManagerused by it.booleanHistorically DB ID has always been stored in Identity File in DB folder.longThe maximum number of microseconds that a write operation will use a yielding spin loop to coordinate with other write threads before blocking on a mutex.longThe latency in microseconds after which a std::this_thread::yield call (sched_yield on Linux) is considered to be a signal that other processes or threads would like to use the current core.
-
Method Details
-
optimizeForSmallDb
T optimizeForSmallDb()Use this if your DB is very small (like under 1GB) and you don't want to spend lots of memory for memtables.- Returns:
- the instance of the current object.
-
setEnv
Use the specified object to interact with the environment, e.g. to read/write files, schedule background work, etc. Default:Env.getDefault()- Parameters:
env-Envinstance.- Returns:
- the instance of the current Options.
-
getEnv
Env getEnv()Returns the set RocksEnv instance.- Returns:
RocksEnvinstance set in the options.
-
setIncreaseParallelism
By default, RocksDB uses only one background thread for flush and compaction. Calling this function will set it up such that total of `total_threads` is used.
You almost definitely want to call this function if your system is bottlenecked by RocksDB.
- Parameters:
totalThreads- The total number of threads to be used by RocksDB. A good value is the number of cores.- Returns:
- the instance of the current Options
-
setCreateIfMissing
If this value is set to true, then the database will be created if it is missing duringRocksDB.open(). Default: false- Parameters:
flag- a flag indicating whether to create a database the specified database inRocksDB.open(org.rocksdb.Options, String)operation is missing.- Returns:
- the instance of the current Options
- See Also:
-
createIfMissing
boolean createIfMissing()Return true if the create_if_missing flag is set to true. If true, the database will be created if it is missing.- Returns:
- true if the createIfMissing option is set to true.
- See Also:
-
setCreateMissingColumnFamilies
If true, missing column families will be automatically created
Default: false
- Parameters:
flag- a flag indicating if missing column families shall be created automatically.- Returns:
- true if missing column families shall be created automatically on open.
-
createMissingColumnFamilies
boolean createMissingColumnFamilies()Return true if the create_missing_column_families flag is set to true. If true column families be created if missing.- Returns:
- true if the createMissingColumnFamilies is set to true.
- See Also:
-
setErrorIfExists
If true, an error will be thrown during RocksDB.open() if the database already exists. Default: false- Parameters:
errorIfExists- if true, an exception will be thrown duringRocksDB.open()if the database already exists.- Returns:
- the reference to the current option.
- See Also:
-
errorIfExists
boolean errorIfExists()If true, an error will be thrown during RocksDB.open() if the database already exists.- Returns:
- if true, an error is raised when the specified database already exists before open.
-
setParanoidChecks
If true, the implementation will do aggressive checking of the data it is processing and will stop early if it detects any errors. This may have unforeseen ramifications: for example, a corruption of one DB entry may cause a large number of entries to become unreadable or for the entire DB to become unopenable. If any of the writes to the database fails (Put, Delete, Merge, Write), the database will switch to read-only mode and fail all other Write operations. Default: true- Parameters:
paranoidChecks- a flag to indicate whether paranoid-check is on.- Returns:
- the reference to the current option.
-
paranoidChecks
boolean paranoidChecks()If true, the implementation will do aggressive checking of the data it is processing and will stop early if it detects any errors. This may have unforeseen ramifications: for example, a corruption of one DB entry may cause a large number of entries to become unreadable or for the entire DB to become unopenable. If any of the writes to the database fails (Put, Delete, Merge, Write), the database will switch to read-only mode and fail all other Write operations.- Returns:
- a boolean indicating whether paranoid-check is on.
-
setRateLimiter
Use to control write rate of flush and compaction. Flush has higher priority than compaction. Rate limiting is disabled if nullptr. Default: nullptr- Parameters:
rateLimiter-RateLimiterinstance.- Returns:
- the instance of the current object.
- Since:
- 3.10.0
-
setSstFileManager
Use to track SST files and control their file deletion rate. Features: - Throttle the deletion rate of the SST files. - Keep track the total size of all SST files. - Set a maximum allowed space limit for SST files that when reached the DB wont do any further flushes or compactions and will set the background error. - Can be shared between multiple dbs. Limitations: - Only track and throttle deletes of SST files in first db_path (db_name if db_paths is empty).- Parameters:
sstFileManager- The SST File Manager for the db.- Returns:
- the instance of the current object.
-
setLogger
Any internal progress/error information generated by the db will be written to the Logger if it is non-nullptr, or to a file stored in the same directory as the DB contents if info_log is nullptr.
Default: nullptr
- Parameters:
logger-LoggerInterfaceinstance.- Returns:
- the instance of the current object.
-
setInfoLogLevel
Sets the RocksDB log level. Default level is INFO
- Parameters:
infoLogLevel- log level to set.- Returns:
- the instance of the current object.
-
infoLogLevel
InfoLogLevel infoLogLevel()Returns currently set log level.
- Returns:
InfoLogLevelinstance.
-
setMaxFileOpeningThreads
IfMutableDBOptionsInterface.maxOpenFiles()is -1, DB will open all files on DB::Open(). You can use this option to increase the number of threads used to open the files. Default: 16- Parameters:
maxFileOpeningThreads- the maximum number of threads to use to open files- Returns:
- the reference to the current options.
-
maxFileOpeningThreads
int maxFileOpeningThreads()IfMutableDBOptionsInterface.maxOpenFiles()is -1, DB will open all files on DB::Open(). You can use this option to increase the number of threads used to open the files. Default: 16- Returns:
- the maximum number of threads to use to open files
-
setStatistics
Sets the statistics object which collects metrics about database operations. Statistics objects should not be shared between DB instances as it does not use any locks to prevent concurrent updates.
- Parameters:
statistics- The statistics to set- Returns:
- the instance of the current object.
- See Also:
-
statistics
Statistics statistics()Returns statistics object.
- Returns:
- the instance of the statistics object or null if there is no statistics object.
- See Also:
-
setUseFsync
If true, then every store to stable storage will issue a fsync.
If false, then every store to stable storage will issue a fdatasync. This parameter should be set to true while storing data to filesystem like ext3 that can lose files after a reboot.
Default: false
- Parameters:
useFsync- a boolean flag to specify whether to use fsync- Returns:
- the instance of the current object.
-
useFsync
boolean useFsync()If true, then every store to stable storage will issue a fsync.
If false, then every store to stable storage will issue a fdatasync. This parameter should be set to true while storing data to filesystem like ext3 that can lose files after a reboot.
- Returns:
- boolean value indicating if fsync is used.
-
setDbPaths
A list of paths where SST files can be put into, with its target size. Newer data is placed into paths specified earlier in the vector while older data gradually moves to paths specified later in the vector. For example, you have a flash device with 10GB allocated for the DB, as well as a hard drive of 2TB, you should config it to be: [{"/flash_path", 10GB}, {"/hard_drive", 2TB}] The system will try to guarantee data under each path is close to but not larger than the target size. But current and future file sizes used by determining where to place a file are based on best-effort estimation, which means there is a chance that the actual size under the directory is slightly more than target size under some workloads. User should give some buffer room for those cases. If none of the paths has sufficient room to place a file, the file will be placed to the last path anyway, despite to the target size. Placing newer data to earlier paths is also best-efforts. User should expect user files to be placed in higher levels in some extreme cases. If left empty, only one path will be used, which is db_name passed when opening the DB. Default: empty- Parameters:
dbPaths- the paths and target sizes- Returns:
- the reference to the current options
-
dbPaths
A list of paths where SST files can be put into, with its target size. Newer data is placed into paths specified earlier in the vector while older data gradually moves to paths specified later in the vector. For example, you have a flash device with 10GB allocated for the DB, as well as a hard drive of 2TB, you should config it to be: [{"/flash_path", 10GB}, {"/hard_drive", 2TB}] The system will try to guarantee data under each path is close to but not larger than the target size. But current and future file sizes used by determining where to place a file are based on best-effort estimation, which means there is a chance that the actual size under the directory is slightly more than target size under some workloads. User should give some buffer room for those cases. If none of the paths has sufficient room to place a file, the file will be placed to the last path anyway, despite to the target size. Placing newer data to earlier paths is also best-efforts. User should expect user files to be placed in higher levels in some extreme cases. If left empty, only one path will be used, which is db_name passed when opening the DB. Default:Collections.emptyList()- Returns:
- dbPaths the paths and target sizes
-
setDbLogDir
This specifies the info LOG dir. If it is empty, the log files will be in the same dir as data. If it is non empty, the log files will be in the specified dir, and the db data dir's absolute path will be used as the log file name's prefix.- Parameters:
dbLogDir- the path to the info log directory- Returns:
- the instance of the current object.
-
dbLogDir
String dbLogDir()Returns the directory of info log. If it is empty, the log files will be in the same dir as data. If it is non empty, the log files will be in the specified dir, and the db data dir's absolute path will be used as the log file name's prefix.- Returns:
- the path to the info log directory
-
setWalDir
This specifies the absolute dir path for write-ahead logs (WAL). If it is empty, the log files will be in the same dir as data, dbname is used as the data dir by default If it is non empty, the log files will be in kept the specified dir. When destroying the db, all log files in wal_dir and the dir itself is deleted- Parameters:
walDir- the path to the write-ahead-log directory.- Returns:
- the instance of the current object.
-
walDir
String walDir()Returns the path to the write-ahead-logs (WAL) directory. If it is empty, the log files will be in the same dir as data, dbname is used as the data dir by default If it is non empty, the log files will be in kept the specified dir. When destroying the db, all log files in wal_dir and the dir itself is deleted- Returns:
- the path to the write-ahead-logs (WAL) directory.
-
setDeleteObsoleteFilesPeriodMicros
The periodicity when obsolete files get deleted. The default value is 6 hours. The files that get out of scope by compaction process will still get automatically delete on every compaction, regardless of this setting- Parameters:
micros- the time interval in micros- Returns:
- the instance of the current object.
-
deleteObsoleteFilesPeriodMicros
long deleteObsoleteFilesPeriodMicros()The periodicity when obsolete files get deleted. The default value is 6 hours. The files that get out of scope by compaction process will still get automatically delete on every compaction, regardless of this setting- Returns:
- the time interval in micros when obsolete files will be deleted.
-
setMaxSubcompactions
This value represents the maximum number of threads that will concurrently perform a compaction job by breaking it into multiple, smaller ones that are run simultaneously. Default: 1 (i.e. no subcompactions)- Parameters:
maxSubcompactions- The maximum number of threads that will concurrently perform a compaction job- Returns:
- the instance of the current object.
-
maxSubcompactions
int maxSubcompactions()This value represents the maximum number of threads that will concurrently perform a compaction job by breaking it into multiple, smaller ones that are run simultaneously. Default: 1 (i.e. no subcompactions)- Returns:
- The maximum number of threads that will concurrently perform a compaction job
-
setMaxBackgroundFlushes
Deprecated.NOT SUPPORTED ANYMORE: RocksDB automatically decides this based on the value of max_background_jobs. For backwards compatibility we will set `max_background_jobs = max_background_compactions + max_background_flushes` in the case where user sets at least one of `max_background_compactions` or `max_background_flushes`. Specifies the maximum number of concurrent background flush jobs. If you're increasing this, also consider increasing number of threads in HIGH priority thread pool. For more information, see Default: -1- Parameters:
maxBackgroundFlushes- number of max concurrent flush jobs- Returns:
- the instance of the current object.
- See Also:
-
maxBackgroundFlushes
Deprecated.NOT SUPPORTED ANYMORE: RocksDB automatically decides this based on the value of max_background_jobs. For backwards compatibility we will set `max_background_jobs = max_background_compactions + max_background_flushes` in the case where user sets at least one of `max_background_compactions` or `max_background_flushes`. Returns the maximum number of concurrent background flush jobs. If you're increasing this, also consider increasing number of threads in HIGH priority thread pool. For more information, see Default: -1- Returns:
- the maximum number of concurrent background flush jobs.
- See Also:
-
setMaxLogFileSize
Specifies the maximum size of a info log file. If the current log file is larger than `max_log_file_size`, a new info log file will be created. If 0, all logs will be written to one log file.- Parameters:
maxLogFileSize- the maximum size of a info log file.- Returns:
- the instance of the current object.
- Throws:
IllegalArgumentException- thrown on 32-Bit platforms while overflowing the underlying platform specific value.
-
maxLogFileSize
long maxLogFileSize()Returns the maximum size of a info log file. If the current log file is larger than this size, a new info log file will be created. If 0, all logs will be written to one log file.- Returns:
- the maximum size of the info log file.
-
setLogFileTimeToRoll
Specifies the time interval for the info log file to roll (in seconds). If specified with non-zero value, log file will be rolled if it has been active longer than `log_file_time_to_roll`. Default: 0 (disabled)- Parameters:
logFileTimeToRoll- the time interval in seconds.- Returns:
- the instance of the current object.
- Throws:
IllegalArgumentException- thrown on 32-Bit platforms while overflowing the underlying platform specific value.
-
logFileTimeToRoll
long logFileTimeToRoll()Returns the time interval for the info log file to roll (in seconds). If specified with non-zero value, log file will be rolled if it has been active longer than `log_file_time_to_roll`. Default: 0 (disabled)- Returns:
- the time interval in seconds.
-
setKeepLogFileNum
Specifies the maximum number of info log files to be kept. Default: 1000- Parameters:
keepLogFileNum- the maximum number of info log files to be kept.- Returns:
- the instance of the current object.
- Throws:
IllegalArgumentException- thrown on 32-Bit platforms while overflowing the underlying platform specific value.
-
keepLogFileNum
long keepLogFileNum()Returns the maximum number of info log files to be kept. Default: 1000- Returns:
- the maximum number of info log files to be kept.
-
setRecycleLogFileNum
Recycle log files. If non-zero, we will reuse previously written log files for new logs, overwriting the old data. The value indicates how many such files we will keep around at any point in time for later use. This is more efficient because the blocks are already allocated and fdatasync does not need to update the inode after each write. Default: 0- Parameters:
recycleLogFileNum- the number of log files to keep for recycling- Returns:
- the reference to the current options
-
recycleLogFileNum
long recycleLogFileNum()Recycle log files. If non-zero, we will reuse previously written log files for new logs, overwriting the old data. The value indicates how many such files we will keep around at any point in time for later use. This is more efficient because the blocks are already allocated and fdatasync does not need to update the inode after each write. Default: 0- Returns:
- the number of log files kept for recycling
-
setMaxManifestFileSize
Manifest file is rolled over on reaching this limit. The older manifest file be deleted. The default value is 1GB so that the manifest file can grow, but not reach the limit of storage capacity.- Parameters:
maxManifestFileSize- the size limit of a manifest file.- Returns:
- the instance of the current object.
-
maxManifestFileSize
long maxManifestFileSize()Manifest file is rolled over on reaching this limit. The older manifest file be deleted. The default value is 1GB so that the manifest file can grow, but not reach the limit of storage capacity.- Returns:
- the size limit of a manifest file.
-
setTableCacheNumshardbits
Number of shards used for table cache.- Parameters:
tableCacheNumshardbits- the number of chards- Returns:
- the instance of the current object.
-
tableCacheNumshardbits
int tableCacheNumshardbits()Number of shards used for table cache.- Returns:
- the number of shards used for table cache.
-
setWalTtlSeconds
walTtlSeconds()andwalSizeLimitMB()affect when WALs will be archived and deleted. When both are zero, obsolete WALs will not be archived and will be deleted immediately. Otherwise, obsolete WALs will be archived prior to deletion. When `WAL_size_limit_MB` is nonzero, archived WALs starting with the earliest will be deleted until the total size of the archive falls below this limit. All empty WALs will be deleted. When `WAL_ttl_seconds` is nonzero, archived WALs older than `WAL_ttl_seconds` will be deleted. When only `WAL_ttl_seconds` is nonzero, the frequency at which archived WALs are deleted is every `WAL_ttl_seconds / 2` seconds. When only `WAL_size_limit_MB` is nonzero, the deletion frequency is every ten minutes. When both are nonzero, the deletion frequency is the minimum of those two values.- Parameters:
walTtlSeconds- the ttl seconds- Returns:
- the instance of the current object.
- See Also:
-
walTtlSeconds
long walTtlSeconds()WalTtlSeconds() and walSizeLimitMB() affect when WALs will be archived and deleted. When both are zero, obsolete WALs will not be archived and will be deleted immediately. Otherwise, obsolete WALs will be archived prior to deletion. When `WAL_size_limit_MB` is nonzero, archived WALs starting with the earliest will be deleted until the total size of the archive falls below this limit. All empty WALs will be deleted. When `WAL_ttl_seconds` is nonzero, archived WALs older than `WAL_ttl_seconds` will be deleted. When only `WAL_ttl_seconds` is nonzero, the frequency at which archived WALs are deleted is every `WAL_ttl_seconds / 2` seconds. When only `WAL_size_limit_MB` is nonzero, the deletion frequency is every ten minutes. When both are nonzero, the deletion frequency is the minimum of those two values.- Returns:
- the wal-ttl seconds
- See Also:
-
setWalSizeLimitMB
WalTtlSeconds() and walSizeLimitMB() affect how archived logs will be deleted. When both are zero, obsolete WALs will not be archived and will be deleted immediately. Otherwise, obsolete WALs will be archived prior to deletion. When `WAL_size_limit_MB` is nonzero, archived WALs starting with the earliest will be deleted until the total size of the archive falls below this limit. All empty WALs will be deleted. When `WAL_ttl_seconds` is nonzero, archived WALs older than `WAL_ttl_seconds` will be deleted. When only `WAL_ttl_seconds` is nonzero, the frequency at which archived WALs are deleted is every `WAL_ttl_seconds / 2` seconds. When only `WAL_size_limit_MB` is nonzero, the deletion frequency is every ten minutes. When both are nonzero, the deletion frequency is the minimum of those two values.- Parameters:
sizeLimitMB- size limit in mega-bytes.- Returns:
- the instance of the current object.
- See Also:
-
walSizeLimitMB
long walSizeLimitMB()WalTtlSeconds() and walSizeLimitMB() affect when WALs will be archived and deleted. When both are zero, obsolete WALs will not be archived and will be deleted immediately. Otherwise, obsolete WALs will be archived prior to deletion. When `WAL_size_limit_MB` is nonzero, archived WALs starting with the earliest will be deleted until the total size of the archive falls below this limit. All empty WALs will be deleted. When `WAL_ttl_seconds` is nonzero, archived WALs older than `WAL_ttl_seconds` will be deleted. When only `WAL_ttl_seconds` is nonzero, the frequency at which archived WALs are deleted is every `WAL_ttl_seconds / 2` seconds. When only `WAL_size_limit_MB` is nonzero, the deletion frequency is every ten minutes. When both are nonzero, the deletion frequency is the minimum of those two values.- Returns:
- size limit in mega-bytes.
- See Also:
-
setMaxWriteBatchGroupSizeBytes
The maximum limit of number of bytes that are written in a single batch of WAL or memtable write. It is followed when the leader write size is larger than 1/8 of this limit. Default: 1 MB- Parameters:
maxWriteBatchGroupSizeBytes- the maximum limit of number of bytes, see description.- Returns:
- the instance of the current object.
-
maxWriteBatchGroupSizeBytes
long maxWriteBatchGroupSizeBytes()The maximum limit of number of bytes that are written in a single batch of WAL or memtable write. It is followed when the leader write size is larger than 1/8 of this limit. Default: 1 MB- Returns:
- the maximum limit of number of bytes, see description.
-
setManifestPreallocationSize
Number of bytes to preallocate (via fallocate) the manifest files. Default is 4mb, which is reasonable to reduce random IO as well as prevent overallocation for mounts that preallocate large amounts of data (such as xfs's allocsize option).- Parameters:
size- the size in byte- Returns:
- the instance of the current object.
- Throws:
IllegalArgumentException- thrown on 32-Bit platforms while overflowing the underlying platform specific value.
-
manifestPreallocationSize
long manifestPreallocationSize()Number of bytes to preallocate (via fallocate) the manifest files. Default is 4mb, which is reasonable to reduce random IO as well as prevent overallocation for mounts that preallocate large amounts of data (such as xfs's allocsize option).- Returns:
- size in bytes.
-
setUseDirectReads
Enable the OS to use direct I/O for reading sst tables. Default: false- Parameters:
useDirectReads- if true, then direct read is enabled- Returns:
- the instance of the current object.
-
useDirectReads
boolean useDirectReads()Enable the OS to use direct I/O for reading sst tables. Default: false- Returns:
- if true, then direct reads are enabled
-
setUseDirectIoForFlushAndCompaction
Enable the OS to use direct reads and writes in flush and compaction Default: false- Parameters:
useDirectIoForFlushAndCompaction- if true, then direct I/O will be enabled for background flush and compactions- Returns:
- the instance of the current object.
-
useDirectIoForFlushAndCompaction
boolean useDirectIoForFlushAndCompaction()Enable the OS to use direct reads and writes in flush and compaction- Returns:
- if true, then direct I/O is enabled for flush and compaction
-
setAllowFAllocate
Whether fallocate calls are allowed- Parameters:
allowFAllocate- false if fallocate() calls are bypassed- Returns:
- the reference to the current options.
-
allowFAllocate
boolean allowFAllocate()Whether fallocate calls are allowed- Returns:
- false if fallocate() calls are bypassed
-
setAllowMmapReads
Allow the OS to mmap file for reading sst tables. Default: false- Parameters:
allowMmapReads- true if mmap reads are allowed.- Returns:
- the instance of the current object.
-
allowMmapReads
boolean allowMmapReads()Allow the OS to mmap file for reading sst tables. Default: false- Returns:
- true if mmap reads are allowed.
-
setAllowMmapWrites
Allow the OS to mmap file for writing. Default: false- Parameters:
allowMmapWrites- true if mmap writes are allowd.- Returns:
- the instance of the current object.
-
allowMmapWrites
boolean allowMmapWrites()Allow the OS to mmap file for writing. Default: false- Returns:
- true if mmap writes are allowed.
-
setIsFdCloseOnExec
Disable child process inherit open files. Default: true- Parameters:
isFdCloseOnExec- true if child process inheriting open files is disabled.- Returns:
- the instance of the current object.
-
isFdCloseOnExec
boolean isFdCloseOnExec()Disable child process inherit open files. Default: true- Returns:
- true if child process inheriting open files is disabled.
-
setAdviseRandomOnOpen
If set true, will hint the underlying file system that the file access pattern is random, when a sst file is opened. Default: true- Parameters:
adviseRandomOnOpen- true if hinting random access is on.- Returns:
- the instance of the current object.
-
adviseRandomOnOpen
boolean adviseRandomOnOpen()If set true, will hint the underlying file system that the file access pattern is random, when a sst file is opened. Default: true- Returns:
- true if hinting random access is on.
-
setDbWriteBufferSize
Amount of data to build up in memtables across all column families before writing to disk. This is distinct fromColumnFamilyOptions.writeBufferSize(), which enforces a limit for a single memtable. This feature is disabled by default. Specify a non-zero value to enable it. Default: 0 (disabled)- Parameters:
dbWriteBufferSize- the size of the write buffer- Returns:
- the reference to the current options.
-
setWriteBufferManager
Use passedWriteBufferManagerto control memory usage across multiple column families and/or DB instances. Check https://github.com/facebook/rocksdb/wiki/Write-Buffer-Manager for more details on when to use it- Parameters:
writeBufferManager- The WriteBufferManager to use- Returns:
- the reference of the current options.
-
writeBufferManager
WriteBufferManager writeBufferManager()Reference toWriteBufferManagerused by it.
Default: null (Disabled)- Returns:
- a reference to WriteBufferManager
-
dbWriteBufferSize
long dbWriteBufferSize()Amount of data to build up in memtables across all column families before writing to disk. This is distinct fromColumnFamilyOptions.writeBufferSize(), which enforces a limit for a single memtable. This feature is disabled by default. Specify a non-zero value to enable it. Default: 0 (disabled)- Returns:
- the size of the write buffer
-
setRandomAccessMaxBufferSize
This is a maximum buffer size that is used by WinMmapReadableFile in unbuffered disk I/O mode. We need to maintain an aligned buffer for reads. We allow the buffer to grow until the specified value and then for bigger requests allocate one shot buffers. In unbuffered mode we always bypass read-ahead buffer at ReadaheadRandomAccessFile When read-ahead is required we then make use ofMutableDBOptionsInterface.compactionReadaheadSize()value and always try to read ahead. With read-ahead we always pre-allocate buffer to the size instead of growing it up to a limit. This option is currently honored only on Windows Default: 1 Mb Special value: 0 - means do not maintain per instance buffer. Allocate per request buffer and avoid locking.- Parameters:
randomAccessMaxBufferSize- the maximum size of the random access buffer- Returns:
- the reference to the current options.
-
randomAccessMaxBufferSize
long randomAccessMaxBufferSize()This is a maximum buffer size that is used by WinMmapReadableFile in unbuffered disk I/O mode. We need to maintain an aligned buffer for reads. We allow the buffer to grow until the specified value and then for bigger requests allocate one shot buffers. In unbuffered mode we always bypass read-ahead buffer at ReadaheadRandomAccessFile When read-ahead is required we then make use ofMutableDBOptionsInterface.compactionReadaheadSize()value and always try to read ahead. With read-ahead we always pre-allocate buffer to the size instead of growing it up to a limit. This option is currently honored only on Windows Default: 1 Mb Special value: 0 - means do not maintain per instance buffer. Allocate per request buffer and avoid locking.- Returns:
- the maximum size of the random access buffer
-
setUseAdaptiveMutex
Use adaptive mutex, which spins in the user space before resorting to kernel. This could reduce context switch when the mutex is not heavily contended. However, if the mutex is hot, we could end up wasting spin time. Default: false- Parameters:
useAdaptiveMutex- true if adaptive mutex is used.- Returns:
- the instance of the current object.
-
useAdaptiveMutex
boolean useAdaptiveMutex()Use adaptive mutex, which spins in the user space before resorting to kernel. This could reduce context switch when the mutex is not heavily contended. However, if the mutex is hot, we could end up wasting spin time. Default: false- Returns:
- true if adaptive mutex is used.
-
setListeners
Sets theEventListeners whose callback functions will be called when specific RocksDB event happens. Note: the RocksJava API currently only supports EventListeners implemented in Java. It could be extended in future to also support adding/removing EventListeners implemented in C++.- Parameters:
listeners- the listeners who should be notified on various events.- Returns:
- the instance of the current object.
-
listeners
List<AbstractEventListener> listeners()Sets theEventListeners whose callback functions will be called when specific RocksDB event happens. Note: the RocksJava API currently only supports EventListeners implemented in Java. It could be extended in future to also support adding/removing EventListeners implemented in C++.- Returns:
- the instance of the current object.
-
setEnableThreadTracking
If true, then the status of the threads involved in this DB will be tracked and available via GetThreadList() API. Default: false- Parameters:
enableThreadTracking- true to enable tracking- Returns:
- the reference to the current options.
-
enableThreadTracking
boolean enableThreadTracking()If true, then the status of the threads involved in this DB will be tracked and available via GetThreadList() API. Default: false- Returns:
- true if tracking is enabled
-
setEnablePipelinedWrite
By default, a single write thread queue is maintained. The thread gets to the head of the queue becomes write batch group leader and responsible for writing to WAL and memtable for the batch group. IfenablePipelinedWrite()is true, separate write thread queue is maintained for WAL write and memtable write. A write thread first enter WAL writer queue and then memtable writer queue. Pending thread on the WAL writer queue thus only have to wait for previous writers to finish their WAL writing but not the memtable writing. Enabling the feature may improve write throughput and reduce latency of the prepare phase of two-phase commit. Default: false- Parameters:
enablePipelinedWrite- true to enabled pipelined writes- Returns:
- the reference to the current options.
-
enablePipelinedWrite
boolean enablePipelinedWrite()Returns true if pipelined writes are enabled. SeesetEnablePipelinedWrite(boolean).- Returns:
- true if pipelined writes are enabled, false otherwise.
-
setUnorderedWrite
SettingunorderedWrite()to true trades higher write throughput with relaxing the immutability guarantee of snapshots. This violates the repeatability one expects from ::Get from a snapshot, as well as ::MultiGet and Iterator's consistent-point-in-time view property. If the application cannot tolerate the relaxed guarantees, it can implement its own mechanisms to work around that and yet benefit from the higher throughput. Using TransactionDB with WRITE_PREPARED write policy andtwoWriteQueues()true is one way to achieve immutable snapshots despite unordered_write. By default, i.e., when it is false, rocksdb does not advance the sequence number for new snapshots unless all the writes with lower sequence numbers are already finished. This provides the immutability that we except from snapshots. Moreover, since Iterator and MultiGet internally depend on snapshots, the snapshot immutability results into Iterator and MultiGet offering consistent-point-in-time view. If set to true, although Read-Your-Own-Write property is still provided, the snapshot immutability property is relaxed: the writes issued after the snapshot is obtained (with larger sequence numbers) will be still not visible to the reads from that snapshot, however, there still might be pending writes (with lower sequence number) that will change the state visible to the snapshot after they are landed to the memtable.- Parameters:
unorderedWrite- true to enabled unordered write- Returns:
- the reference to the current options.
-
unorderedWrite
boolean unorderedWrite()Returns true if unordered write are enabled. SeesetUnorderedWrite(boolean).- Returns:
- true if unordered write are enabled, false otherwise.
-
setAllowConcurrentMemtableWrite
If true, allow multi-writers to update mem tables in parallel. Only some memtable factorys support concurrent writes; currently it is implemented only for SkipListFactory. Concurrent memtable writes are not compatible with inplace_update_support or filter_deletes. It is strongly recommended to setsetEnableWriteThreadAdaptiveYield(boolean)if you are going to use this feature. Default: true- Parameters:
allowConcurrentMemtableWrite- true to enable concurrent writes for the memtable- Returns:
- the reference to the current options.
-
allowConcurrentMemtableWrite
boolean allowConcurrentMemtableWrite()If true, allow multi-writers to update mem tables in parallel. Only some memtable factorys support concurrent writes; currently it is implemented only for SkipListFactory. Concurrent memtable writes are not compatible with inplace_update_support or filter_deletes. It is strongly recommended to setsetEnableWriteThreadAdaptiveYield(boolean)if you are going to use this feature. Default: true- Returns:
- true if concurrent writes are enabled for the memtable
-
setEnableWriteThreadAdaptiveYield
If true, threads synchronizing with the write batch group leader will wait for up towriteThreadMaxYieldUsec()before blocking on a mutex. This can substantially improve throughput for concurrent workloads, regardless of whetherallowConcurrentMemtableWrite()is enabled. Default: true- Parameters:
enableWriteThreadAdaptiveYield- true to enable adaptive yield for the write threads- Returns:
- the reference to the current options.
-
enableWriteThreadAdaptiveYield
boolean enableWriteThreadAdaptiveYield()If true, threads synchronizing with the write batch group leader will wait for up towriteThreadMaxYieldUsec()before blocking on a mutex. This can substantially improve throughput for concurrent workloads, regardless of whetherallowConcurrentMemtableWrite()is enabled. Default: true- Returns:
- true if adaptive yield is enabled for the writing threads
-
setWriteThreadMaxYieldUsec
The maximum number of microseconds that a write operation will use a yielding spin loop to coordinate with other write threads before blocking on a mutex. (AssumingwriteThreadSlowYieldUsec()is set properly) increasing this value is likely to increase RocksDB throughput at the expense of increased CPU usage. Default: 100- Parameters:
writeThreadMaxYieldUsec- maximum number of microseconds- Returns:
- the reference to the current options.
-
writeThreadMaxYieldUsec
long writeThreadMaxYieldUsec()The maximum number of microseconds that a write operation will use a yielding spin loop to coordinate with other write threads before blocking on a mutex. (AssumingwriteThreadSlowYieldUsec()is set properly) increasing this value is likely to increase RocksDB throughput at the expense of increased CPU usage. Default: 100- Returns:
- the maximum number of microseconds
-
setWriteThreadSlowYieldUsec
The latency in microseconds after which a std::this_thread::yield call (sched_yield on Linux) is considered to be a signal that other processes or threads would like to use the current core. Increasing this makes writer threads more likely to take CPU by spinning, which will show up as an increase in the number of involuntary context switches. Default: 3- Parameters:
writeThreadSlowYieldUsec- the latency in microseconds- Returns:
- the reference to the current options.
-
writeThreadSlowYieldUsec
long writeThreadSlowYieldUsec()The latency in microseconds after which a std::this_thread::yield call (sched_yield on Linux) is considered to be a signal that other processes or threads would like to use the current core. Increasing this makes writer threads more likely to take CPU by spinning, which will show up as an increase in the number of involuntary context switches. Default: 3- Returns:
- writeThreadSlowYieldUsec the latency in microseconds
-
setSkipStatsUpdateOnDbOpen
If true, then DB::Open() will not update the statistics used to optimize compaction decision by loading table properties from many files. Turning off this feature will improve DBOpen time especially in disk environment. Default: false- Parameters:
skipStatsUpdateOnDbOpen- true if updating stats will be skipped- Returns:
- the reference to the current options.
-
skipStatsUpdateOnDbOpen
boolean skipStatsUpdateOnDbOpen()If true, then DB::Open() will not update the statistics used to optimize compaction decision by loading table properties from many files. Turning off this feature will improve DBOpen time especially in disk environment. Default: false- Returns:
- true if updating stats will be skipped
-
setSkipCheckingSstFileSizesOnDbOpen
If true, thenRocksDB.open(String)will not fetch and check sizes of all sst files. This may significantly speed up startup if there are many sst files, especially when using non-default Env with expensive GetFileSize(). We'll still check that all required sst files exist. Ifparanoid_checksis false, this option is ignored, and sst files are not checked at all. Default: false- Parameters:
skipCheckingSstFileSizesOnDbOpen- if true, then SST file sizes will not be checked when callingRocksDB.open(String).- Returns:
- the reference to the current options.
-
skipCheckingSstFileSizesOnDbOpen
boolean skipCheckingSstFileSizesOnDbOpen()If true, thenRocksDB.open(String)will not fetch and check sizes of all sst files. This may significantly speed up startup if there are many sst files, especially when using non-default Env with expensive GetFileSize(). We'll still check that all required sst files exist. Ifparanoid_checksis false, this option is ignored, and sst files are not checked at all. Default: false- Returns:
- true, if file sizes will not be checked when calling
RocksDB.open(String).
-
setWalRecoveryMode
Recovery mode to control the consistency while replaying WAL Default:WALRecoveryMode.PointInTimeRecovery- Parameters:
walRecoveryMode- The WAL recover mode- Returns:
- the reference to the current options.
-
walRecoveryMode
WALRecoveryMode walRecoveryMode()Recovery mode to control the consistency while replaying WAL Default:WALRecoveryMode.PointInTimeRecovery- Returns:
- The WAL recover mode
-
setAllow2pc
if set to false then recovery will fail when a prepared transaction is encountered in the WAL Default: false- Parameters:
allow2pc- true if two-phase-commit is enabled- Returns:
- the reference to the current options.
-
allow2pc
boolean allow2pc()if set to false then recovery will fail when a prepared transaction is encountered in the WAL Default: false- Returns:
- true if two-phase-commit is enabled
-
setRowCache
A global cache for table-level rows. Default: null (disabled)- Parameters:
rowCache- The global row cache- Returns:
- the reference to the current options.
-
rowCache
Cache rowCache()A global cache for table-level rows. Default: null (disabled)- Returns:
- The global row cache
-
setWalFilter
A filter object supplied to be invoked while processing write-ahead-logs (WALs) during recovery. The filter provides a way to inspect log records, ignoring a particular record or skipping replay. The filter is invoked at startup and is invoked from a single-thread currently.- Parameters:
walFilter- the filter for processing WALs during recovery.- Returns:
- the reference to the current options.
-
walFilter
WalFilter walFilter()Get's the filter for processing WALs during recovery. SeesetWalFilter(AbstractWalFilter).- Returns:
- the filter used for processing WALs during recovery.
-
setFailIfOptionsFileError
If true, then DB::Open / CreateColumnFamily / DropColumnFamily / SetOptions will fail if options file is not detected or properly persisted. DEFAULT: false- Parameters:
failIfOptionsFileError- true if we should fail if there is an error in the options file- Returns:
- the reference to the current options.
-
failIfOptionsFileError
boolean failIfOptionsFileError()If true, then DB::Open / CreateColumnFamily / DropColumnFamily / SetOptions will fail if options file is not detected or properly persisted. DEFAULT: false- Returns:
- true if we should fail if there is an error in the options file
-
setDumpMallocStats
If true, then print malloc stats together with rocksdb.stats when printing to LOG. DEFAULT: false- Parameters:
dumpMallocStats- true if malloc stats should be printed to LOG- Returns:
- the reference to the current options.
-
dumpMallocStats
boolean dumpMallocStats()If true, then print malloc stats together with rocksdb.stats when printing to LOG. DEFAULT: false- Returns:
- true if malloc stats should be printed to LOG
-
setAvoidFlushDuringRecovery
By default RocksDB replay WAL logs and flush them on DB open, which may create very small SST files. If this option is enabled, RocksDB will try to avoid (but not guarantee not to) flush during recovery. Also, existing WAL logs will be kept, so that if crash happened before flush, we still have logs to recover from. DEFAULT: false- Parameters:
avoidFlushDuringRecovery- true to try to avoid (but not guarantee not to) flush during recovery- Returns:
- the reference to the current options.
-
avoidFlushDuringRecovery
boolean avoidFlushDuringRecovery()By default RocksDB replay WAL logs and flush them on DB open, which may create very small SST files. If this option is enabled, RocksDB will try to avoid (but not guarantee not to) flush during recovery. Also, existing WAL logs will be kept, so that if crash happened before flush, we still have logs to recover from. DEFAULT: false- Returns:
- true to try to avoid (but not guarantee not to) flush during recovery
-
setAllowIngestBehind
Set this option to true during creation of database if you want to be able to ingest behind (call IngestExternalFile() skipping keys that already exist, rather than overwriting matching keys). Setting this option to true will affect 2 things: 1) Disable some internal optimizations around SST file compression 2) Reserve bottom-most level for ingested files only. 3) Note that num_levels should be >= 3 if this option is turned on. DEFAULT: false- Parameters:
allowIngestBehind- true to allow ingest behind, false to disallow.- Returns:
- the reference to the current options.
-
allowIngestBehind
boolean allowIngestBehind()Returns true if ingest behind is allowed. SeesetAllowIngestBehind(boolean).- Returns:
- true if ingest behind is allowed, false otherwise.
-
setTwoWriteQueues
If enabled it uses two queues for writes, one for the ones with disable_memtable and one for the ones that also write to memtable. This allows the memtable writes not to lag behind other writes. It can be used to optimize MySQL 2PC in which only the commits, which are serial, write to memtable. DEFAULT: false- Parameters:
twoWriteQueues- true to enable two write queues, false otherwise.- Returns:
- the reference to the current options.
-
twoWriteQueues
boolean twoWriteQueues()Returns true if two write queues are enabled.- Returns:
- true if two write queues are enabled, false otherwise.
-
setManualWalFlush
If true WAL is not flushed automatically after each write. Instead it relies on manual invocation of FlushWAL to write the WAL buffer to its file. DEFAULT: false- Parameters:
manualWalFlush- true to set disable automatic WAL flushing, false otherwise.- Returns:
- the reference to the current options.
-
manualWalFlush
boolean manualWalFlush()Returns true if automatic WAL flushing is disabled. SeesetManualWalFlush(boolean).- Returns:
- true if automatic WAL flushing is disabled, false otherwise.
-
setAtomicFlush
If true, RocksDB supports flushing multiple column families and committing their results atomically to MANIFEST. Note that it is not necessary to set atomic_flush to true if WAL is always enabled since WAL allows the database to be restored to the last persistent state in WAL. This option is useful when there are column families with writes NOT protected by WAL. For manual flush, application has to specify which column families to flush atomically inRocksDB.flush(FlushOptions, List). For auto-triggered flush, RocksDB atomically flushes ALL column families. Currently, any WAL-enabled writes after atomic flush may be replayed independently if the process crashes later and tries to recover.- Parameters:
atomicFlush- true to enable atomic flush of multiple column families.- Returns:
- the reference to the current options.
-
atomicFlush
boolean atomicFlush()Determine if atomic flush of multiple column families is enabled. SeesetAtomicFlush(boolean).- Returns:
- true if atomic flush is enabled.
-
setAvoidUnnecessaryBlockingIO
If true, working thread may avoid doing unnecessary and long-latency operation (such as deleting obsolete files directly or deleting memtable) and will instead schedule a background job to do it. Use it if you're latency-sensitive. If set to true, takes precedence overReadOptions.setBackgroundPurgeOnIteratorCleanup(boolean).- Parameters:
avoidUnnecessaryBlockingIO- If true, working thread may avoid doing unnecessary operation.- Returns:
- the reference to the current options.
-
avoidUnnecessaryBlockingIO
boolean avoidUnnecessaryBlockingIO()If true, working thread may avoid doing unnecessary and long-latency operation (such as deleting obsolete files directly or deleting memtable) and will instead schedule a background job to do it. Use it if you're latency-sensitive. If set to true, takes precedence overReadOptions.setBackgroundPurgeOnIteratorCleanup(boolean).- Returns:
- true, if working thread may avoid doing unnecessary operation.
-
setPersistStatsToDisk
If true, automatically persist stats to a hidden column family (column family name: ___rocksdb_stats_history___) every stats_persist_period_sec seconds; otherwise, write to an in-memory struct. User can query through `GetStatsHistory` API. If user attempts to create a column family with the same name on a DB which have previously set persist_stats_to_disk to true, the column family creation will fail, but the hidden column family will survive, as well as the previously persisted statistics. When peristing stats to disk, the stat name will be limited at 100 bytes. Default: false- Parameters:
persistStatsToDisk- true if stats should be persisted to hidden column family.- Returns:
- the instance of the current object.
-
persistStatsToDisk
boolean persistStatsToDisk()If true, automatically persist stats to a hidden column family (column family name: ___rocksdb_stats_history___) every stats_persist_period_sec seconds; otherwise, write to an in-memory struct. User can query through `GetStatsHistory` API. If user attempts to create a column family with the same name on a DB which have previously set persist_stats_to_disk to true, the column family creation will fail, but the hidden column family will survive, as well as the previously persisted statistics. When peristing stats to disk, the stat name will be limited at 100 bytes. Default: false- Returns:
- true if stats should be persisted to hidden column family.
-
setWriteDbidToManifest
Historically DB ID has always been stored in Identity File in DB folder. If this flag is true, the DB ID is written to Manifest file in addition to the Identity file. By doing this 2 problems are solved 1. We don't checksum the Identity file where as Manifest file is. 2. Since the source of truth for DB is Manifest file DB ID will sit with the source of truth. Previously the Identity file could be copied independent of Manifest and that can result in wrong DB ID. We recommend setting this flag to true. Default: false- Parameters:
writeDbidToManifest- if true, then DB ID will be written to Manifest file.- Returns:
- the instance of the current object.
-
writeDbidToManifest
boolean writeDbidToManifest()Historically DB ID has always been stored in Identity File in DB folder. If this flag is true, the DB ID is written to Manifest file in addition to the Identity file. By doing this 2 problems are solved 1. We don't checksum the Identity file where as Manifest file is. 2. Since the source of truth for DB is Manifest file DB ID will sit with the source of truth. Previously the Identity file could be copied independent of Manifest and that can result in wrong DB ID. We recommend setting this flag to true. Default: false- Returns:
- true, if DB ID will be written to Manifest file.
-
setLogReadaheadSize
The number of bytes to prefetch when reading the log. This is mostly useful for reading a remotely located log, as it can save the number of round-trips. If 0, then the prefetching is disabled. Default: 0- Parameters:
logReadaheadSize- the number of bytes to prefetch when reading the log.- Returns:
- the instance of the current object.
-
logReadaheadSize
long logReadaheadSize()The number of bytes to prefetch when reading the log. This is mostly useful for reading a remotely located log, as it can save the number of round-trips. If 0, then the prefetching is disabled. Default: 0- Returns:
- the number of bytes to prefetch when reading the log.
-
setBestEffortsRecovery
By default, RocksDB recovery fails if any table file referenced in MANIFEST are missing after scanning the MANIFEST. Best-efforts recovery is another recovery mode that tries to restore the database to the most recent point in time without missing file. Currently not compatible with atomic flush. Furthermore, WAL files will not be used for recovery if best_efforts_recovery is true. Default: false- Parameters:
bestEffortsRecovery- if true, RocksDB will use best-efforts mode when recovering.- Returns:
- the instance of the current object.
-
bestEffortsRecovery
boolean bestEffortsRecovery()By default, RocksDB recovery fails if any table file referenced in MANIFEST are missing after scanning the MANIFEST. Best-efforts recovery is another recovery mode that tries to restore the database to the most recent point in time without missing file. Currently not compatible with atomic flush. Furthermore, WAL files will not be used for recovery if best_efforts_recovery is true. Default: false- Returns:
- true, if RocksDB uses best-efforts mode when recovering.
-
setMaxBgErrorResumeCount
It defines how many times db resume is called by a separate thread when background retryable IO Error happens. When background retryable IO Error happens, SetBGError is called to deal with the error. If the error can be auto-recovered (e.g., retryable IO Error during Flush or WAL write), then db resume is called in background to recover from the error. If this value is 0 or negative, db resume will not be called. Default: INT_MAX- Parameters:
maxBgerrorResumeCount- maximum number of times db resume should be called when IO Error happens.- Returns:
- the instance of the current object.
-
maxBgerrorResumeCount
int maxBgerrorResumeCount()It defines how many times db resume is called by a separate thread when background retryable IO Error happens. When background retryable IO Error happens, SetBGError is called to deal with the error. If the error can be auto-recovered (e.g., retryable IO Error during Flush or WAL write), then db resume is called in background to recover from the error. If this value is 0 or negative, db resume will not be called. Default: INT_MAX- Returns:
- maximum number of times db resume should be called when IO Error happens.
-
setBgerrorResumeRetryInterval
If max_bgerror_resume_count is ≥ 2, db resume is called multiple times. This option decides how long to wait to retry the next resume if the previous resume fails and satisfy redo resume conditions. Default: 1000000 (microseconds).- Parameters:
bgerrorResumeRetryInterval- how many microseconds to wait between DB resume attempts.- Returns:
- the instance of the current object.
-
bgerrorResumeRetryInterval
long bgerrorResumeRetryInterval()If max_bgerror_resume_count is ≥ 2, db resume is called multiple times. This option decides how long to wait to retry the next resume if the previous resume fails and satisfy redo resume conditions. Default: 1000000 (microseconds).- Returns:
- the instance of the current object.
-
MutableDBOptionsInterface.setMaxBackgroundJobs(int)