Skip to content

Commit 1046e28

Browse files
zzylolclaude
andcommitted
Fix clippy errors: type_complexity, unused_mut, collapsible_if, deprecated
- Add MetricBucketMap type alias in common.rs to fix type_complexity - Use MetricBucketMap in global.rs and per_key.rs - Remove unused `mut` from `results` in global.rs - Collapse nested `if` into single condition in per_key.rs - Add #[allow(deprecated)] to impl blocks in per_key_legacy.rs - Add #![allow(deprecated)] to benchmark file for legacy store usage Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent a1047f3 commit 1046e28

5 files changed

Lines changed: 15 additions & 13 deletions

File tree

asap-query-engine/benches/simple_map_store_benchmark.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![allow(deprecated)]
12
use criterion::{black_box, criterion_group, criterion_main, BenchmarkId, Criterion};
23
use std::collections::HashMap;
34
use std::sync::{Arc, Barrier};

asap-query-engine/src/stores/simple_map_store/common.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use std::sync::Arc;
55
pub type MetricID = u32;
66
pub type EpochID = u64;
77
pub type TimestampRange = (u64, u64);
8+
pub type MetricBucketMap = HashMap<MetricID, Vec<(TimestampRange, Arc<dyn AggregateCore>)>>;
89

910
/// Assigns a compact MetricID (u32) to each unique label combination.
1011
/// Label strings stored once; all internal maps use MetricID (O(1) key ops).
@@ -122,7 +123,7 @@ impl EpochData {
122123
&self,
123124
start: u64,
124125
end: u64,
125-
out: &mut HashMap<MetricID, Vec<(TimestampRange, Arc<dyn AggregateCore>)>>,
126+
out: &mut MetricBucketMap,
126127
matched_windows: &mut Vec<TimestampRange>,
127128
) {
128129
for (&metric_id, btree) in &self.label_map {

asap-query-engine/src/stores/simple_map_store/global.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::data_model::{AggregateCore, CleanupPolicy, PrecomputedOutput, StreamingConfig};
22
use crate::stores::simple_map_store::common::{
3-
EpochData, EpochID, InternTable, MetricID, TimestampRange,
3+
EpochData, EpochID, InternTable, MetricBucketMap, TimestampRange,
44
};
55
use crate::stores::{Store, StoreResult, TimestampedBucketsMap};
66
use std::collections::{BTreeMap, HashMap, HashSet};
@@ -402,7 +402,7 @@ impl Store for SimpleMapStoreGlobal {
402402
let range_scan_start_time = Instant::now();
403403

404404
// Accumulate by MetricID first (no intermediate flat Vec allocation).
405-
let mut mid: HashMap<MetricID, Vec<(TimestampRange, Arc<dyn AggregateCore>)>> = {
405+
let mut mid: MetricBucketMap = {
406406
let per_key = match data.stores.get(&store_key) {
407407
Some(pk) => pk,
408408
None => {
@@ -411,8 +411,7 @@ impl Store for SimpleMapStoreGlobal {
411411
}
412412
};
413413

414-
let mut mid: HashMap<MetricID, Vec<(TimestampRange, Arc<dyn AggregateCore>)>> =
415-
HashMap::with_capacity(per_key.intern.len());
414+
let mut mid: MetricBucketMap = HashMap::with_capacity(per_key.intern.len());
416415

417416
for epoch in per_key.epochs.values() {
418417
// Skip epoch if it has no windows overlapping [start, end]
@@ -433,7 +432,7 @@ impl Store for SimpleMapStoreGlobal {
433432
};
434433

435434
// Resolve MetricIDs → labels in a single pass (scope ends before read_counts borrow)
436-
let mut results: TimestampedBucketsMap = {
435+
let results: TimestampedBucketsMap = {
437436
let per_key = data.stores.get(&store_key).unwrap();
438437
let mut r = HashMap::with_capacity(mid.len());
439438
for (metric_id, buckets) in mid.drain() {

asap-query-engine/src/stores/simple_map_store/per_key.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::data_model::{AggregateCore, CleanupPolicy, PrecomputedOutput, StreamingConfig};
22
use crate::stores::simple_map_store::common::{
3-
EpochData, EpochID, InternTable, MetricID, TimestampRange,
3+
EpochData, EpochID, InternTable, MetricBucketMap, MetricID, TimestampRange,
44
};
55
use crate::stores::{Store, StoreResult, TimestampedBucketsMap};
66
use dashmap::DashMap;
@@ -292,10 +292,10 @@ impl SimpleMapStorePerKey {
292292
epoch.insert(metric_id, timestamp_range, Arc::from(precompute));
293293

294294
// After each item, check if we should rotate (CircularBuffer, Optimization 2)
295-
if aggregation_config.aggregation_type != "DeltaSetAggregator" {
296-
if matches!(self.cleanup_policy, CleanupPolicy::CircularBuffer) {
297-
data.maybe_rotate_epoch();
298-
}
295+
if aggregation_config.aggregation_type != "DeltaSetAggregator"
296+
&& matches!(self.cleanup_policy, CleanupPolicy::CircularBuffer)
297+
{
298+
data.maybe_rotate_epoch();
299299
}
300300
}
301301

@@ -460,8 +460,7 @@ impl Store for SimpleMapStorePerKey {
460460
let range_scan_start_time = Instant::now();
461461

462462
// Accumulate by MetricID first (no intermediate flat Vec allocation).
463-
let mut mid: HashMap<MetricID, Vec<(TimestampRange, Arc<dyn AggregateCore>)>> =
464-
HashMap::with_capacity(data.intern.len());
463+
let mut mid: MetricBucketMap = HashMap::with_capacity(data.intern.len());
465464

466465
// Query each epoch; skip if time_ranges don't overlap [start, end]
467466
for epoch in data.epochs.values() {

asap-query-engine/src/stores/simple_map_store/per_key_legacy.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ pub struct LegacySimpleMapStorePerKey {
5050
cleanup_policy: CleanupPolicy,
5151
}
5252

53+
#[allow(deprecated)]
5354
impl LegacySimpleMapStorePerKey {
5455
pub fn new(streaming_config: Arc<StreamingConfig>, cleanup_policy: CleanupPolicy) -> Self {
5556
Self {
@@ -303,6 +304,7 @@ impl LegacySimpleMapStorePerKey {
303304
}
304305
}
305306

307+
#[allow(deprecated)]
306308
#[async_trait::async_trait]
307309
impl Store for LegacySimpleMapStorePerKey {
308310
fn insert_precomputed_output(

0 commit comments

Comments
 (0)