This is an automated email from the ASF dual-hosted git repository.
zyxxoo pushed a commit to branch refactor/rust-rewrite-design
in repository https://gitbox.apache.org/repos/asf/hugegraph.git
The following commit(s) were added to refs/heads/refactor/rust-rewrite-design
by this push:
new b573a0579 feat(rust): digest all RocksDB column families
b573a0579 is described below
commit b573a05791deacc13b0aa8863c0678c4d7feb336
Author: vaughn <[email protected]>
AuthorDate: Sun Sep 13 18:36:11 2026 +0800
feat(rust): digest all RocksDB column families
---
tools/rust-store-reader/src/lib.rs | 31 ++++++++++++++++++++++---------
1 file changed, 22 insertions(+), 9 deletions(-)
diff --git a/tools/rust-store-reader/src/lib.rs
b/tools/rust-store-reader/src/lib.rs
index 5526f2689..a65d9b356 100644
--- a/tools/rust-store-reader/src/lib.rs
+++ b/tools/rust-store-reader/src/lib.rs
@@ -3,7 +3,7 @@
// The ASF licenses this file to you under the Apache License, Version 2.0.
// http://www.apache.org/licenses/LICENSE-2.0
use anyhow::{Context, Result};
-use rocksdb::{IteratorMode, DB};
+use rocksdb::{IteratorMode, Options, DB};
use sha2::{Digest, Sha256};
use std::path::Path;
@@ -16,16 +16,29 @@ pub struct StoreDigest {
/// Computes a deterministic digest while leaving the database untouched.
pub fn digest(path: impl AsRef<Path>) -> Result<StoreDigest> {
let path = path.as_ref();
- let db = DB::open_default(path).with_context(|| format!("open RocksDB {}",
path.display()))?;
+ let mut options = Options::default();
+ options.create_if_missing(false);
+ let families = DB::list_cf(&options, path)
+ .with_context(|| format!("list column families in {}",
path.display()))?;
+ let descriptors = families
+ .iter()
+ .map(|name| rocksdb::ColumnFamilyDescriptor::new(name,
Options::default()));
+ let db = DB::open_cf_descriptors(&options, path, descriptors)
+ .with_context(|| format!("open RocksDB {}", path.display()))?;
let mut hasher = Sha256::new();
let mut entries = 0;
- for item in db.iterator(IteratorMode::Start) {
- let (key, value) = item?;
- entries += 1;
- hasher.update((key.len() as u64).to_be_bytes());
- hasher.update(&key);
- hasher.update((value.len() as u64).to_be_bytes());
- hasher.update(&value);
+ for family in families {
+ let handle = db.cf_handle(&family).context("column family handle")?;
+ hasher.update((family.len() as u64).to_be_bytes());
+ hasher.update(family.as_bytes());
+ for item in db.iterator_cf(handle, IteratorMode::Start) {
+ let (key, value) = item?;
+ entries += 1;
+ hasher.update((key.len() as u64).to_be_bytes());
+ hasher.update(&key);
+ hasher.update((value.len() as u64).to_be_bytes());
+ hasher.update(&value);
+ }
}
Ok(StoreDigest {
entries,