|
|
@ -12,7 +12,7 @@ |
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
|
|
|
|
use std::ffi::{CStr, CString}; |
|
|
|
use std::ffi::CStr; |
|
|
|
use std::path::Path; |
|
|
|
use std::path::Path; |
|
|
|
use std::sync::Arc; |
|
|
|
use std::sync::Arc; |
|
|
|
|
|
|
|
|
|
|
@ -24,7 +24,7 @@ use crate::{ |
|
|
|
comparator::{self, ComparatorCallback, CompareFn}, |
|
|
|
comparator::{self, ComparatorCallback, CompareFn}, |
|
|
|
db::DBAccess, |
|
|
|
db::DBAccess, |
|
|
|
ffi, |
|
|
|
ffi, |
|
|
|
ffi_util::CStrLike, |
|
|
|
ffi_util::{to_cpath, CStrLike}, |
|
|
|
merge_operator::{ |
|
|
|
merge_operator::{ |
|
|
|
self, full_merge_callback, partial_merge_callback, MergeFn, MergeOperatorCallback, |
|
|
|
self, full_merge_callback, partial_merge_callback, MergeFn, MergeOperatorCallback, |
|
|
|
}, |
|
|
|
}, |
|
|
@ -1535,7 +1535,7 @@ impl Options { |
|
|
|
///
|
|
|
|
///
|
|
|
|
/// Default: empty
|
|
|
|
/// Default: empty
|
|
|
|
pub fn set_db_log_dir<P: AsRef<Path>>(&mut self, path: P) { |
|
|
|
pub fn set_db_log_dir<P: AsRef<Path>>(&mut self, path: P) { |
|
|
|
let p = CString::new(path.as_ref().to_string_lossy().as_bytes()).unwrap(); |
|
|
|
let p = to_cpath(path).unwrap(); |
|
|
|
unsafe { |
|
|
|
unsafe { |
|
|
|
ffi::rocksdb_options_set_db_log_dir(self.inner, p.as_ptr()); |
|
|
|
ffi::rocksdb_options_set_db_log_dir(self.inner, p.as_ptr()); |
|
|
|
} |
|
|
|
} |
|
|
@ -2723,7 +2723,7 @@ impl Options { |
|
|
|
/// opts.set_wal_dir("/path/to/dir");
|
|
|
|
/// opts.set_wal_dir("/path/to/dir");
|
|
|
|
/// ```
|
|
|
|
/// ```
|
|
|
|
pub fn set_wal_dir<P: AsRef<Path>>(&mut self, path: P) { |
|
|
|
pub fn set_wal_dir<P: AsRef<Path>>(&mut self, path: P) { |
|
|
|
let p = CString::new(path.as_ref().to_string_lossy().as_bytes()).unwrap(); |
|
|
|
let p = to_cpath(path).unwrap(); |
|
|
|
unsafe { |
|
|
|
unsafe { |
|
|
|
ffi::rocksdb_options_set_wal_dir(self.inner, p.as_ptr()); |
|
|
|
ffi::rocksdb_options_set_wal_dir(self.inner, p.as_ptr()); |
|
|
|
} |
|
|
|
} |
|
|
@ -3860,12 +3860,12 @@ pub struct DBPath { |
|
|
|
impl DBPath { |
|
|
|
impl DBPath { |
|
|
|
/// Create a new path
|
|
|
|
/// Create a new path
|
|
|
|
pub fn new<P: AsRef<Path>>(path: P, target_size: u64) -> Result<Self, Error> { |
|
|
|
pub fn new<P: AsRef<Path>>(path: P, target_size: u64) -> Result<Self, Error> { |
|
|
|
let p = CString::new(path.as_ref().to_string_lossy().as_bytes()).unwrap(); |
|
|
|
let p = to_cpath(path.as_ref()).unwrap(); |
|
|
|
let dbpath = unsafe { ffi::rocksdb_dbpath_create(p.as_ptr(), target_size) }; |
|
|
|
let dbpath = unsafe { ffi::rocksdb_dbpath_create(p.as_ptr(), target_size) }; |
|
|
|
if dbpath.is_null() { |
|
|
|
if dbpath.is_null() { |
|
|
|
Err(Error::new(format!( |
|
|
|
Err(Error::new(format!( |
|
|
|
"Could not create path for storing sst files at location: {}", |
|
|
|
"Could not create path for storing sst files at location: {}", |
|
|
|
path.as_ref().to_string_lossy() |
|
|
|
path.as_ref().display() |
|
|
|
))) |
|
|
|
))) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
Ok(DBPath { inner: dbpath }) |
|
|
|
Ok(DBPath { inner: dbpath }) |
|
|
|