From 9f74dbcdb11e387ef7b101b4fe5b88b1634a04a0 Mon Sep 17 00:00:00 2001 From: Oleksandr Anyshchenko Date: Mon, 18 Mar 2019 10:01:31 +0200 Subject: [PATCH] Added a possibility to enable mmap files for reads and writes --- src/db_options.rs | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/db_options.rs b/src/db_options.rs index 64d0b15..61cf241 100644 --- a/src/db_options.rs +++ b/src/db_options.rs @@ -1158,6 +1158,42 @@ impl Options { ffi::rocksdb_options_set_keep_log_file_num(self.inner, nfiles); } } + + /// Allow the OS to mmap file for writing. + /// + /// Default: false + /// + /// # Example + /// + /// ``` + /// use rocksdb::Options; + /// + /// let mut options = Options::default(); + /// options.set_allow_mmap_writes(true); + /// ``` + pub fn set_allow_mmap_writes(&mut self, is_enabled: bool) { + unsafe { + ffi::rocksdb_options_set_allow_mmap_writes(self.inner, is_enabled as c_uchar); + } + } + + /// Allow the OS to mmap file for reading sst tables. + /// + /// Default: false + /// + /// # Example + /// + /// ``` + /// use rocksdb::Options; + /// + /// let mut options = Options::default(); + /// options.set_allow_mmap_reads(true); + /// ``` + pub fn set_allow_mmap_reads(&mut self, is_enabled: bool) { + unsafe { + ffi::rocksdb_options_set_allow_mmap_reads(self.inner, is_enabled as c_uchar); + } + } } impl Default for Options {