From 6eeee5e60a1a98a959f438332bf84ef24d0b5723 Mon Sep 17 00:00:00 2001 From: Stanislav Tkach Date: Thu, 28 May 2020 09:31:49 +0300 Subject: [PATCH] Add set_max_log_file_size and set_recycle_log_file_num to the Options (#433) --- src/db_options.rs | 57 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/src/db_options.rs b/src/db_options.rs index 9a870ae..a38c4a2 100644 --- a/src/db_options.rs +++ b/src/db_options.rs @@ -1646,6 +1646,17 @@ impl Options { } /// 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) { unsafe { 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); } } + + /// 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 {