|
|
|
@ -1005,21 +1005,7 @@ impl DB { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
pub fn set_options(&self, opts: &[(&str, &str)]) -> Result<(), Error> { |
|
|
|
|
let copts = opts |
|
|
|
|
.iter() |
|
|
|
|
.map(|(name, value)| { |
|
|
|
|
let cname = match CString::new(name.as_bytes()) { |
|
|
|
|
Ok(cname) => cname, |
|
|
|
|
Err(e) => return Err(Error::new(format!("Invalid option name `{}`", e))), |
|
|
|
|
}; |
|
|
|
|
let cvalue = match CString::new(value.as_bytes()) { |
|
|
|
|
Ok(cvalue) => cvalue, |
|
|
|
|
Err(e) => return Err(Error::new(format!("Invalid option value: `{}`", e))), |
|
|
|
|
}; |
|
|
|
|
Ok((cname, cvalue)) |
|
|
|
|
}) |
|
|
|
|
.collect::<Result<Vec<(CString, CString)>, Error>>()?; |
|
|
|
|
|
|
|
|
|
let copts = convert_options(opts)?; |
|
|
|
|
let cnames: Vec<*const c_char> = copts.iter().map(|opt| opt.0.as_ptr()).collect(); |
|
|
|
|
let cvalues: Vec<*const c_char> = copts.iter().map(|opt| opt.1.as_ptr()).collect(); |
|
|
|
|
let count = opts.len() as i32; |
|
|
|
@ -1034,6 +1020,27 @@ impl DB { |
|
|
|
|
Ok(()) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
pub fn set_options_cf( |
|
|
|
|
&self, |
|
|
|
|
cf_handle: &ColumnFamily, |
|
|
|
|
opts: &[(&str, &str)], |
|
|
|
|
) -> Result<(), Error> { |
|
|
|
|
let copts = convert_options(opts)?; |
|
|
|
|
let cnames: Vec<*const c_char> = copts.iter().map(|opt| opt.0.as_ptr()).collect(); |
|
|
|
|
let cvalues: Vec<*const c_char> = copts.iter().map(|opt| opt.1.as_ptr()).collect(); |
|
|
|
|
let count = opts.len() as i32; |
|
|
|
|
unsafe { |
|
|
|
|
ffi_try!(ffi::rocksdb_set_options_cf( |
|
|
|
|
self.inner, |
|
|
|
|
cf_handle.inner, |
|
|
|
|
count, |
|
|
|
|
cnames.as_ptr(), |
|
|
|
|
cvalues.as_ptr(), |
|
|
|
|
)); |
|
|
|
|
} |
|
|
|
|
Ok(()) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// Retrieves a RocksDB property by name.
|
|
|
|
|
///
|
|
|
|
|
/// Full list of properties could be find
|
|
|
|
@ -1405,3 +1412,19 @@ pub struct LiveFile { |
|
|
|
|
/// Number of deletions/tomb key(s) in the file
|
|
|
|
|
pub num_deletions: u64, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fn convert_options(opts: &[(&str, &str)]) -> Result<Vec<(CString, CString)>, Error> { |
|
|
|
|
opts.iter() |
|
|
|
|
.map(|(name, value)| { |
|
|
|
|
let cname = match CString::new(name.as_bytes()) { |
|
|
|
|
Ok(cname) => cname, |
|
|
|
|
Err(e) => return Err(Error::new(format!("Invalid option name `{}`", e))), |
|
|
|
|
}; |
|
|
|
|
let cvalue = match CString::new(value.as_bytes()) { |
|
|
|
|
Ok(cvalue) => cvalue, |
|
|
|
|
Err(e) => return Err(Error::new(format!("Invalid option value: `{}`", e))), |
|
|
|
|
}; |
|
|
|
|
Ok((cname, cvalue)) |
|
|
|
|
}) |
|
|
|
|
.collect() |
|
|
|
|
} |
|
|
|
|