From af1fe2e91ea331ac07845e1402d5fd83af424e8b Mon Sep 17 00:00:00 2001 From: Gaius Date: Wed, 15 May 2024 11:14:43 +0800 Subject: [PATCH] feat: replace TransactionDB with DB (#468) Signed-off-by: Gaius --- Cargo.lock | 16 +++++++-------- Cargo.toml | 16 +++++++-------- .../src/storage_engine/rocksdb.rs | 20 +++++++------------ 3 files changed, 23 insertions(+), 29 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 762ac381..7148a0e6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -959,7 +959,7 @@ dependencies = [ [[package]] name = "dragonfly-client" -version = "0.1.55" +version = "0.1.56" dependencies = [ "anyhow", "bytes", @@ -1022,7 +1022,7 @@ dependencies = [ [[package]] name = "dragonfly-client-backend" -version = "0.1.55" +version = "0.1.56" dependencies = [ "dragonfly-client-core", "futures", @@ -1040,7 +1040,7 @@ dependencies = [ [[package]] name = "dragonfly-client-config" -version = "0.1.55" +version = "0.1.56" dependencies = [ "dragonfly-client-core", "home", @@ -1059,7 +1059,7 @@ dependencies = [ [[package]] name = "dragonfly-client-core" -version = "0.1.55" +version = "0.1.56" dependencies = [ "libloading", "reqwest", @@ -1070,7 +1070,7 @@ dependencies = [ [[package]] name = "dragonfly-client-init" -version = "0.1.55" +version = "0.1.56" dependencies = [ "anyhow", "clap", @@ -1086,7 +1086,7 @@ dependencies = [ [[package]] name = "dragonfly-client-storage" -version = "0.1.55" +version = "0.1.56" dependencies = [ "base16ct", "blake3", @@ -1110,7 +1110,7 @@ dependencies = [ [[package]] name = "dragonfly-client-util" -version = "0.1.55" +version = "0.1.56" dependencies = [ "dragonfly-api", "dragonfly-client-core", @@ -1568,7 +1568,7 @@ dependencies = [ [[package]] name = "hdfs" -version = "0.1.55" +version = "0.1.56" dependencies = [ "dragonfly-client-backend", "dragonfly-client-core", diff --git a/Cargo.toml b/Cargo.toml index d4f3600d..a431505c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,7 @@ members = [ ] [workspace.package] -version = "0.1.55" +version = "0.1.56" authors = ["The Dragonfly Developers"] homepage = "https://d7y.io/" repository = "https://github.com/dragonflyoss/client.git" @@ -22,13 +22,13 @@ readme = "README.md" edition = "2021" [workspace.dependencies] -dragonfly-client = { path = "dragonfly-client", version = "0.1.55" } -dragonfly-client-core = { path = "dragonfly-client-core", version = "0.1.55" } -dragonfly-client-config = { path = "dragonfly-client-config", version = "0.1.55" } -dragonfly-client-storage = { path = "dragonfly-client-storage", version = "0.1.55" } -dragonfly-client-backend = { path = "dragonfly-client-backend", version = "0.1.55" } -dragonfly-client-util = { path = "dragonfly-client-util", version = "0.1.55" } -dragonfly-client-init = { path = "dragonfly-client-init", version = "0.1.55" } +dragonfly-client = { path = "dragonfly-client", version = "0.1.56" } +dragonfly-client-core = { path = "dragonfly-client-core", version = "0.1.56" } +dragonfly-client-config = { path = "dragonfly-client-config", version = "0.1.56" } +dragonfly-client-storage = { path = "dragonfly-client-storage", version = "0.1.56" } +dragonfly-client-backend = { path = "dragonfly-client-backend", version = "0.1.56" } +dragonfly-client-util = { path = "dragonfly-client-util", version = "0.1.56" } +dragonfly-client-init = { path = "dragonfly-client-init", version = "0.1.56" } thiserror = "1.0" dragonfly-api = "2.0.112" reqwest = { version = "0.11.27", features = ["stream", "native-tls", "default-tls", "rustls-tls"] } diff --git a/dragonfly-client-storage/src/storage_engine/rocksdb.rs b/dragonfly-client-storage/src/storage_engine/rocksdb.rs index 1487d784..b34f25cb 100644 --- a/dragonfly-client-storage/src/storage_engine/rocksdb.rs +++ b/dragonfly-client-storage/src/storage_engine/rocksdb.rs @@ -24,16 +24,16 @@ use tracing::info; /// RocksdbStorageEngine is a storage engine based on rocksdb. pub struct RocksdbStorageEngine { - // inner is the inner rocksdb transaction db. - inner: rocksdb::TransactionDB, + // inner is the inner rocksdb DB. + inner: rocksdb::DB, } // RocksdbStorageEngine implements deref of the storage engine. impl Deref for RocksdbStorageEngine { - // Target is the inner rocksdb transaction db. - type Target = rocksdb::TransactionDB; + // Target is the inner rocksdb DB. + type Target = rocksdb::DB; - // deref returns the inner rocksdb transaction db. + // deref returns the inner rocksdb DB. fn deref(&self) -> &Self::Target { &self.inner } @@ -80,13 +80,7 @@ impl RocksdbStorageEngine { // Open rocksdb. let dir = dir.join(Self::DEFAULT_DIR_NAME); - let db = rocksdb::TransactionDB::open_cf( - &options, - &rocksdb::TransactionDBOptions::default(), - &dir, - cf_names, - ) - .or_err(ErrorType::StorageError)?; + let db = rocksdb::DB::open_cf(&options, &dir, cf_names).or_err(ErrorType::StorageError)?; info!("metadata initialized directory: {:?}", dir); Ok(Self { inner: db }) @@ -149,7 +143,7 @@ impl Operations for RocksdbStorageEngine { impl<'db> StorageEngine<'db> for RocksdbStorageEngine {} /// cf_handle returns the column family handle for the given object. -fn cf_handle(db: &rocksdb::TransactionDB) -> Result<&rocksdb::ColumnFamily> +fn cf_handle(db: &rocksdb::DB) -> Result<&rocksdb::ColumnFamily> where T: DatabaseObject, {