Skip to content

Commit

Permalink
Store Options from ColumnFamily
Browse files Browse the repository at this point in the history
  • Loading branch information
acrrd committed Apr 8, 2021
1 parent 5641786 commit f15b437
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ use std::collections::BTreeMap;
use std::ffi::{CStr, CString};
use std::fmt;
use std::fs;
use std::iter;
use std::marker::PhantomData;
use std::path::Path;
use std::path::PathBuf;
Expand Down Expand Up @@ -103,7 +104,7 @@ pub struct DBWithThreadMode<T: ThreadMode> {
pub(crate) inner: *mut ffi::rocksdb_t,
cfs: T, // Column families are held differently depending on thread mode
path: PathBuf,
_outlive: OptionsMustOutliveDB,
_outlive: Vec<OptionsMustOutliveDB>,
}

/// Minimal set of DB-related methods, intended to be generic over
Expand Down Expand Up @@ -240,7 +241,7 @@ impl<T: ThreadMode> DBWithThreadMode<T> {
inner: db,
cfs: T::new(BTreeMap::new()),
path: path.as_ref().to_path_buf(),
_outlive: opts.outlive.clone(),
_outlive: vec![opts.outlive.clone()],
})
}

Expand Down Expand Up @@ -333,6 +334,9 @@ impl<T: ThreadMode> DBWithThreadMode<T> {
I: IntoIterator<Item = ColumnFamilyDescriptor>,
{
let cfs: Vec<_> = cfs.into_iter().collect();
let outlive = iter::once(opts.outlive.clone())
.chain(cfs.iter().map(|cf| cf.options.outlive.clone()))
.collect();

let cpath = to_cpath(&path)?;

Expand Down Expand Up @@ -404,7 +408,7 @@ impl<T: ThreadMode> DBWithThreadMode<T> {
inner: db,
path: path.as_ref().to_path_buf(),
cfs: T::new(cf_map),
_outlive: opts.outlive.clone(),
_outlive: outlive,
})
}

Expand Down

0 comments on commit f15b437

Please sign in to comment.