Add set_max_log_file_size and set_recycle_log_file_num to the Options (#433)

master
Stanislav Tkach 5 years ago committed by GitHub
parent b5d69fde69
commit 6eeee5e60a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 57
      src/db_options.rs

@ -1646,6 +1646,17 @@ impl Options {
} }
/// Specify the maximal number of info log files to be kept. /// Specify the maximal number of info log files to be kept.
///
/// Default: 1000
///
/// # Examples
///
/// ```
/// use rocksdb::Options;
///
/// let mut options = Options::default();
/// options.set_keep_log_file_num(100);
/// ```
pub fn set_keep_log_file_num(&mut self, nfiles: usize) { pub fn set_keep_log_file_num(&mut self, nfiles: usize) {
unsafe { unsafe {
ffi::rocksdb_options_set_keep_log_file_num(self.inner, nfiles); ffi::rocksdb_options_set_keep_log_file_num(self.inner, nfiles);
@ -1739,6 +1750,52 @@ impl Options {
ffi::rocksdb_options_set_ratelimiter(self.inner, ratelimiter); ffi::rocksdb_options_set_ratelimiter(self.inner, ratelimiter);
} }
} }
/// Sets the maximal size of the info log file.
///
/// If the log file is larger than `max_log_file_size`, a new info log file
/// will be created. If `max_log_file_size` is equal to zero, all logs will
/// be written to one log file.
///
/// Default: 0
///
/// # Examples
///
/// ```
/// use rocksdb::Options;
///
/// let mut options = Options::default();
/// options.set_max_log_file_size(0);
/// ```
pub fn set_max_log_file_size(&mut self, size: usize) {
unsafe {
ffi::rocksdb_options_set_max_log_file_size(self.inner, size);
}
}
/// Controls the recycling of log files.
///
/// If non-zero, previously written log files will be reused 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
///
/// # Examples
///
/// ```
/// use rocksdb::Options;
///
/// let mut options = Options::default();
/// options.set_recycle_log_file_num(5);
/// ```
pub fn set_recycle_log_file_num(&mut self, num: usize) {
unsafe {
ffi::rocksdb_options_set_recycle_log_file_num(self.inner, num);
}
}
} }
impl Default for Options { impl Default for Options {

Loading…
Cancel
Save