1 // Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
2 // This source code is licensed under both the GPLv2 (found in the
3 // COPYING file in the root directory) and Apache 2.0 License
4 // (found in the LICENSE.Apache file in the root directory).
8 import java
.util
.Collection
;
11 public interface DBOptionsInterface
<T
extends DBOptionsInterface
<T
>> {
13 * Use this if your DB is very small (like under 1GB) and you don't want to
14 * spend lots of memory for memtables.
16 * @return the instance of the current object.
18 T
optimizeForSmallDb();
21 * Use the specified object to interact with the environment,
22 * e.g. to read/write files, schedule background work, etc.
23 * Default: {@link Env#getDefault()}
25 * @param env {@link Env} instance.
26 * @return the instance of the current Options.
28 T
setEnv(final Env env
);
31 * Returns the set RocksEnv instance.
33 * @return {@link RocksEnv} instance set in the options.
38 * <p>By default, RocksDB uses only one background thread for flush and
39 * compaction. Calling this function will set it up such that total of
40 * `total_threads` is used.</p>
42 * <p>You almost definitely want to call this function if your system is
43 * bottlenecked by RocksDB.</p>
45 * @param totalThreads The total number of threads to be used by RocksDB.
46 * A good value is the number of cores.
48 * @return the instance of the current Options
50 T
setIncreaseParallelism(int totalThreads
);
53 * If this value is set to true, then the database will be created
54 * if it is missing during {@code RocksDB.open()}.
57 * @param flag a flag indicating whether to create a database the
58 * specified database in {@link RocksDB#open(org.rocksdb.Options, String)} operation
60 * @return the instance of the current Options
61 * @see RocksDB#open(org.rocksdb.Options, String)
63 T
setCreateIfMissing(boolean flag
);
66 * Return true if the create_if_missing flag is set to true.
67 * If true, the database will be created if it is missing.
69 * @return true if the createIfMissing option is set to true.
70 * @see #setCreateIfMissing(boolean)
72 boolean createIfMissing();
75 * <p>If true, missing column families will be automatically created</p>
77 * <p>Default: false</p>
79 * @param flag a flag indicating if missing column families shall be
80 * created automatically.
81 * @return true if missing column families shall be created automatically
84 T
setCreateMissingColumnFamilies(boolean flag
);
87 * Return true if the create_missing_column_families flag is set
88 * to true. If true column families be created if missing.
90 * @return true if the createMissingColumnFamilies is set to
92 * @see #setCreateMissingColumnFamilies(boolean)
94 boolean createMissingColumnFamilies();
97 * If true, an error will be thrown during RocksDB.open() if the
98 * database already exists.
101 * @param errorIfExists if true, an exception will be thrown
102 * during {@code RocksDB.open()} if the database already exists.
103 * @return the reference to the current option.
104 * @see RocksDB#open(org.rocksdb.Options, String)
106 T
setErrorIfExists(boolean errorIfExists
);
109 * If true, an error will be thrown during RocksDB.open() if the
110 * database already exists.
112 * @return if true, an error is raised when the specified database
113 * already exists before open.
115 boolean errorIfExists();
118 * If true, the implementation will do aggressive checking of the
119 * data it is processing and will stop early if it detects any
120 * errors. This may have unforeseen ramifications: for example, a
121 * corruption of one DB entry may cause a large number of entries to
122 * become unreadable or for the entire DB to become unopenable.
123 * If any of the writes to the database fails (Put, Delete, Merge, Write),
124 * the database will switch to read-only mode and fail all other
128 * @param paranoidChecks a flag to indicate whether paranoid-check
130 * @return the reference to the current option.
132 T
setParanoidChecks(boolean paranoidChecks
);
135 * If true, the implementation will do aggressive checking of the
136 * data it is processing and will stop early if it detects any
137 * errors. This may have unforeseen ramifications: for example, a
138 * corruption of one DB entry may cause a large number of entries to
139 * become unreadable or for the entire DB to become unopenable.
140 * If any of the writes to the database fails (Put, Delete, Merge, Write),
141 * the database will switch to read-only mode and fail all other
144 * @return a boolean indicating whether paranoid-check is on.
146 boolean paranoidChecks();
149 * Use to control write rate of flush and compaction. Flush has higher
150 * priority than compaction. Rate limiting is disabled if nullptr.
153 * @param rateLimiter {@link org.rocksdb.RateLimiter} instance.
154 * @return the instance of the current object.
158 T
setRateLimiter(RateLimiter rateLimiter
);
161 * Use to track SST files and control their file deletion rate.
164 * - Throttle the deletion rate of the SST files.
165 * - Keep track the total size of all SST files.
166 * - Set a maximum allowed space limit for SST files that when reached
167 * the DB wont do any further flushes or compactions and will set the
169 * - Can be shared between multiple dbs.
172 * - Only track and throttle deletes of SST files in
173 * first db_path (db_name if db_paths is empty).
175 * @param sstFileManager The SST File Manager for the db.
176 * @return the instance of the current object.
178 T
setSstFileManager(SstFileManager sstFileManager
);
181 * <p>Any internal progress/error information generated by
182 * the db will be written to the Logger if it is non-nullptr,
183 * or to a file stored in the same directory as the DB
184 * contents if info_log is nullptr.</p>
186 * <p>Default: nullptr</p>
188 * @param logger {@link Logger} instance.
189 * @return the instance of the current object.
191 T
setLogger(Logger logger
);
194 * <p>Sets the RocksDB log level. Default level is INFO</p>
196 * @param infoLogLevel log level to set.
197 * @return the instance of the current object.
199 T
setInfoLogLevel(InfoLogLevel infoLogLevel
);
202 * <p>Returns currently set log level.</p>
203 * @return {@link org.rocksdb.InfoLogLevel} instance.
205 InfoLogLevel
infoLogLevel();
208 * If {@link MutableDBOptionsInterface#maxOpenFiles()} is -1, DB will open
209 * all files on DB::Open(). You can use this option to increase the number
210 * of threads used to open the files.
214 * @param maxFileOpeningThreads the maximum number of threads to use to
217 * @return the reference to the current options.
219 T
setMaxFileOpeningThreads(int maxFileOpeningThreads
);
222 * If {@link MutableDBOptionsInterface#maxOpenFiles()} is -1, DB will open all
223 * files on DB::Open(). You can use this option to increase the number of
224 * threads used to open the files.
228 * @return the maximum number of threads to use to open files
230 int maxFileOpeningThreads();
233 * <p>Sets the statistics object which collects metrics about database operations.
234 * Statistics objects should not be shared between DB instances as
235 * it does not use any locks to prevent concurrent updates.</p>
237 * @param statistics The statistics to set
239 * @return the instance of the current object.
241 * @see RocksDB#open(org.rocksdb.Options, String)
243 T
setStatistics(final Statistics statistics
);
246 * <p>Returns statistics object.</p>
248 * @return the instance of the statistics object or null if there is no
251 * @see #setStatistics(Statistics)
253 Statistics
statistics();
256 * <p>If true, then every store to stable storage will issue a fsync.</p>
257 * <p>If false, then every store to stable storage will issue a fdatasync.
258 * This parameter should be set to true while storing data to
259 * filesystem like ext3 that can lose files after a reboot.</p>
260 * <p>Default: false</p>
262 * @param useFsync a boolean flag to specify whether to use fsync
263 * @return the instance of the current object.
265 T
setUseFsync(boolean useFsync
);
268 * <p>If true, then every store to stable storage will issue a fsync.</p>
269 * <p>If false, then every store to stable storage will issue a fdatasync.
270 * This parameter should be set to true while storing data to
271 * filesystem like ext3 that can lose files after a reboot.</p>
273 * @return boolean value indicating if fsync is used.
278 * A list of paths where SST files can be put into, with its target size.
279 * Newer data is placed into paths specified earlier in the vector while
280 * older data gradually moves to paths specified later in the vector.
282 * For example, you have a flash device with 10GB allocated for the DB,
283 * as well as a hard drive of 2TB, you should config it to be:
284 * [{"/flash_path", 10GB}, {"/hard_drive", 2TB}]
286 * The system will try to guarantee data under each path is close to but
287 * not larger than the target size. But current and future file sizes used
288 * by determining where to place a file are based on best-effort estimation,
289 * which means there is a chance that the actual size under the directory
290 * is slightly more than target size under some workloads. User should give
291 * some buffer room for those cases.
293 * If none of the paths has sufficient room to place a file, the file will
294 * be placed to the last path anyway, despite to the target size.
296 * Placing newer data to earlier paths is also best-efforts. User should
297 * expect user files to be placed in higher levels in some extreme cases.
299 * If left empty, only one path will be used, which is db_name passed when
304 * @param dbPaths the paths and target sizes
306 * @return the reference to the current options
308 T
setDbPaths(final Collection
<DbPath
> dbPaths
);
311 * A list of paths where SST files can be put into, with its target size.
312 * Newer data is placed into paths specified earlier in the vector while
313 * older data gradually moves to paths specified later in the vector.
315 * For example, you have a flash device with 10GB allocated for the DB,
316 * as well as a hard drive of 2TB, you should config it to be:
317 * [{"/flash_path", 10GB}, {"/hard_drive", 2TB}]
319 * The system will try to guarantee data under each path is close to but
320 * not larger than the target size. But current and future file sizes used
321 * by determining where to place a file are based on best-effort estimation,
322 * which means there is a chance that the actual size under the directory
323 * is slightly more than target size under some workloads. User should give
324 * some buffer room for those cases.
326 * If none of the paths has sufficient room to place a file, the file will
327 * be placed to the last path anyway, despite to the target size.
329 * Placing newer data to earlier paths is also best-efforts. User should
330 * expect user files to be placed in higher levels in some extreme cases.
332 * If left empty, only one path will be used, which is db_name passed when
335 * Default: {@link java.util.Collections#emptyList()}
337 * @return dbPaths the paths and target sizes
339 List
<DbPath
> dbPaths();
342 * This specifies the info LOG dir.
343 * If it is empty, the log files will be in the same dir as data.
344 * If it is non empty, the log files will be in the specified dir,
345 * and the db data dir's absolute path will be used as the log file
348 * @param dbLogDir the path to the info log directory
349 * @return the instance of the current object.
351 T
setDbLogDir(String dbLogDir
);
354 * Returns the directory of info log.
356 * If it is empty, the log files will be in the same dir as data.
357 * If it is non empty, the log files will be in the specified dir,
358 * and the db data dir's absolute path will be used as the log file
361 * @return the path to the info log directory
366 * This specifies the absolute dir path for write-ahead logs (WAL).
367 * If it is empty, the log files will be in the same dir as data,
368 * dbname is used as the data dir by default
369 * If it is non empty, the log files will be in kept the specified dir.
370 * When destroying the db,
371 * all log files in wal_dir and the dir itself is deleted
373 * @param walDir the path to the write-ahead-log directory.
374 * @return the instance of the current object.
376 T
setWalDir(String walDir
);
379 * Returns the path to the write-ahead-logs (WAL) directory.
381 * If it is empty, the log files will be in the same dir as data,
382 * dbname is used as the data dir by default
383 * If it is non empty, the log files will be in kept the specified dir.
384 * When destroying the db,
385 * all log files in wal_dir and the dir itself is deleted
387 * @return the path to the write-ahead-logs (WAL) directory.
392 * The periodicity when obsolete files get deleted. The default
393 * value is 6 hours. The files that get out of scope by compaction
394 * process will still get automatically delete on every compaction,
395 * regardless of this setting
397 * @param micros the time interval in micros
398 * @return the instance of the current object.
400 T
setDeleteObsoleteFilesPeriodMicros(long micros
);
403 * The periodicity when obsolete files get deleted. The default
404 * value is 6 hours. The files that get out of scope by compaction
405 * process will still get automatically delete on every compaction,
406 * regardless of this setting
408 * @return the time interval in micros when obsolete files will be deleted.
410 long deleteObsoleteFilesPeriodMicros();
413 * This value represents the maximum number of threads that will
414 * concurrently perform a compaction job by breaking it into multiple,
415 * smaller ones that are run simultaneously.
416 * Default: 1 (i.e. no subcompactions)
418 * @param maxSubcompactions The maximum number of threads that will
419 * concurrently perform a compaction job
421 * @return the instance of the current object.
423 T
setMaxSubcompactions(int maxSubcompactions
);
426 * This value represents the maximum number of threads that will
427 * concurrently perform a compaction job by breaking it into multiple,
428 * smaller ones that are run simultaneously.
429 * Default: 1 (i.e. no subcompactions)
431 * @return The maximum number of threads that will concurrently perform a
434 int maxSubcompactions();
437 * NOT SUPPORTED ANYMORE: RocksDB automatically decides this based on the
438 * value of max_background_jobs. For backwards compatibility we will set
439 * `max_background_jobs = max_background_compactions + max_background_flushes`
440 * in the case where user sets at least one of `max_background_compactions` or
441 * `max_background_flushes`.
443 * Specifies the maximum number of concurrent background flush jobs.
444 * If you're increasing this, also consider increasing number of threads in
445 * HIGH priority thread pool. For more information, see
448 * @param maxBackgroundFlushes number of max concurrent flush jobs
449 * @return the instance of the current object.
451 * @see RocksEnv#setBackgroundThreads(int)
452 * @see RocksEnv#setBackgroundThreads(int, Priority)
453 * @see MutableDBOptionsInterface#maxBackgroundCompactions()
455 * @deprecated Use {@link MutableDBOptionsInterface#setMaxBackgroundJobs(int)}
458 T
setMaxBackgroundFlushes(int maxBackgroundFlushes
);
461 * NOT SUPPORTED ANYMORE: RocksDB automatically decides this based on the
462 * value of max_background_jobs. For backwards compatibility we will set
463 * `max_background_jobs = max_background_compactions + max_background_flushes`
464 * in the case where user sets at least one of `max_background_compactions` or
465 * `max_background_flushes`.
467 * Returns the maximum number of concurrent background flush jobs.
468 * If you're increasing this, also consider increasing number of threads in
469 * HIGH priority thread pool. For more information, see
472 * @return the maximum number of concurrent background flush jobs.
473 * @see RocksEnv#setBackgroundThreads(int)
474 * @see RocksEnv#setBackgroundThreads(int, Priority)
477 int maxBackgroundFlushes();
480 * Specifies the maximum size of a info log file. If the current log file
481 * is larger than `max_log_file_size`, a new info log file will
483 * If 0, all logs will be written to one log file.
485 * @param maxLogFileSize the maximum size of a info log file.
486 * @return the instance of the current object.
487 * @throws java.lang.IllegalArgumentException thrown on 32-Bit platforms
488 * while overflowing the underlying platform specific value.
490 T
setMaxLogFileSize(long maxLogFileSize
);
493 * Returns the maximum size of a info log file. If the current log file
494 * is larger than this size, a new info log file will be created.
495 * If 0, all logs will be written to one log file.
497 * @return the maximum size of the info log file.
499 long maxLogFileSize();
502 * Specifies the time interval for the info log file to roll (in seconds).
503 * If specified with non-zero value, log file will be rolled
504 * if it has been active longer than `log_file_time_to_roll`.
505 * Default: 0 (disabled)
507 * @param logFileTimeToRoll the time interval in seconds.
508 * @return the instance of the current object.
509 * @throws java.lang.IllegalArgumentException thrown on 32-Bit platforms
510 * while overflowing the underlying platform specific value.
512 T
setLogFileTimeToRoll(long logFileTimeToRoll
);
515 * Returns the time interval for the info log file to roll (in seconds).
516 * If specified with non-zero value, log file will be rolled
517 * if it has been active longer than `log_file_time_to_roll`.
518 * Default: 0 (disabled)
520 * @return the time interval in seconds.
522 long logFileTimeToRoll();
525 * Specifies the maximum number of info log files to be kept.
528 * @param keepLogFileNum the maximum number of info log files to be kept.
529 * @return the instance of the current object.
530 * @throws java.lang.IllegalArgumentException thrown on 32-Bit platforms
531 * while overflowing the underlying platform specific value.
533 T
setKeepLogFileNum(long keepLogFileNum
);
536 * Returns the maximum number of info log files to be kept.
539 * @return the maximum number of info log files to be kept.
541 long keepLogFileNum();
546 * If non-zero, we will reuse previously written log files for new
547 * logs, overwriting the old data. The value indicates how many
548 * such files we will keep around at any point in time for later
551 * This is more efficient because the blocks are already
552 * allocated and fdatasync does not need to update the inode after
557 * @param recycleLogFileNum the number of log files to keep for recycling
559 * @return the reference to the current options
561 T
setRecycleLogFileNum(long recycleLogFileNum
);
566 * If non-zero, we will reuse previously written log files for new
567 * logs, overwriting the old data. The value indicates how many
568 * such files we will keep around at any point in time for later
571 * This is more efficient because the blocks are already
572 * allocated and fdatasync does not need to update the inode after
577 * @return the number of log files kept for recycling
579 long recycleLogFileNum();
582 * Manifest file is rolled over on reaching this limit.
583 * The older manifest file be deleted.
584 * The default value is 1GB so that the manifest file can grow, but not
585 * reach the limit of storage capacity.
587 * @param maxManifestFileSize the size limit of a manifest file.
588 * @return the instance of the current object.
590 T
setMaxManifestFileSize(long maxManifestFileSize
);
593 * Manifest file is rolled over on reaching this limit.
594 * The older manifest file be deleted.
595 * The default value is 1GB so that the manifest file can grow, but not
596 * reach the limit of storage capacity.
598 * @return the size limit of a manifest file.
600 long maxManifestFileSize();
603 * Number of shards used for table cache.
605 * @param tableCacheNumshardbits the number of chards
606 * @return the instance of the current object.
608 T
setTableCacheNumshardbits(int tableCacheNumshardbits
);
611 * Number of shards used for table cache.
613 * @return the number of shards used for table cache.
615 int tableCacheNumshardbits();
618 * {@link #walTtlSeconds()} and {@link #walSizeLimitMB()} affect how archived logs
621 * <li>If both set to 0, logs will be deleted asap and will not get into
623 * <li>If WAL_ttl_seconds is 0 and WAL_size_limit_MB is not 0,
624 * WAL files will be checked every 10 min and if total size is greater
625 * then WAL_size_limit_MB, they will be deleted starting with the
626 * earliest until size_limit is met. All empty files will be deleted.</li>
627 * <li>If WAL_ttl_seconds is not 0 and WAL_size_limit_MB is 0, then
628 * WAL files will be checked every WAL_ttl_secondsi / 2 and those that
629 * are older than WAL_ttl_seconds will be deleted.</li>
630 * <li>If both are not 0, WAL files will be checked every 10 min and both
631 * checks will be performed with ttl being first.</li>
634 * @param walTtlSeconds the ttl seconds
635 * @return the instance of the current object.
636 * @see #setWalSizeLimitMB(long)
638 T
setWalTtlSeconds(long walTtlSeconds
);
641 * WalTtlSeconds() and walSizeLimitMB() affect how archived logs
644 * <li>If both set to 0, logs will be deleted asap and will not get into
646 * <li>If WAL_ttl_seconds is 0 and WAL_size_limit_MB is not 0,
647 * WAL files will be checked every 10 min and if total size is greater
648 * then WAL_size_limit_MB, they will be deleted starting with the
649 * earliest until size_limit is met. All empty files will be deleted.</li>
650 * <li>If WAL_ttl_seconds is not 0 and WAL_size_limit_MB is 0, then
651 * WAL files will be checked every WAL_ttl_secondsi / 2 and those that
652 * are older than WAL_ttl_seconds will be deleted.</li>
653 * <li>If both are not 0, WAL files will be checked every 10 min and both
654 * checks will be performed with ttl being first.</li>
657 * @return the wal-ttl seconds
658 * @see #walSizeLimitMB()
660 long walTtlSeconds();
663 * WalTtlSeconds() and walSizeLimitMB() affect how archived logs
666 * <li>If both set to 0, logs will be deleted asap and will not get into
668 * <li>If WAL_ttl_seconds is 0 and WAL_size_limit_MB is not 0,
669 * WAL files will be checked every 10 min and if total size is greater
670 * then WAL_size_limit_MB, they will be deleted starting with the
671 * earliest until size_limit is met. All empty files will be deleted.</li>
672 * <li>If WAL_ttl_seconds is not 0 and WAL_size_limit_MB is 0, then
673 * WAL files will be checked every WAL_ttl_secondsi / 2 and those that
674 * are older than WAL_ttl_seconds will be deleted.</li>
675 * <li>If both are not 0, WAL files will be checked every 10 min and both
676 * checks will be performed with ttl being first.</li>
679 * @param sizeLimitMB size limit in mega-bytes.
680 * @return the instance of the current object.
681 * @see #setWalSizeLimitMB(long)
683 T
setWalSizeLimitMB(long sizeLimitMB
);
686 * {@link #walTtlSeconds()} and {@code #walSizeLimitMB()} affect how archived logs
689 * <li>If both set to 0, logs will be deleted asap and will not get into
691 * <li>If WAL_ttl_seconds is 0 and WAL_size_limit_MB is not 0,
692 * WAL files will be checked every 10 min and if total size is greater
693 * then WAL_size_limit_MB, they will be deleted starting with the
694 * earliest until size_limit is met. All empty files will be deleted.</li>
695 * <li>If WAL_ttl_seconds is not 0 and WAL_size_limit_MB is 0, then
696 * WAL files will be checked every WAL_ttl_seconds i / 2 and those that
697 * are older than WAL_ttl_seconds will be deleted.</li>
698 * <li>If both are not 0, WAL files will be checked every 10 min and both
699 * checks will be performed with ttl being first.</li>
701 * @return size limit in mega-bytes.
702 * @see #walSizeLimitMB()
704 long walSizeLimitMB();
707 * The maximum limit of number of bytes that are written in a single batch
708 * of WAL or memtable write. It is followed when the leader write size
709 * is larger than 1/8 of this limit.
713 * @param maxWriteBatchGroupSizeBytes the maximum limit of number of bytes, see description.
714 * @return the instance of the current object.
716 T
setMaxWriteBatchGroupSizeBytes(final long maxWriteBatchGroupSizeBytes
);
719 * The maximum limit of number of bytes that are written in a single batch
720 * of WAL or memtable write. It is followed when the leader write size
721 * is larger than 1/8 of this limit.
725 * @return the maximum limit of number of bytes, see description.
727 long maxWriteBatchGroupSizeBytes();
730 * Number of bytes to preallocate (via fallocate) the manifest
731 * files. Default is 4mb, which is reasonable to reduce random IO
732 * as well as prevent overallocation for mounts that preallocate
733 * large amounts of data (such as xfs's allocsize option).
735 * @param size the size in byte
736 * @return the instance of the current object.
737 * @throws java.lang.IllegalArgumentException thrown on 32-Bit platforms
738 * while overflowing the underlying platform specific value.
740 T
setManifestPreallocationSize(long size
);
743 * Number of bytes to preallocate (via fallocate) the manifest
744 * files. Default is 4mb, which is reasonable to reduce random IO
745 * as well as prevent overallocation for mounts that preallocate
746 * large amounts of data (such as xfs's allocsize option).
748 * @return size in bytes.
750 long manifestPreallocationSize();
753 * Enable the OS to use direct I/O for reading sst tables.
756 * @param useDirectReads if true, then direct read is enabled
757 * @return the instance of the current object.
759 T
setUseDirectReads(boolean useDirectReads
);
762 * Enable the OS to use direct I/O for reading sst tables.
765 * @return if true, then direct reads are enabled
767 boolean useDirectReads();
770 * Enable the OS to use direct reads and writes in flush and
774 * @param useDirectIoForFlushAndCompaction if true, then direct
775 * I/O will be enabled for background flush and compactions
776 * @return the instance of the current object.
778 T
setUseDirectIoForFlushAndCompaction(boolean useDirectIoForFlushAndCompaction
);
781 * Enable the OS to use direct reads and writes in flush and
784 * @return if true, then direct I/O is enabled for flush and
787 boolean useDirectIoForFlushAndCompaction();
790 * Whether fallocate calls are allowed
792 * @param allowFAllocate false if fallocate() calls are bypassed
794 * @return the reference to the current options.
796 T
setAllowFAllocate(boolean allowFAllocate
);
799 * Whether fallocate calls are allowed
801 * @return false if fallocate() calls are bypassed
803 boolean allowFAllocate();
806 * Allow the OS to mmap file for reading sst tables.
809 * @param allowMmapReads true if mmap reads are allowed.
810 * @return the instance of the current object.
812 T
setAllowMmapReads(boolean allowMmapReads
);
815 * Allow the OS to mmap file for reading sst tables.
818 * @return true if mmap reads are allowed.
820 boolean allowMmapReads();
823 * Allow the OS to mmap file for writing. Default: false
825 * @param allowMmapWrites true if mmap writes are allowd.
826 * @return the instance of the current object.
828 T
setAllowMmapWrites(boolean allowMmapWrites
);
831 * Allow the OS to mmap file for writing. Default: false
833 * @return true if mmap writes are allowed.
835 boolean allowMmapWrites();
838 * Disable child process inherit open files. Default: true
840 * @param isFdCloseOnExec true if child process inheriting open
842 * @return the instance of the current object.
844 T
setIsFdCloseOnExec(boolean isFdCloseOnExec
);
847 * Disable child process inherit open files. Default: true
849 * @return true if child process inheriting open files is disabled.
851 boolean isFdCloseOnExec();
854 * If set true, will hint the underlying file system that the file
855 * access pattern is random, when a sst file is opened.
858 * @param adviseRandomOnOpen true if hinting random access is on.
859 * @return the instance of the current object.
861 T
setAdviseRandomOnOpen(boolean adviseRandomOnOpen
);
864 * If set true, will hint the underlying file system that the file
865 * access pattern is random, when a sst file is opened.
868 * @return true if hinting random access is on.
870 boolean adviseRandomOnOpen();
873 * Amount of data to build up in memtables across all column
874 * families before writing to disk.
876 * This is distinct from {@link ColumnFamilyOptions#writeBufferSize()},
877 * which enforces a limit for a single memtable.
879 * This feature is disabled by default. Specify a non-zero value
882 * Default: 0 (disabled)
884 * @param dbWriteBufferSize the size of the write buffer
886 * @return the reference to the current options.
888 T
setDbWriteBufferSize(long dbWriteBufferSize
);
891 * Use passed {@link WriteBufferManager} to control memory usage across
892 * multiple column families and/or DB instances.
894 * Check <a href="https://github.com/facebook/rocksdb/wiki/Write-Buffer-Manager">
895 * https://github.com/facebook/rocksdb/wiki/Write-Buffer-Manager</a>
896 * for more details on when to use it
898 * @param writeBufferManager The WriteBufferManager to use
899 * @return the reference of the current options.
901 T
setWriteBufferManager(final WriteBufferManager writeBufferManager
);
904 * Reference to {@link WriteBufferManager} used by it. <br>
906 * Default: null (Disabled)
908 * @return a reference to WriteBufferManager
910 WriteBufferManager
writeBufferManager();
913 * Amount of data to build up in memtables across all column
914 * families before writing to disk.
916 * This is distinct from {@link ColumnFamilyOptions#writeBufferSize()},
917 * which enforces a limit for a single memtable.
919 * This feature is disabled by default. Specify a non-zero value
922 * Default: 0 (disabled)
924 * @return the size of the write buffer
926 long dbWriteBufferSize();
929 * Specify the file access pattern once a compaction is started.
930 * It will be applied to all input files of a compaction.
932 * Default: {@link AccessHint#NORMAL}
934 * @param accessHint The access hint
936 * @return the reference to the current options.
938 T
setAccessHintOnCompactionStart(final AccessHint accessHint
);
941 * Specify the file access pattern once a compaction is started.
942 * It will be applied to all input files of a compaction.
944 * Default: {@link AccessHint#NORMAL}
946 * @return The access hint
948 AccessHint
accessHintOnCompactionStart();
951 * If true, always create a new file descriptor and new table reader
952 * for compaction inputs. Turn this parameter on may introduce extra
953 * memory usage in the table reader, if it allocates extra memory
954 * for indexes. This will allow file descriptor prefetch options
955 * to be set for compaction input files and not to impact file
956 * descriptors for the same file used by user queries.
957 * Suggest to enable {@link BlockBasedTableConfig#cacheIndexAndFilterBlocks()}
958 * for this mode if using block-based table.
962 * @param newTableReaderForCompactionInputs true if a new file descriptor and
963 * table reader should be created for compaction inputs
965 * @return the reference to the current options.
967 T
setNewTableReaderForCompactionInputs(
968 boolean newTableReaderForCompactionInputs
);
971 * If true, always create a new file descriptor and new table reader
972 * for compaction inputs. Turn this parameter on may introduce extra
973 * memory usage in the table reader, if it allocates extra memory
974 * for indexes. This will allow file descriptor prefetch options
975 * to be set for compaction input files and not to impact file
976 * descriptors for the same file used by user queries.
977 * Suggest to enable {@link BlockBasedTableConfig#cacheIndexAndFilterBlocks()}
978 * for this mode if using block-based table.
982 * @return true if a new file descriptor and table reader are created for
985 boolean newTableReaderForCompactionInputs();
988 * This is a maximum buffer size that is used by WinMmapReadableFile in
989 * unbuffered disk I/O mode. We need to maintain an aligned buffer for
990 * reads. We allow the buffer to grow until the specified value and then
991 * for bigger requests allocate one shot buffers. In unbuffered mode we
992 * always bypass read-ahead buffer at ReadaheadRandomAccessFile
993 * When read-ahead is required we then make use of
994 * {@link MutableDBOptionsInterface#compactionReadaheadSize()} value and
995 * always try to read ahead.
996 * With read-ahead we always pre-allocate buffer to the size instead of
997 * growing it up to a limit.
999 * This option is currently honored only on Windows
1003 * Special value: 0 - means do not maintain per instance buffer. Allocate
1004 * per request buffer and avoid locking.
1006 * @param randomAccessMaxBufferSize the maximum size of the random access
1009 * @return the reference to the current options.
1011 T
setRandomAccessMaxBufferSize(long randomAccessMaxBufferSize
);
1014 * This is a maximum buffer size that is used by WinMmapReadableFile in
1015 * unbuffered disk I/O mode. We need to maintain an aligned buffer for
1016 * reads. We allow the buffer to grow until the specified value and then
1017 * for bigger requests allocate one shot buffers. In unbuffered mode we
1018 * always bypass read-ahead buffer at ReadaheadRandomAccessFile
1019 * When read-ahead is required we then make use of
1020 * {@link MutableDBOptionsInterface#compactionReadaheadSize()} value and
1021 * always try to read ahead. With read-ahead we always pre-allocate buffer
1022 * to the size instead of growing it up to a limit.
1024 * This option is currently honored only on Windows
1028 * Special value: 0 - means do not maintain per instance buffer. Allocate
1029 * per request buffer and avoid locking.
1031 * @return the maximum size of the random access buffer
1033 long randomAccessMaxBufferSize();
1036 * Use adaptive mutex, which spins in the user space before resorting
1037 * to kernel. This could reduce context switch when the mutex is not
1038 * heavily contended. However, if the mutex is hot, we could end up
1039 * wasting spin time.
1042 * @param useAdaptiveMutex true if adaptive mutex is used.
1043 * @return the instance of the current object.
1045 T
setUseAdaptiveMutex(boolean useAdaptiveMutex
);
1048 * Use adaptive mutex, which spins in the user space before resorting
1049 * to kernel. This could reduce context switch when the mutex is not
1050 * heavily contended. However, if the mutex is hot, we could end up
1051 * wasting spin time.
1054 * @return true if adaptive mutex is used.
1056 boolean useAdaptiveMutex();
1059 * Sets the {@link EventListener}s whose callback functions
1060 * will be called when specific RocksDB event happens.
1062 * Note: the RocksJava API currently only supports EventListeners implemented in Java.
1063 * It could be extended in future to also support adding/removing EventListeners implemented in
1066 * @param listeners the listeners who should be notified on various events.
1068 * @return the instance of the current object.
1070 T
setListeners(final List
<AbstractEventListener
> listeners
);
1073 * Sets the {@link EventListener}s whose callback functions
1074 * will be called when specific RocksDB event happens.
1076 * Note: the RocksJava API currently only supports EventListeners implemented in Java.
1077 * It could be extended in future to also support adding/removing EventListeners implemented in
1080 * @return the instance of the current object.
1082 List
<AbstractEventListener
> listeners();
1085 * If true, then the status of the threads involved in this DB will
1086 * be tracked and available via GetThreadList() API.
1090 * @param enableThreadTracking true to enable tracking
1092 * @return the reference to the current options.
1094 T
setEnableThreadTracking(boolean enableThreadTracking
);
1097 * If true, then the status of the threads involved in this DB will
1098 * be tracked and available via GetThreadList() API.
1102 * @return true if tracking is enabled
1104 boolean enableThreadTracking();
1107 * By default, a single write thread queue is maintained. The thread gets
1108 * to the head of the queue becomes write batch group leader and responsible
1109 * for writing to WAL and memtable for the batch group.
1111 * If {@link #enablePipelinedWrite()} is true, separate write thread queue is
1112 * maintained for WAL write and memtable write. A write thread first enter WAL
1113 * writer queue and then memtable writer queue. Pending thread on the WAL
1114 * writer queue thus only have to wait for previous writers to finish their
1115 * WAL writing but not the memtable writing. Enabling the feature may improve
1116 * write throughput and reduce latency of the prepare phase of two-phase
1121 * @param enablePipelinedWrite true to enabled pipelined writes
1123 * @return the reference to the current options.
1125 T
setEnablePipelinedWrite(final boolean enablePipelinedWrite
);
1128 * Returns true if pipelined writes are enabled.
1129 * See {@link #setEnablePipelinedWrite(boolean)}.
1131 * @return true if pipelined writes are enabled, false otherwise.
1133 boolean enablePipelinedWrite();
1136 * Setting {@link #unorderedWrite()} to true trades higher write throughput with
1137 * relaxing the immutability guarantee of snapshots. This violates the
1138 * repeatability one expects from ::Get from a snapshot, as well as
1139 * ::MultiGet and Iterator's consistent-point-in-time view property.
1140 * If the application cannot tolerate the relaxed guarantees, it can implement
1141 * its own mechanisms to work around that and yet benefit from the higher
1142 * throughput. Using TransactionDB with WRITE_PREPARED write policy and
1143 * {@link #twoWriteQueues()} true is one way to achieve immutable snapshots despite
1146 * By default, i.e., when it is false, rocksdb does not advance the sequence
1147 * number for new snapshots unless all the writes with lower sequence numbers
1148 * are already finished. This provides the immutability that we except from
1149 * snapshots. Moreover, since Iterator and MultiGet internally depend on
1150 * snapshots, the snapshot immutability results into Iterator and MultiGet
1151 * offering consistent-point-in-time view. If set to true, although
1152 * Read-Your-Own-Write property is still provided, the snapshot immutability
1153 * property is relaxed: the writes issued after the snapshot is obtained (with
1154 * larger sequence numbers) will be still not visible to the reads from that
1155 * snapshot, however, there still might be pending writes (with lower sequence
1156 * number) that will change the state visible to the snapshot after they are
1157 * landed to the memtable.
1159 * @param unorderedWrite true to enabled unordered write
1161 * @return the reference to the current options.
1163 T
setUnorderedWrite(final boolean unorderedWrite
);
1166 * Returns true if unordered write are enabled.
1167 * See {@link #setUnorderedWrite(boolean)}.
1169 * @return true if unordered write are enabled, false otherwise.
1171 boolean unorderedWrite();
1174 * If true, allow multi-writers to update mem tables in parallel.
1175 * Only some memtable factorys support concurrent writes; currently it
1176 * is implemented only for SkipListFactory. Concurrent memtable writes
1177 * are not compatible with inplace_update_support or filter_deletes.
1178 * It is strongly recommended to set
1179 * {@link #setEnableWriteThreadAdaptiveYield(boolean)} if you are going to use
1183 * @param allowConcurrentMemtableWrite true to enable concurrent writes
1186 * @return the reference to the current options.
1188 T
setAllowConcurrentMemtableWrite(boolean allowConcurrentMemtableWrite
);
1191 * If true, allow multi-writers to update mem tables in parallel.
1192 * Only some memtable factorys support concurrent writes; currently it
1193 * is implemented only for SkipListFactory. Concurrent memtable writes
1194 * are not compatible with inplace_update_support or filter_deletes.
1195 * It is strongly recommended to set
1196 * {@link #setEnableWriteThreadAdaptiveYield(boolean)} if you are going to use
1200 * @return true if concurrent writes are enabled for the memtable
1202 boolean allowConcurrentMemtableWrite();
1205 * If true, threads synchronizing with the write batch group leader will
1206 * wait for up to {@link #writeThreadMaxYieldUsec()} before blocking on a
1207 * mutex. This can substantially improve throughput for concurrent workloads,
1208 * regardless of whether {@link #allowConcurrentMemtableWrite()} is enabled.
1211 * @param enableWriteThreadAdaptiveYield true to enable adaptive yield for the
1214 * @return the reference to the current options.
1216 T
setEnableWriteThreadAdaptiveYield(
1217 boolean enableWriteThreadAdaptiveYield
);
1220 * If true, threads synchronizing with the write batch group leader will
1221 * wait for up to {@link #writeThreadMaxYieldUsec()} before blocking on a
1222 * mutex. This can substantially improve throughput for concurrent workloads,
1223 * regardless of whether {@link #allowConcurrentMemtableWrite()} is enabled.
1226 * @return true if adaptive yield is enabled
1227 * for the writing threads
1229 boolean enableWriteThreadAdaptiveYield();
1232 * The maximum number of microseconds that a write operation will use
1233 * a yielding spin loop to coordinate with other write threads before
1234 * blocking on a mutex. (Assuming {@link #writeThreadSlowYieldUsec()} is
1235 * set properly) increasing this value is likely to increase RocksDB
1236 * throughput at the expense of increased CPU usage.
1239 * @param writeThreadMaxYieldUsec maximum number of microseconds
1241 * @return the reference to the current options.
1243 T
setWriteThreadMaxYieldUsec(long writeThreadMaxYieldUsec
);
1246 * The maximum number of microseconds that a write operation will use
1247 * a yielding spin loop to coordinate with other write threads before
1248 * blocking on a mutex. (Assuming {@link #writeThreadSlowYieldUsec()} is
1249 * set properly) increasing this value is likely to increase RocksDB
1250 * throughput at the expense of increased CPU usage.
1253 * @return the maximum number of microseconds
1255 long writeThreadMaxYieldUsec();
1258 * The latency in microseconds after which a std::this_thread::yield
1259 * call (sched_yield on Linux) is considered to be a signal that
1260 * other processes or threads would like to use the current core.
1261 * Increasing this makes writer threads more likely to take CPU
1262 * by spinning, which will show up as an increase in the number of
1263 * involuntary context switches.
1266 * @param writeThreadSlowYieldUsec the latency in microseconds
1268 * @return the reference to the current options.
1270 T
setWriteThreadSlowYieldUsec(long writeThreadSlowYieldUsec
);
1273 * The latency in microseconds after which a std::this_thread::yield
1274 * call (sched_yield on Linux) is considered to be a signal that
1275 * other processes or threads would like to use the current core.
1276 * Increasing this makes writer threads more likely to take CPU
1277 * by spinning, which will show up as an increase in the number of
1278 * involuntary context switches.
1281 * @return writeThreadSlowYieldUsec the latency in microseconds
1283 long writeThreadSlowYieldUsec();
1286 * If true, then DB::Open() will not update the statistics used to optimize
1287 * compaction decision by loading table properties from many files.
1288 * Turning off this feature will improve DBOpen time especially in
1293 * @param skipStatsUpdateOnDbOpen true if updating stats will be skipped
1295 * @return the reference to the current options.
1297 T
setSkipStatsUpdateOnDbOpen(boolean skipStatsUpdateOnDbOpen
);
1300 * If true, then DB::Open() will not update the statistics used to optimize
1301 * compaction decision by loading table properties from many files.
1302 * Turning off this feature will improve DBOpen time especially in
1307 * @return true if updating stats will be skipped
1309 boolean skipStatsUpdateOnDbOpen();
1312 * If true, then {@link RocksDB#open(String)} will not fetch and check sizes of all sst files.
1313 * This may significantly speed up startup if there are many sst files,
1314 * especially when using non-default Env with expensive GetFileSize().
1315 * We'll still check that all required sst files exist.
1316 * If {@code paranoid_checks} is false, this option is ignored, and sst files are
1317 * not checked at all.
1321 * @param skipCheckingSstFileSizesOnDbOpen if true, then SST file sizes will not be checked
1322 * when calling {@link RocksDB#open(String)}.
1323 * @return the reference to the current options.
1325 T
setSkipCheckingSstFileSizesOnDbOpen(final boolean skipCheckingSstFileSizesOnDbOpen
);
1328 * If true, then {@link RocksDB#open(String)} will not fetch and check sizes of all sst files.
1329 * This may significantly speed up startup if there are many sst files,
1330 * especially when using non-default Env with expensive GetFileSize().
1331 * We'll still check that all required sst files exist.
1332 * If {@code paranoid_checks} is false, this option is ignored, and sst files are
1333 * not checked at all.
1337 * @return true, if file sizes will not be checked when calling {@link RocksDB#open(String)}.
1339 boolean skipCheckingSstFileSizesOnDbOpen();
1342 * Recovery mode to control the consistency while replaying WAL
1344 * Default: {@link WALRecoveryMode#PointInTimeRecovery}
1346 * @param walRecoveryMode The WAL recover mode
1348 * @return the reference to the current options.
1350 T
setWalRecoveryMode(WALRecoveryMode walRecoveryMode
);
1353 * Recovery mode to control the consistency while replaying WAL
1355 * Default: {@link WALRecoveryMode#PointInTimeRecovery}
1357 * @return The WAL recover mode
1359 WALRecoveryMode
walRecoveryMode();
1362 * if set to false then recovery will fail when a prepared
1363 * transaction is encountered in the WAL
1367 * @param allow2pc true if two-phase-commit is enabled
1369 * @return the reference to the current options.
1371 T
setAllow2pc(boolean allow2pc
);
1374 * if set to false then recovery will fail when a prepared
1375 * transaction is encountered in the WAL
1379 * @return true if two-phase-commit is enabled
1384 * A global cache for table-level rows.
1386 * Default: null (disabled)
1388 * @param rowCache The global row cache
1390 * @return the reference to the current options.
1392 T
setRowCache(final Cache rowCache
);
1395 * A global cache for table-level rows.
1397 * Default: null (disabled)
1399 * @return The global row cache
1404 * A filter object supplied to be invoked while processing write-ahead-logs
1405 * (WALs) during recovery. The filter provides a way to inspect log
1406 * records, ignoring a particular record or skipping replay.
1407 * The filter is invoked at startup and is invoked from a single-thread
1410 * @param walFilter the filter for processing WALs during recovery.
1412 * @return the reference to the current options.
1414 T
setWalFilter(final AbstractWalFilter walFilter
);
1417 * Get's the filter for processing WALs during recovery.
1418 * See {@link #setWalFilter(AbstractWalFilter)}.
1420 * @return the filter used for processing WALs during recovery.
1422 WalFilter
walFilter();
1425 * If true, then DB::Open / CreateColumnFamily / DropColumnFamily
1426 * / SetOptions will fail if options file is not detected or properly
1431 * @param failIfOptionsFileError true if we should fail if there is an error
1432 * in the options file
1434 * @return the reference to the current options.
1436 T
setFailIfOptionsFileError(boolean failIfOptionsFileError
);
1439 * If true, then DB::Open / CreateColumnFamily / DropColumnFamily
1440 * / SetOptions will fail if options file is not detected or properly
1445 * @return true if we should fail if there is an error in the options file
1447 boolean failIfOptionsFileError();
1450 * If true, then print malloc stats together with rocksdb.stats
1451 * when printing to LOG.
1455 * @param dumpMallocStats true if malloc stats should be printed to LOG
1457 * @return the reference to the current options.
1459 T
setDumpMallocStats(boolean dumpMallocStats
);
1462 * If true, then print malloc stats together with rocksdb.stats
1463 * when printing to LOG.
1467 * @return true if malloc stats should be printed to LOG
1469 boolean dumpMallocStats();
1472 * By default RocksDB replay WAL logs and flush them on DB open, which may
1473 * create very small SST files. If this option is enabled, RocksDB will try
1474 * to avoid (but not guarantee not to) flush during recovery. Also, existing
1475 * WAL logs will be kept, so that if crash happened before flush, we still
1476 * have logs to recover from.
1480 * @param avoidFlushDuringRecovery true to try to avoid (but not guarantee
1481 * not to) flush during recovery
1483 * @return the reference to the current options.
1485 T
setAvoidFlushDuringRecovery(boolean avoidFlushDuringRecovery
);
1488 * By default RocksDB replay WAL logs and flush them on DB open, which may
1489 * create very small SST files. If this option is enabled, RocksDB will try
1490 * to avoid (but not guarantee not to) flush during recovery. Also, existing
1491 * WAL logs will be kept, so that if crash happened before flush, we still
1492 * have logs to recover from.
1496 * @return true to try to avoid (but not guarantee not to) flush during
1499 boolean avoidFlushDuringRecovery();
1502 * Set this option to true during creation of database if you want
1503 * to be able to ingest behind (call IngestExternalFile() skipping keys
1504 * that already exist, rather than overwriting matching keys).
1505 * Setting this option to true will affect 2 things:
1506 * 1) Disable some internal optimizations around SST file compression
1507 * 2) Reserve bottom-most level for ingested files only.
1508 * 3) Note that num_levels should be >= 3 if this option is turned on.
1512 * @param allowIngestBehind true to allow ingest behind, false to disallow.
1514 * @return the reference to the current options.
1516 T
setAllowIngestBehind(final boolean allowIngestBehind
);
1519 * Returns true if ingest behind is allowed.
1520 * See {@link #setAllowIngestBehind(boolean)}.
1522 * @return true if ingest behind is allowed, false otherwise.
1524 boolean allowIngestBehind();
1527 * Needed to support differential snapshots.
1528 * If set to true then DB will only process deletes with sequence number
1529 * less than what was set by SetPreserveDeletesSequenceNumber(uint64_t ts).
1530 * Clients are responsible to periodically call this method to advance
1531 * the cutoff time. If this method is never called and preserve_deletes
1532 * is set to true NO deletes will ever be processed.
1533 * At the moment this only keeps normal deletes, SingleDeletes will
1538 * @param preserveDeletes true to preserve deletes.
1540 * @return the reference to the current options.
1542 T
setPreserveDeletes(final boolean preserveDeletes
);
1545 * Returns true if deletes are preserved.
1546 * See {@link #setPreserveDeletes(boolean)}.
1548 * @return true if deletes are preserved, false otherwise.
1550 boolean preserveDeletes();
1553 * If enabled it uses two queues for writes, one for the ones with
1554 * disable_memtable and one for the ones that also write to memtable. This
1555 * allows the memtable writes not to lag behind other writes. It can be used
1556 * to optimize MySQL 2PC in which only the commits, which are serial, write to
1561 * @param twoWriteQueues true to enable two write queues, false otherwise.
1563 * @return the reference to the current options.
1565 T
setTwoWriteQueues(final boolean twoWriteQueues
);
1568 * Returns true if two write queues are enabled.
1570 * @return true if two write queues are enabled, false otherwise.
1572 boolean twoWriteQueues();
1575 * If true WAL is not flushed automatically after each write. Instead it
1576 * relies on manual invocation of FlushWAL to write the WAL buffer to its
1581 * @param manualWalFlush true to set disable automatic WAL flushing,
1584 * @return the reference to the current options.
1586 T
setManualWalFlush(final boolean manualWalFlush
);
1589 * Returns true if automatic WAL flushing is disabled.
1590 * See {@link #setManualWalFlush(boolean)}.
1592 * @return true if automatic WAL flushing is disabled, false otherwise.
1594 boolean manualWalFlush();
1597 * If true, RocksDB supports flushing multiple column families and committing
1598 * their results atomically to MANIFEST. Note that it is not
1599 * necessary to set atomic_flush to true if WAL is always enabled since WAL
1600 * allows the database to be restored to the last persistent state in WAL.
1601 * This option is useful when there are column families with writes NOT
1603 * For manual flush, application has to specify which column families to
1604 * flush atomically in {@link RocksDB#flush(FlushOptions, List)}.
1605 * For auto-triggered flush, RocksDB atomically flushes ALL column families.
1607 * Currently, any WAL-enabled writes after atomic flush may be replayed
1608 * independently if the process crashes later and tries to recover.
1610 * @param atomicFlush true to enable atomic flush of multiple column families.
1612 * @return the reference to the current options.
1614 T
setAtomicFlush(final boolean atomicFlush
);
1617 * Determine if atomic flush of multiple column families is enabled.
1619 * See {@link #setAtomicFlush(boolean)}.
1621 * @return true if atomic flush is enabled.
1623 boolean atomicFlush();
1626 * If true, working thread may avoid doing unnecessary and long-latency
1627 * operation (such as deleting obsolete files directly or deleting memtable)
1628 * and will instead schedule a background job to do it.
1629 * Use it if you're latency-sensitive.
1630 * If set to true, takes precedence over
1631 * {@link ReadOptions#setBackgroundPurgeOnIteratorCleanup(boolean)}.
1633 * @param avoidUnnecessaryBlockingIO If true, working thread may avoid doing unnecessary
1635 * @return the reference to the current options.
1637 T
setAvoidUnnecessaryBlockingIO(final boolean avoidUnnecessaryBlockingIO
);
1640 * If true, working thread may avoid doing unnecessary and long-latency
1641 * operation (such as deleting obsolete files directly or deleting memtable)
1642 * and will instead schedule a background job to do it.
1643 * Use it if you're latency-sensitive.
1644 * If set to true, takes precedence over
1645 * {@link ReadOptions#setBackgroundPurgeOnIteratorCleanup(boolean)}.
1647 * @return true, if working thread may avoid doing unnecessary operation.
1649 boolean avoidUnnecessaryBlockingIO();
1652 * If true, automatically persist stats to a hidden column family (column
1653 * family name: ___rocksdb_stats_history___) every
1654 * stats_persist_period_sec seconds; otherwise, write to an in-memory
1655 * struct. User can query through `GetStatsHistory` API.
1656 * If user attempts to create a column family with the same name on a DB
1657 * which have previously set persist_stats_to_disk to true, the column family
1658 * creation will fail, but the hidden column family will survive, as well as
1659 * the previously persisted statistics.
1660 * When peristing stats to disk, the stat name will be limited at 100 bytes.
1663 * @param persistStatsToDisk true if stats should be persisted to hidden column family.
1664 * @return the instance of the current object.
1666 T
setPersistStatsToDisk(final boolean persistStatsToDisk
);
1669 * If true, automatically persist stats to a hidden column family (column
1670 * family name: ___rocksdb_stats_history___) every
1671 * stats_persist_period_sec seconds; otherwise, write to an in-memory
1672 * struct. User can query through `GetStatsHistory` API.
1673 * If user attempts to create a column family with the same name on a DB
1674 * which have previously set persist_stats_to_disk to true, the column family
1675 * creation will fail, but the hidden column family will survive, as well as
1676 * the previously persisted statistics.
1677 * When peristing stats to disk, the stat name will be limited at 100 bytes.
1680 * @return true if stats should be persisted to hidden column family.
1682 boolean persistStatsToDisk();
1685 * Historically DB ID has always been stored in Identity File in DB folder.
1686 * If this flag is true, the DB ID is written to Manifest file in addition
1687 * to the Identity file. By doing this 2 problems are solved
1688 * 1. We don't checksum the Identity file where as Manifest file is.
1689 * 2. Since the source of truth for DB is Manifest file DB ID will sit with
1690 * the source of truth. Previously the Identity file could be copied
1691 * independent of Manifest and that can result in wrong DB ID.
1692 * We recommend setting this flag to true.
1695 * @param writeDbidToManifest if true, then DB ID will be written to Manifest file.
1696 * @return the instance of the current object.
1698 T
setWriteDbidToManifest(final boolean writeDbidToManifest
);
1701 * Historically DB ID has always been stored in Identity File in DB folder.
1702 * If this flag is true, the DB ID is written to Manifest file in addition
1703 * to the Identity file. By doing this 2 problems are solved
1704 * 1. We don't checksum the Identity file where as Manifest file is.
1705 * 2. Since the source of truth for DB is Manifest file DB ID will sit with
1706 * the source of truth. Previously the Identity file could be copied
1707 * independent of Manifest and that can result in wrong DB ID.
1708 * We recommend setting this flag to true.
1711 * @return true, if DB ID will be written to Manifest file.
1713 boolean writeDbidToManifest();
1716 * The number of bytes to prefetch when reading the log. This is mostly useful
1717 * for reading a remotely located log, as it can save the number of
1718 * round-trips. If 0, then the prefetching is disabled.
1722 * @param logReadaheadSize the number of bytes to prefetch when reading the log.
1723 * @return the instance of the current object.
1725 T
setLogReadaheadSize(final long logReadaheadSize
);
1728 * The number of bytes to prefetch when reading the log. This is mostly useful
1729 * for reading a remotely located log, as it can save the number of
1730 * round-trips. If 0, then the prefetching is disabled.
1734 * @return the number of bytes to prefetch when reading the log.
1736 long logReadaheadSize();
1739 * By default, RocksDB recovery fails if any table file referenced in
1740 * MANIFEST are missing after scanning the MANIFEST.
1741 * Best-efforts recovery is another recovery mode that
1742 * tries to restore the database to the most recent point in time without
1744 * Currently not compatible with atomic flush. Furthermore, WAL files will
1745 * not be used for recovery if best_efforts_recovery is true.
1748 * @param bestEffortsRecovery if true, RocksDB will use best-efforts mode when recovering.
1749 * @return the instance of the current object.
1751 T
setBestEffortsRecovery(final boolean bestEffortsRecovery
);
1754 * By default, RocksDB recovery fails if any table file referenced in
1755 * MANIFEST are missing after scanning the MANIFEST.
1756 * Best-efforts recovery is another recovery mode that
1757 * tries to restore the database to the most recent point in time without
1759 * Currently not compatible with atomic flush. Furthermore, WAL files will
1760 * not be used for recovery if best_efforts_recovery is true.
1763 * @return true, if RocksDB uses best-efforts mode when recovering.
1765 boolean bestEffortsRecovery();
1768 * It defines how many times db resume is called by a separate thread when
1769 * background retryable IO Error happens. When background retryable IO
1770 * Error happens, SetBGError is called to deal with the error. If the error
1771 * can be auto-recovered (e.g., retryable IO Error during Flush or WAL write),
1772 * then db resume is called in background to recover from the error. If this
1773 * value is 0 or negative, db resume will not be called.
1777 * @param maxBgerrorResumeCount maximum number of times db resume should be called when IO Error
1779 * @return the instance of the current object.
1781 T
setMaxBgErrorResumeCount(final int maxBgerrorResumeCount
);
1784 * It defines how many times db resume is called by a separate thread when
1785 * background retryable IO Error happens. When background retryable IO
1786 * Error happens, SetBGError is called to deal with the error. If the error
1787 * can be auto-recovered (e.g., retryable IO Error during Flush or WAL write),
1788 * then db resume is called in background to recover from the error. If this
1789 * value is 0 or negative, db resume will not be called.
1793 * @return maximum number of times db resume should be called when IO Error happens.
1795 int maxBgerrorResumeCount();
1798 * If max_bgerror_resume_count is ≥ 2, db resume is called multiple times.
1799 * This option decides how long to wait to retry the next resume if the
1800 * previous resume fails and satisfy redo resume conditions.
1802 * Default: 1000000 (microseconds).
1804 * @param bgerrorResumeRetryInterval how many microseconds to wait between DB resume attempts.
1805 * @return the instance of the current object.
1807 T
setBgerrorResumeRetryInterval(final long bgerrorResumeRetryInterval
);
1810 * If max_bgerror_resume_count is ≥ 2, db resume is called multiple times.
1811 * This option decides how long to wait to retry the next resume if the
1812 * previous resume fails and satisfy redo resume conditions.
1814 * Default: 1000000 (microseconds).
1816 * @return the instance of the current object.
1818 long bgerrorResumeRetryInterval();