diff --git a/.gitmodules b/.gitmodules index ef0e03496..95c5d6e87 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,7 +4,7 @@ [submodule "librocksdb-sys/rocksdb"] path = librocksdb-sys/rocksdb url = https://github.com/haizhi-tech/rocksdb.git - branch = v8.1.1-hz + branch = v9.9.3-hz [submodule "librocksdb-sys/lz4"] path = librocksdb-sys/lz4 url = https://github.com/lz4/lz4.git diff --git a/Cargo.toml b/Cargo.toml index 23036069a..d65fb35b4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "haizhi-rocksdb" description = "Rust wrapper for Facebook's RocksDB embeddable database" -version = "0.2.8" +version = "0.2.10" edition = "2021" rust-version = "1.71.1" authors = ["Tyler Neely ", "David Greenberg "] diff --git a/librocksdb-sys/Cargo.toml b/librocksdb-sys/Cargo.toml index fbf45eea0..25c100fc6 100644 --- a/librocksdb-sys/Cargo.toml +++ b/librocksdb-sys/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "haizhi-librocksdb-sys" -version = "0.2.7+9.9.3" +version = "0.2.10+9.9.3" edition = "2021" rust-version = "1.71.1" authors = [ diff --git a/librocksdb-sys/rocksdb b/librocksdb-sys/rocksdb index 14d3046a5..3370047e3 160000 --- a/librocksdb-sys/rocksdb +++ b/librocksdb-sys/rocksdb @@ -1 +1 @@ -Subproject commit 14d3046a53dda588ef5887ee2c80e93104caf079 +Subproject commit 3370047e30a17c6baf3b3daee1039af91487c676 diff --git a/librocksdb-sys/tests/ffi.rs b/librocksdb-sys/tests/ffi.rs index a0b1e6a67..2253aea22 100644 --- a/librocksdb-sys/tests/ffi.rs +++ b/librocksdb-sys/tests/ffi.rs @@ -23,8 +23,8 @@ unused_variables )] +use haizhi_librocksdb_sys::*; use libc::*; -use librocksdb_sys::*; use std::borrow::Cow; use std::env; use std::ffi::{CStr, CString}; diff --git a/src/checkpoint.rs b/src/checkpoint.rs index 0a5e61a58..8de759cd7 100644 --- a/src/checkpoint.rs +++ b/src/checkpoint.rs @@ -18,12 +18,12 @@ //! [1]: https://github.com/facebook/rocksdb/wiki/Checkpoints use crate::AsColumnFamilyRef; -use crate::{ffi, Error, DB}; -use libc::{c_char, int32_t}; +use crate::{ffi, Error}; +use libc::c_char; use crate::db::DBInner; use crate::ffi_util::to_cpath; -use crate::{ColumnFamily, DBCommon, ThreadMode}; +use crate::{DBCommon, ThreadMode}; use std::ffi::{CStr, CString}; use std::fs::File; use std::io::{Read, Write}; @@ -215,14 +215,12 @@ impl<'db> Checkpoint<'db> { export_dir: P, ) -> Result { let path = export_dir.as_ref(); - let cpath = if let Ok(c) = CString::new(path.to_string_lossy().as_bytes()) { - c - } else { - return Err(Error::new( - "Failed to convert path to CString when creating DB checkpoint".to_owned(), - )); - }; - + let cpath = CString::new(path.to_string_lossy().as_bytes()).map_err(|err| { + Error::new(format!( + "Failed to convert path to CString when creating DB checkpoint: {}", + err + )) + })?; let inner: *mut ffi::rocksdb_export_import_files_metadata_t; unsafe { diff --git a/src/db.rs b/src/db.rs index 19e07eb56..6afb58988 100644 --- a/src/db.rs +++ b/src/db.rs @@ -2363,7 +2363,7 @@ impl DBCommon { true, true, files_size_error_margin, - )) + )); } Ok(sizes) } @@ -2549,13 +2549,12 @@ impl DBCommon { opts: &Options, metadata: &ExportImportFilesMetaData, ) -> Result<*mut ffi::rocksdb_column_family_handle_t, Error> { - let cf_name = if let Ok(c) = CString::new(name.as_bytes()) { - c - } else { - return Err(Error::new( - "Failed to convert path to CString when creating cf".to_owned(), - )); - }; + let cf_name = CString::new(name.as_bytes()).map_err(|err| { + Error::new(format!( + "Failed to convert path to CString when creating cf: {}", + err + )) + })?; Ok(unsafe { ffi_try!(ffi::rocksdb_create_column_family_with_import( self.inner.inner(), diff --git a/src/db_options.rs b/src/db_options.rs index 1aa171ea8..cdb07d06d 100644 --- a/src/db_options.rs +++ b/src/db_options.rs @@ -1138,12 +1138,6 @@ impl Options { } } - pub fn set_periodic_compaction_seconds(&mut self, sec: u64) { - unsafe { - ffi::rocksdb_options_set_periodic_compaction_seconds(self.inner, sec); - } - } - /// If true, the database will be created if it is missing. /// /// Default: `false` @@ -4770,7 +4764,7 @@ mod tests { #[test] fn test_set_write_buffer_manager() { let mut opts = Options::default(); - let lrucache = Cache::new_lru_cache(100); + let lrucache = Cache::new_lru_cache(100).unwrap(); let write_buffer_manager = WriteBufferManager::new_write_buffer_manager_with_cache(100, false, lrucache); assert_eq!(write_buffer_manager.get_buffer_size(), 100); diff --git a/tests/fail/open_with_multiple_refs_as_single_threaded.stderr b/tests/fail/open_with_multiple_refs_as_single_threaded.stderr index 85bbdbc65..d13c1b03e 100644 --- a/tests/fail/open_with_multiple_refs_as_single_threaded.stderr +++ b/tests/fail/open_with_multiple_refs_as_single_threaded.stderr @@ -7,7 +7,7 @@ error[E0596]: cannot borrow `*db_ref1` as mutable, as it is behind a `&` referen help: consider changing this to be a mutable reference | 6 | let db_ref1 = &mut db; - | ~~~~~~~ + | +++ error[E0596]: cannot borrow `*db_ref2` as mutable, as it is behind a `&` reference --> tests/fail/open_with_multiple_refs_as_single_threaded.rs:10:5 @@ -18,4 +18,4 @@ error[E0596]: cannot borrow `*db_ref2` as mutable, as it is behind a `&` referen help: consider changing this to be a mutable reference | 7 | let db_ref2 = &mut db; - | ~~~~~~~ + | +++ diff --git a/tests/test_optimistic_transaction_db_memory_usage.rs b/tests/test_optimistic_transaction_db_memory_usage.rs index 3bb77ecc6..b53cc873d 100644 --- a/tests/test_optimistic_transaction_db_memory_usage.rs +++ b/tests/test_optimistic_transaction_db_memory_usage.rs @@ -15,6 +15,8 @@ mod util; +use haizhi_rocksdb as rocksdb; + use rocksdb::{OptimisticTransactionDB, Options, SingleThreaded}; use util::DBPath; @@ -27,7 +29,7 @@ fn test_optimistic_transaction_db_memory_usage() { options.enable_statistics(); // setup cache: - let cache = rocksdb::Cache::new_lru_cache(1 << 20); // 1 MB cache + let cache = rocksdb::Cache::new_lru_cache(1 << 20).unwrap(); // 1 MB cache let mut block_based_options = rocksdb::BlockBasedOptions::default(); block_based_options.set_block_cache(&cache); options.set_block_based_table_factory(&block_based_options); diff --git a/tests/test_transaction_db_memory_usage.rs b/tests/test_transaction_db_memory_usage.rs index 0e80127c3..9a243833d 100644 --- a/tests/test_transaction_db_memory_usage.rs +++ b/tests/test_transaction_db_memory_usage.rs @@ -14,6 +14,8 @@ mod util; +use haizhi_rocksdb as rocksdb; + use pretty_assertions::assert_eq; use rocksdb::{perf, Options, TransactionDB, TransactionDBOptions}; @@ -33,7 +35,7 @@ fn test_transaction_db_memory_usage() { options.enable_statistics(); // setup cache: - let cache = rocksdb::Cache::new_lru_cache(1 << 20); // 1 MB cache + let cache = rocksdb::Cache::new_lru_cache(1 << 20).unwrap(); // 1 MB cache let mut block_based_options = rocksdb::BlockBasedOptions::default(); block_based_options.set_block_cache(&cache); options.set_block_based_table_factory(&block_based_options); diff --git a/tests/test_transaction_db_property.rs b/tests/test_transaction_db_property.rs index abb507ffd..01f5ccd59 100644 --- a/tests/test_transaction_db_property.rs +++ b/tests/test_transaction_db_property.rs @@ -14,6 +14,8 @@ mod util; +use haizhi_rocksdb as rocksdb; + use pretty_assertions::assert_eq; use rocksdb::{properties, Options, TransactionDB, TransactionDBOptions}; diff --git a/tests/util/mod.rs b/tests/util/mod.rs index 95b098d37..e71a0297d 100644 --- a/tests/util/mod.rs +++ b/tests/util/mod.rs @@ -8,7 +8,6 @@ use std::{ }; use rocksdb::{Error, Options, DB}; -use std::path::{Path, PathBuf}; /// Temporary database path which calls DB::Destroy when DBPath is dropped. pub struct DBPath {