Skip to content

Commit

Permalink
Merge branch 'master' into bindgen-runtime-feature
Browse files Browse the repository at this point in the history
  • Loading branch information
Congyuwang authored Nov 13, 2024
2 parents de9121b + 7cf4f8a commit b0ea828
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 4 deletions.
12 changes: 12 additions & 0 deletions librocksdb-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,22 @@ fn build_rocksdb() {
config.define("OS_LINUX", None);
config.define("ROCKSDB_PLATFORM_POSIX", None);
config.define("ROCKSDB_LIB_IO_POSIX", None);
} else if target.contains("dragonfly") {
config.define("OS_DRAGONFLYBSD", None);
config.define("ROCKSDB_PLATFORM_POSIX", None);
config.define("ROCKSDB_LIB_IO_POSIX", None);
} else if target.contains("freebsd") {
config.define("OS_FREEBSD", None);
config.define("ROCKSDB_PLATFORM_POSIX", None);
config.define("ROCKSDB_LIB_IO_POSIX", None);
} else if target.contains("netbsd") {
config.define("OS_NETBSD", None);
config.define("ROCKSDB_PLATFORM_POSIX", None);
config.define("ROCKSDB_LIB_IO_POSIX", None);
} else if target.contains("openbsd") {
config.define("OS_OPENBSD", None);
config.define("ROCKSDB_PLATFORM_POSIX", None);
config.define("ROCKSDB_LIB_IO_POSIX", None);
} else if target.contains("windows") {
link("rpcrt4", false);
link("shlwapi", false);
Expand Down
6 changes: 5 additions & 1 deletion src/compaction_filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,11 @@ fn test_filter(level: u32, key: &[u8], value: &[u8]) -> Decision {
fn compaction_filter_test() {
use crate::{Options, DB};

let path = "_rust_rocksdb_filter_test";
let tempdir = tempfile::Builder::new()
.prefix("_rust_rocksdb_filter_test")
.tempdir()
.expect("Failed to create temporary path for the _rust_rocksdb_filter_test");
let path = tempdir.path();
let mut opts = Options::default();
opts.create_if_missing(true);
opts.set_compaction_filter("test", test_filter);
Expand Down
6 changes: 5 additions & 1 deletion src/compaction_filter_factory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,11 @@ mod tests {

#[test]
fn compaction_filter_factory_test() {
let path = "_rust_rocksdb_filter_factory_test";
let tempdir = tempfile::Builder::new()
.prefix("_rust_rocksdb_filter_factory_test")
.tempdir()
.expect("Failed to create temporary path for the _rust_rocksdb_filter_factory_test.");
let path = tempdir.path();
let mut opts = Options::default();
opts.create_if_missing(true);
opts.set_compaction_filter_factory(TestFactory(CString::new("TestFactory").unwrap()));
Expand Down
5 changes: 4 additions & 1 deletion src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2478,8 +2478,11 @@ impl<I: DBInner> DBCommon<SingleThreaded, I> {
impl<I: DBInner> DBCommon<MultiThreaded, I> {
/// Creates column family with given name and options
pub fn create_cf<N: AsRef<str>>(&self, name: N, opts: &Options) -> Result<(), Error> {
// Note that we acquire the cfs lock before inserting: otherwise we might race
// another caller who observed the handle as missing.
let mut cfs = self.cfs.cfs.write().unwrap();
let inner = self.create_inner_cf_handle(name.as_ref(), opts)?;
self.cfs.cfs.write().unwrap().insert(
cfs.insert(
name.as_ref().to_string(),
Arc::new(UnboundColumnFamily { inner }),
);
Expand Down
5 changes: 4 additions & 1 deletion src/transactions/transaction_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -994,8 +994,11 @@ impl TransactionDB<SingleThreaded> {
impl TransactionDB<MultiThreaded> {
/// Creates column family with given name and options.
pub fn create_cf<N: AsRef<str>>(&self, name: N, opts: &Options) -> Result<(), Error> {
// Note that we acquire the cfs lock before inserting: otherwise we might race
// another caller who observed the handle as missing.
let mut cfs = self.cfs.cfs.write().unwrap();
let inner = self.create_inner_cf_handle(name.as_ref(), opts)?;
self.cfs.cfs.write().unwrap().insert(
cfs.insert(
name.as_ref().to_string(),
Arc::new(UnboundColumnFamily { inner }),
);
Expand Down

0 comments on commit b0ea828

Please sign in to comment.