diff --git a/ufos/src/bin/analyze.rs b/ufos/src/bin/analyze.rs index 384536c..7984939 100644 --- a/ufos/src/bin/analyze.rs +++ b/ufos/src/bin/analyze.rs @@ -6,8 +6,8 @@ use std::collections::BTreeMap; use std::path::PathBuf; use ufos::db_types::{db_complete, DbBytes}; use ufos::store_types::{ - AllTimeRollupKey, AllTimeRollupStaticPrefix, CountsValue, WeekTruncatedCursor, - WeeklyRollupKey, WeeklyRollupStaticPrefix, WithCollection, + AllTimeRollupKey, AllTimeRollupStaticPrefix, CountsValue, WeekTruncatedCursor, WeeklyRollupKey, + WeeklyRollupStaticPrefix, WithCollection, }; #[derive(Parser)] @@ -69,6 +69,7 @@ fn total_users(rollups: &PartitionHandle) -> anyhow::Result<()> { /// Scan weekly rollups once, returning week -> (merged sketch, per-group entries) /// Only non-excluded groups are included. +#[expect(clippy::type_complexity)] fn scan_weekly( rollups: &PartitionHandle, ) -> anyhow::Result, Vec<(String, u64)>)>> { @@ -94,7 +95,7 @@ fn scan_weekly( } scanned += 1; - if scanned % 500_000 == 0 { + if scanned.is_multiple_of(500_000) { eprintln!(" ...scanned {scanned} weekly entries"); } } diff --git a/ufos/src/error.rs b/ufos/src/error.rs index 012b61d..6b7748a 100644 --- a/ufos/src/error.rs +++ b/ufos/src/error.rs @@ -28,11 +28,11 @@ pub enum StorageError { InitError(String), #[error("DB seems to be in a bad state: {0}")] BadStateError(String), - #[error("Fjall error")] + #[error("Fjall error: {0}")] FjallError(#[from] fjall::Error), - #[error("LSM-tree error (from fjall)")] + #[error("LSM-tree error (from fjall): {0}")] FjallLsmError(#[from] fjall::LsmError), - #[error("Bytes encoding error")] + #[error("Bytes encoding error: {0}")] EncodingError(#[from] EncodingError), #[error("If you ever see this, there's a bug in the code. The error was stolen")] Stolen, diff --git a/ufos/src/storage_fjall.rs b/ufos/src/storage_fjall.rs index ec46301..dc96c45 100644 --- a/ufos/src/storage_fjall.rs +++ b/ufos/src/storage_fjall.rs @@ -1205,7 +1205,7 @@ impl FjallWriter { let mut dirty_nsids = HashSet::new(); - #[derive(Eq, Hash, PartialEq)] + #[derive(Debug, Eq, Hash, PartialEq)] enum Rollup { Hourly(HourTruncatedCursor), Weekly(WeekTruncatedCursor), @@ -1235,7 +1235,9 @@ impl FjallWriter { dirty_nsids.insert(key.collection().clone()); batch.remove(&self.rollups, key_bytes); - let val = db_complete::(&val_bytes)?; + let val = db_complete::(&val_bytes).inspect_err(|e| { + log::error!("bad CountsValue at {key:?} from rolling up timelies: {e}") + })?; counts_by_rollup .entry(( key.collection().clone(), @@ -1275,7 +1277,10 @@ impl FjallWriter { .get(&rollup_key_bytes)? .as_deref() .map(db_complete::) - .transpose()? + .transpose() + .inspect_err(|e| { + log::error!("bad CountsValue at {nsid:?}/{rollup:?} from counts_by_rollup: {e}") + })? .unwrap_or_default(); // now that we have values, we can know the exising ranks