Skip to content

Commit

Permalink
Update to upstream version
Browse files Browse the repository at this point in the history
- update rocksdb version
- fix some tests and clippy

now the base versions:

- rust-rocksdb: v0.23.0(upstream: 3525109)
- librocksdb-sys/rocksdb: v9.9.3(upstream: 14d3046a53, head with our changes: 3370047e)
  • Loading branch information
yangweijian committed Feb 13, 2025
1 parent e06de2f commit eb2ac2e
Show file tree
Hide file tree
Showing 13 changed files with 32 additions and 36 deletions.
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>", "David Greenberg <[email protected]>"]
Expand Down
2 changes: 1 addition & 1 deletion librocksdb-sys/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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 = [
Expand Down
2 changes: 1 addition & 1 deletion librocksdb-sys/rocksdb
2 changes: 1 addition & 1 deletion librocksdb-sys/tests/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
20 changes: 9 additions & 11 deletions src/checkpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -215,14 +215,12 @@ impl<'db> Checkpoint<'db> {
export_dir: P,
) -> Result<ExportImportFilesMetaData, Error> {
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!(

Check failure on line 219 in src/checkpoint.rs

View workflow job for this annotation

GitHub Actions / Clippy

variables can be used directly in the `format!` string
"Failed to convert path to CString when creating DB checkpoint: {}",
err
))
})?;
let inner: *mut ffi::rocksdb_export_import_files_metadata_t;

unsafe {
Expand Down
15 changes: 7 additions & 8 deletions src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2363,7 +2363,7 @@ impl<T: ThreadMode, D: DBInner> DBCommon<T, D> {
true,
true,
files_size_error_margin,
))
));
}
Ok(sizes)
}
Expand Down Expand Up @@ -2549,13 +2549,12 @@ impl<T: ThreadMode, D: DBInner> DBCommon<T, D> {
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!(

Check failure on line 2553 in src/db.rs

View workflow job for this annotation

GitHub Actions / Clippy

variables can be used directly in the `format!` string
"Failed to convert path to CString when creating cf: {}",
err
))
})?;
Ok(unsafe {
ffi_try!(ffi::rocksdb_create_column_family_with_import(
self.inner.inner(),
Expand Down
8 changes: 1 addition & 7 deletions src/db_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions tests/fail/open_with_multiple_refs_as_single_threaded.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
| ~~~~~~~
| +++
4 changes: 3 additions & 1 deletion tests/test_optimistic_transaction_db_memory_usage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

mod util;

use haizhi_rocksdb as rocksdb;

use rocksdb::{OptimisticTransactionDB, Options, SingleThreaded};
use util::DBPath;

Expand All @@ -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);
Expand Down
4 changes: 3 additions & 1 deletion tests/test_transaction_db_memory_usage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

mod util;

use haizhi_rocksdb as rocksdb;

use pretty_assertions::assert_eq;

use rocksdb::{perf, Options, TransactionDB, TransactionDBOptions};
Expand All @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions tests/test_transaction_db_property.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

mod util;

use haizhi_rocksdb as rocksdb;

use pretty_assertions::assert_eq;

use rocksdb::{properties, Options, TransactionDB, TransactionDBOptions};
Expand Down
1 change: 0 additions & 1 deletion tests/util/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit eb2ac2e

Please sign in to comment.