|
|
@ -782,17 +782,7 @@ impl DB { |
|
|
|
{ |
|
|
|
{ |
|
|
|
let cfs: Vec<_> = cfs.into_iter().collect(); |
|
|
|
let cfs: Vec<_> = cfs.into_iter().collect(); |
|
|
|
|
|
|
|
|
|
|
|
let path = path.as_ref(); |
|
|
|
let cpath = to_cpath(&path)?; |
|
|
|
let cpath = match CString::new(path.to_string_lossy().as_bytes()) { |
|
|
|
|
|
|
|
Ok(c) => c, |
|
|
|
|
|
|
|
Err(_) => { |
|
|
|
|
|
|
|
return Err(Error::new( |
|
|
|
|
|
|
|
"Failed to convert path to CString \ |
|
|
|
|
|
|
|
when opening DB." |
|
|
|
|
|
|
|
.to_owned(), |
|
|
|
|
|
|
|
)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if let Err(e) = fs::create_dir_all(&path) { |
|
|
|
if let Err(e) = fs::create_dir_all(&path) { |
|
|
|
return Err(Error::new(format!( |
|
|
|
return Err(Error::new(format!( |
|
|
@ -848,9 +838,7 @@ impl DB { |
|
|
|
for handle in &cfhandles { |
|
|
|
for handle in &cfhandles { |
|
|
|
if handle.is_null() { |
|
|
|
if handle.is_null() { |
|
|
|
return Err(Error::new( |
|
|
|
return Err(Error::new( |
|
|
|
"Received null column family \ |
|
|
|
"Received null column family handle from DB.".to_owned(), |
|
|
|
handle from DB." |
|
|
|
|
|
|
|
.to_owned(), |
|
|
|
|
|
|
|
)); |
|
|
|
)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -867,7 +855,7 @@ impl DB { |
|
|
|
Ok(DB { |
|
|
|
Ok(DB { |
|
|
|
inner: db, |
|
|
|
inner: db, |
|
|
|
cfs: cf_map, |
|
|
|
cfs: cf_map, |
|
|
|
path: path.to_path_buf(), |
|
|
|
path: path.as_ref().to_path_buf(), |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -1007,11 +995,8 @@ impl DB { |
|
|
|
) -> Result<Option<DBPinnableSlice>, Error> { |
|
|
|
) -> Result<Option<DBPinnableSlice>, Error> { |
|
|
|
if readopts.inner.is_null() { |
|
|
|
if readopts.inner.is_null() { |
|
|
|
return Err(Error::new( |
|
|
|
return Err(Error::new( |
|
|
|
"Unable to create RocksDB read options. \ |
|
|
|
"Unable to create RocksDB read options. This is a fairly trivial call, and its \ |
|
|
|
This is a fairly trivial call, and its \ |
|
|
|
failure may be indicative of a mis-compiled or mis-loaded RocksDB library." |
|
|
|
failure may be indicative of a \ |
|
|
|
|
|
|
|
mis-compiled or mis-loaded RocksDB \ |
|
|
|
|
|
|
|
library." |
|
|
|
|
|
|
|
.to_owned(), |
|
|
|
.to_owned(), |
|
|
|
)); |
|
|
|
)); |
|
|
|
} |
|
|
|
} |
|
|
@ -1050,11 +1035,8 @@ impl DB { |
|
|
|
) -> Result<Option<DBPinnableSlice>, Error> { |
|
|
|
) -> Result<Option<DBPinnableSlice>, Error> { |
|
|
|
if readopts.inner.is_null() { |
|
|
|
if readopts.inner.is_null() { |
|
|
|
return Err(Error::new( |
|
|
|
return Err(Error::new( |
|
|
|
"Unable to create RocksDB read options. \ |
|
|
|
"Unable to create RocksDB read options. This is a fairly trivial call, and its \ |
|
|
|
This is a fairly trivial call, and its \ |
|
|
|
failure may be indicative of a mis-compiled or mis-loaded RocksDB library." |
|
|
|
failure may be indicative of a \ |
|
|
|
|
|
|
|
mis-compiled or mis-loaded RocksDB \ |
|
|
|
|
|
|
|
library." |
|
|
|
|
|
|
|
.to_owned(), |
|
|
|
.to_owned(), |
|
|
|
)); |
|
|
|
)); |
|
|
|
} |
|
|
|
} |
|
|
@ -1092,9 +1074,7 @@ impl DB { |
|
|
|
Ok(c) => c, |
|
|
|
Ok(c) => c, |
|
|
|
Err(_) => { |
|
|
|
Err(_) => { |
|
|
|
return Err(Error::new( |
|
|
|
return Err(Error::new( |
|
|
|
"Failed to convert path to CString \ |
|
|
|
"Failed to convert path to CString when creating cf".to_owned(), |
|
|
|
when opening rocksdb" |
|
|
|
|
|
|
|
.to_owned(), |
|
|
|
|
|
|
|
)); |
|
|
|
)); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
@ -2005,9 +1985,10 @@ unsafe impl Sync for ReadOptions {} |
|
|
|
fn to_cpath<P: AsRef<Path>>(path: P) -> Result<CString, Error> { |
|
|
|
fn to_cpath<P: AsRef<Path>>(path: P) -> Result<CString, Error> { |
|
|
|
match CString::new(path.as_ref().to_string_lossy().as_bytes()) { |
|
|
|
match CString::new(path.as_ref().to_string_lossy().as_bytes()) { |
|
|
|
Ok(c) => Ok(c), |
|
|
|
Ok(c) => Ok(c), |
|
|
|
Err(_) => Err(Error::new( |
|
|
|
Err(e) => Err(Error::new(format!( |
|
|
|
"Failed to convert path to CString when opening DB.".to_owned(), |
|
|
|
"Failed to convert path to CString: {}", |
|
|
|
)), |
|
|
|
e, |
|
|
|
|
|
|
|
))), |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|