diff --git a/control_plane/src/asap_tier_analysis.rs b/control_plane/src/asap_tier_analysis.rs index 3bc2a064..6d448da1 100644 --- a/control_plane/src/asap_tier_analysis.rs +++ b/control_plane/src/asap_tier_analysis.rs @@ -1420,8 +1420,8 @@ mod tests { mod matching { use super::super::*; + use asap_types::KeyByLabelNames; use asap_types::{AggregationConfig, PolicyFingerprint, PolicyRegistry}; - use promql_utilities::data_model::KeyByLabelNames; use promql_utilities::query_logics::enums::AggregationType; use std::collections::HashMap; diff --git a/crates/asap_types/src/aggregation_config.rs b/crates/asap_types/src/aggregation_config.rs index d3d2da5f..d7b49a84 100644 --- a/crates/asap_types/src/aggregation_config.rs +++ b/crates/asap_types/src/aggregation_config.rs @@ -7,7 +7,7 @@ use crate::enums::{QueryLanguage, WindowType}; use crate::policy_fingerprint::PolicyFingerprint; use crate::traits::SerializableToSink; use crate::utils::normalize_spatial_filter; -use promql_utilities::data_model::KeyByLabelNames; +use crate::KeyByLabelNames; use promql_utilities::query_logics::enums::AggregationType; /// Per-aggregation policy carried in the streaming config. @@ -395,18 +395,12 @@ mod tests { /// SAME config as a fixture without it. #[test] fn explicit_aggregation_id_in_yaml_is_ignored() { - let with = AggregationConfig::from_yaml_data( - &sample_yaml(true), - None, - QueryLanguage::promql, - ) - .expect("parse ok"); - let without = AggregationConfig::from_yaml_data( - &sample_yaml(false), - None, - QueryLanguage::promql, - ) - .expect("parse ok"); + let with = + AggregationConfig::from_yaml_data(&sample_yaml(true), None, QueryLanguage::promql) + .expect("parse ok"); + let without = + AggregationConfig::from_yaml_data(&sample_yaml(false), None, QueryLanguage::promql) + .expect("parse ok"); assert_eq!( with.policy_fingerprint(), without.policy_fingerprint(), @@ -417,18 +411,10 @@ mod tests { /// Round-tripping the same content yields the same fingerprint. #[test] fn fingerprint_is_deterministic_per_content() { - let a = AggregationConfig::from_yaml_data( - &sample_yaml(false), - None, - QueryLanguage::promql, - ) - .expect("parse a"); - let b = AggregationConfig::from_yaml_data( - &sample_yaml(false), - None, - QueryLanguage::promql, - ) - .expect("parse b"); + let a = AggregationConfig::from_yaml_data(&sample_yaml(false), None, QueryLanguage::promql) + .expect("parse a"); + let b = AggregationConfig::from_yaml_data(&sample_yaml(false), None, QueryLanguage::promql) + .expect("parse b"); assert_eq!(a.policy_fingerprint(), b.policy_fingerprint()); assert_ne!( a.policy_fingerprint().as_u64(), @@ -440,24 +426,18 @@ mod tests { /// The `policy_fp_u64()` accessor is exactly the fingerprint u64. #[test] fn policy_fp_u64_accessor_equals_fingerprint_u64() { - let cfg = AggregationConfig::from_yaml_data( - &sample_yaml(false), - None, - QueryLanguage::promql, - ) - .expect("parse"); + let cfg = + AggregationConfig::from_yaml_data(&sample_yaml(false), None, QueryLanguage::promql) + .expect("parse"); assert_eq!(cfg.policy_fp_u64(), cfg.policy_fingerprint().as_u64()); } /// PR 5: `serialize_to_json` no longer emits `aggregationId`. #[test] fn serialize_to_json_omits_aggregation_id() { - let cfg = AggregationConfig::from_yaml_data( - &sample_yaml(false), - None, - QueryLanguage::promql, - ) - .expect("parse"); + let cfg = + AggregationConfig::from_yaml_data(&sample_yaml(false), None, QueryLanguage::promql) + .expect("parse"); let json = cfg.serialize_to_json(); assert!( json.get("aggregationId").is_none(), diff --git a/crates/asap_types/src/capability_matching.rs b/crates/asap_types/src/capability_matching.rs index 1a6627cf..871e40f6 100644 --- a/crates/asap_types/src/capability_matching.rs +++ b/crates/asap_types/src/capability_matching.rs @@ -1,8 +1,8 @@ use std::cmp::Ordering; use std::collections::HashMap; -use promql_utilities::data_model::KeyByLabelNames; -use promql_utilities::query_logics::enums::Statistic; +use crate::KeyByLabelNames; +use crate::Statistic; use serde::{Deserialize, Serialize}; use tracing::{debug, warn}; @@ -556,7 +556,7 @@ pub fn find_compatible_aggregation( mod tests { use super::*; use crate::utils::normalize_spatial_filter; - use promql_utilities::data_model::KeyByLabelNames; + use crate::KeyByLabelNames; use std::collections::HashMap; #[allow(clippy::too_many_arguments)] @@ -1018,7 +1018,16 @@ mod tests { #[test] fn avg_finds_sum_and_count() { let sum = make_config(1, "cpu", "Sum", "", 300, "tumbling", &["job"], ""); - let cnt = make_config(2, "cpu", "CountMinSketch", "", 300, "tumbling", &["job"], ""); + let cnt = make_config( + 2, + "cpu", + "CountMinSketch", + "", + 300, + "tumbling", + &["job"], + "", + ); let mut configs = HashMap::new(); configs.insert(sum.policy_fp_u64(), sum); configs.insert(cnt.policy_fp_u64(), cnt); @@ -1039,7 +1048,16 @@ mod tests { fn avg_different_windows_rejected() { let sum = make_config(1, "cpu", "Sum", "", 300, "tumbling", &["job"], ""); // Count config has different window_size — must be rejected - let cnt = make_config(2, "cpu", "CountMinSketch", "", 900, "tumbling", &["job"], ""); + let cnt = make_config( + 2, + "cpu", + "CountMinSketch", + "", + 900, + "tumbling", + &["job"], + "", + ); let mut configs = HashMap::new(); configs.insert(sum.policy_fp_u64(), sum); configs.insert(cnt.policy_fp_u64(), cnt); @@ -1204,8 +1222,7 @@ mod tests { StorageBackend::SketchStore, StorageBackend::DoubleWrite, ] { - let backends = - compatible_storage_backends(Statistic::Sum, AccuracyTarget::Exact, cfg); + let backends = compatible_storage_backends(Statistic::Sum, AccuracyTarget::Exact, cfg); assert_eq!( backends, vec![StorageBackend::GorillaObjectStore], @@ -1225,11 +1242,8 @@ mod tests { StorageBackend::GorillaObjectStore, StorageBackend::DoubleWrite, ] { - let backends = compatible_storage_backends( - Statistic::Quantile, - AccuracyTarget::Approximate, - cfg, - ); + let backends = + compatible_storage_backends(Statistic::Quantile, AccuracyTarget::Approximate, cfg); assert_eq!( backends, vec![ diff --git a/crates/asap_types/src/enums.rs b/crates/asap_types/src/enums.rs index 6534a8e5..fcf68e49 100644 --- a/crates/asap_types/src/enums.rs +++ b/crates/asap_types/src/enums.rs @@ -1,9 +1,85 @@ use std::fmt; use std::str::FromStr; +use tracing::debug; // Re-export AggregationType from promql_utilities (defined there to avoid circular deps). pub use promql_utilities::query_logics::enums::AggregationType; +/// The scalar value a serving-time query wants out of an already-built +/// accumulator: "given a live `AggregateCore` implementation, which +/// number do you want?" Every accumulator's `AggregateCore::query_statistic` +/// dispatches on this. Distinct from L3's `AggIntent` (a planning-time +/// IR node carrying accuracy targets, column refs, φ, k) — nothing at +/// L3/L4 reaches down to a live Rust struct's fields, so `Statistic` has +/// no upstream ASAPController equivalent; it's this workspace's own +/// serving-time vocabulary. +/// +/// Formerly `promql_utilities::query_logics::enums::Statistic` — moved +/// here because its real center of gravity (`compatible_agg_types`, +/// `QueryRequirements`, capability matching) already lived in this +/// crate, and `asap_types` — not `data_plane` — is the shared foundation +/// both `control_plane`'s ecosystem and `data_plane` can depend on +/// without a cycle. +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize)] +pub enum Statistic { + Count, + Sum, + Cardinality, + Increase, + Rate, + Min, + Max, + Quantile, + Topk, +} + +impl fmt::Display for Statistic { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + debug!("Formatting Statistic: {:?}", self); + match self { + Statistic::Count => write!(f, "count"), + Statistic::Sum => write!(f, "sum"), + Statistic::Cardinality => write!(f, "cardinality"), + Statistic::Increase => write!(f, "increase"), + Statistic::Rate => write!(f, "rate"), + Statistic::Min => write!(f, "min"), + Statistic::Max => write!(f, "max"), + Statistic::Quantile => write!(f, "quantile"), + Statistic::Topk => write!(f, "topk"), + } + } +} + +#[allow(clippy::should_implement_trait)] +impl Statistic { + pub fn from_str(s: &str) -> Option { + debug!("Parsing Statistic from string: {}", s); + match s.to_lowercase().as_str() { + "count" => Some(Statistic::Count), + "sum" => Some(Statistic::Sum), + "cardinality" => Some(Statistic::Cardinality), + "increase" => Some(Statistic::Increase), + "rate" => Some(Statistic::Rate), + "min" => Some(Statistic::Min), + "max" => Some(Statistic::Max), + "quantile" => Some(Statistic::Quantile), + "topk" => Some(Statistic::Topk), + _ => None, + } + } +} + +impl FromStr for Statistic { + type Err = (); + + /// Parse a statistic from a string (case-insensitive). + /// Use `s.parse::()` or `Statistic::from_str(s)`. + fn from_str(s: &str) -> Result { + debug!("FromStr trait parsing Statistic: {}", s); + Statistic::from_str(s).ok_or(()) + } +} + #[derive(clap::ValueEnum, Clone, Copy, Debug, PartialEq)] #[allow(non_camel_case_types)] pub enum QueryLanguage { diff --git a/crates/promql_utilities/src/data_model/key_by_label_names.rs b/crates/asap_types/src/key_by_label_names.rs similarity index 85% rename from crates/promql_utilities/src/data_model/key_by_label_names.rs rename to crates/asap_types/src/key_by_label_names.rs index df4f0f04..deb7fe3f 100644 --- a/crates/promql_utilities/src/data_model/key_by_label_names.rs +++ b/crates/asap_types/src/key_by_label_names.rs @@ -1,3 +1,16 @@ +//! A sorted, set-algebra-bearing label-name key. +//! +//! Formerly `promql_utilities::data_model::key_by_label_names` — moved +//! here for the same reason as [`crate::Statistic`]: `asap_types` +//! (`AggregationConfig::grouping_labels`, `PolicyFingerprint`, +//! `PolicyRegistry`, `capability_matching`) is its real center of +//! gravity and the shared foundation both `control_plane`'s ecosystem +//! and `data_plane` can depend on without a cycle. Closer to a runtime +//! index key than a planning IR node — ASAPController's +//! `QueryExpr::Aggregate.by` is the nearest relative in spirit, but +//! carries positional `ColumnId`s, not a sorted, deduplicated label-name +//! set with `Vec`-style set algebra. + use serde::{Deserialize, Serialize}; use tracing::debug; diff --git a/crates/asap_types/src/lib.rs b/crates/asap_types/src/lib.rs index a028b25c..269f0e6d 100644 --- a/crates/asap_types/src/lib.rs +++ b/crates/asap_types/src/lib.rs @@ -1,6 +1,7 @@ pub mod aggregation_config; pub mod capability_matching; pub mod enums; +pub mod key_by_label_names; pub mod policy_fingerprint; pub mod policy_registry; pub mod query_requirements; @@ -15,6 +16,7 @@ pub use capability_matching::{ ENGINE_ID_THANOS_QUERY, }; pub use enums::*; +pub use key_by_label_names::KeyByLabelNames; pub use policy_fingerprint::PolicyFingerprint; pub use policy_registry::PolicyRegistry; pub use query_requirements::*; diff --git a/crates/asap_types/src/policy_fingerprint.rs b/crates/asap_types/src/policy_fingerprint.rs index a330c69f..9b365308 100644 --- a/crates/asap_types/src/policy_fingerprint.rs +++ b/crates/asap_types/src/policy_fingerprint.rs @@ -109,9 +109,7 @@ impl PolicyFingerprint { for (k, v) in sorted { buf.extend_from_slice(k.as_bytes()); buf.push(b'='); - buf.extend_from_slice( - serde_json::to_string(v).unwrap_or_default().as_bytes(), - ); + buf.extend_from_slice(serde_json::to_string(v).unwrap_or_default().as_bytes()); buf.push(b';'); } buf.push(0); @@ -175,7 +173,7 @@ impl std::fmt::Display for PolicyFingerprint { mod tests { use super::*; use crate::enums::WindowType; - use promql_utilities::data_model::KeyByLabelNames; + use crate::KeyByLabelNames; use promql_utilities::query_logics::enums::AggregationType; use std::collections::HashMap; @@ -208,28 +206,86 @@ mod tests { #[test] fn same_config_yields_same_fingerprint() { - let a = cfg("http_lat", AggregationType::Sum, HashMap::new(), vec!["zone"], 60, ""); - let b = cfg("http_lat", AggregationType::Sum, HashMap::new(), vec!["zone"], 60, ""); - assert_eq!(PolicyFingerprint::from_config(&a), PolicyFingerprint::from_config(&b)); + let a = cfg( + "http_lat", + AggregationType::Sum, + HashMap::new(), + vec!["zone"], + 60, + "", + ); + let b = cfg( + "http_lat", + AggregationType::Sum, + HashMap::new(), + vec!["zone"], + 60, + "", + ); + assert_eq!( + PolicyFingerprint::from_config(&a), + PolicyFingerprint::from_config(&b) + ); } #[test] fn different_metric_yields_different_fingerprint() { - let a = cfg("http_lat", AggregationType::Sum, HashMap::new(), vec![], 60, ""); - let b = cfg("cpu_pct", AggregationType::Sum, HashMap::new(), vec![], 60, ""); - assert_ne!(PolicyFingerprint::from_config(&a), PolicyFingerprint::from_config(&b)); + let a = cfg( + "http_lat", + AggregationType::Sum, + HashMap::new(), + vec![], + 60, + "", + ); + let b = cfg( + "cpu_pct", + AggregationType::Sum, + HashMap::new(), + vec![], + 60, + "", + ); + assert_ne!( + PolicyFingerprint::from_config(&a), + PolicyFingerprint::from_config(&b) + ); } #[test] fn different_window_yields_different_fingerprint() { - let a = cfg("http_lat", AggregationType::Sum, HashMap::new(), vec![], 60, ""); - let b = cfg("http_lat", AggregationType::Sum, HashMap::new(), vec![], 300, ""); - assert_ne!(PolicyFingerprint::from_config(&a), PolicyFingerprint::from_config(&b)); + let a = cfg( + "http_lat", + AggregationType::Sum, + HashMap::new(), + vec![], + 60, + "", + ); + let b = cfg( + "http_lat", + AggregationType::Sum, + HashMap::new(), + vec![], + 300, + "", + ); + assert_ne!( + PolicyFingerprint::from_config(&a), + PolicyFingerprint::from_config(&b) + ); } #[test] fn different_spatial_filter_yields_different_fingerprint() { - let a = cfg("http_lat", AggregationType::Sum, HashMap::new(), vec![], 60, ""); + let a = cfg( + "http_lat", + AggregationType::Sum, + HashMap::new(), + vec![], + 60, + "", + ); let b = cfg( "http_lat", AggregationType::Sum, @@ -238,12 +294,22 @@ mod tests { 60, r#"status="200""#, ); - assert_ne!(PolicyFingerprint::from_config(&a), PolicyFingerprint::from_config(&b)); + assert_ne!( + PolicyFingerprint::from_config(&a), + PolicyFingerprint::from_config(&b) + ); } #[test] fn different_group_by_yields_different_fingerprint() { - let a = cfg("http_lat", AggregationType::Sum, HashMap::new(), vec!["zone"], 60, ""); + let a = cfg( + "http_lat", + AggregationType::Sum, + HashMap::new(), + vec!["zone"], + 60, + "", + ); let b = cfg( "http_lat", AggregationType::Sum, @@ -252,7 +318,10 @@ mod tests { 60, "", ); - assert_ne!(PolicyFingerprint::from_config(&a), PolicyFingerprint::from_config(&b)); + assert_ne!( + PolicyFingerprint::from_config(&a), + PolicyFingerprint::from_config(&b) + ); } /// Pre-PR-5 the `aggregation_id` field on `AggregationConfig` was @@ -262,7 +331,14 @@ mod tests { /// is needed. #[test] fn policy_fp_u64_accessor_equals_fingerprint_u64() { - let a = cfg("http_lat", AggregationType::Sum, HashMap::new(), vec![], 60, ""); + let a = cfg( + "http_lat", + AggregationType::Sum, + HashMap::new(), + vec![], + 60, + "", + ); assert_eq!( a.policy_fp_u64(), PolicyFingerprint::from_config(&a).as_u64(), @@ -271,7 +347,14 @@ mod tests { #[test] fn num_aggregates_to_retain_does_not_affect_fingerprint() { - let mut a = cfg("http_lat", AggregationType::Sum, HashMap::new(), vec![], 60, ""); + let mut a = cfg( + "http_lat", + AggregationType::Sum, + HashMap::new(), + vec![], + 60, + "", + ); let mut b = a.clone(); a.num_aggregates_to_retain = Some(100); b.num_aggregates_to_retain = Some(500); diff --git a/crates/asap_types/src/policy_registry.rs b/crates/asap_types/src/policy_registry.rs index bf646ebb..0bf7ed0b 100644 --- a/crates/asap_types/src/policy_registry.rs +++ b/crates/asap_types/src/policy_registry.rs @@ -116,7 +116,7 @@ impl PolicyRegistry { mod tests { use super::*; use crate::enums::WindowType; - use promql_utilities::data_model::KeyByLabelNames; + use crate::KeyByLabelNames; use promql_utilities::query_logics::enums::AggregationType; use std::collections::HashMap as StdHashMap; diff --git a/crates/asap_types/src/query_requirements.rs b/crates/asap_types/src/query_requirements.rs index 218d94d5..f7a4b264 100644 --- a/crates/asap_types/src/query_requirements.rs +++ b/crates/asap_types/src/query_requirements.rs @@ -1,5 +1,5 @@ -use promql_utilities::data_model::KeyByLabelNames; -use promql_utilities::query_logics::enums::Statistic; +use crate::KeyByLabelNames; +use crate::Statistic; /// What a query needs in order to be answered by a stored aggregation. #[derive(Debug, Clone)] diff --git a/crates/promql_utilities/src/data_model/mod.rs b/crates/promql_utilities/src/data_model/mod.rs deleted file mode 100644 index f587f435..00000000 --- a/crates/promql_utilities/src/data_model/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub mod key_by_label_names; - -pub use key_by_label_names::*; diff --git a/crates/promql_utilities/src/lib.rs b/crates/promql_utilities/src/lib.rs index 7bbe5e9d..b6d257db 100644 --- a/crates/promql_utilities/src/lib.rs +++ b/crates/promql_utilities/src/lib.rs @@ -1,5 +1,3 @@ -pub mod data_model; pub mod query_logics; -pub use data_model::*; pub use query_logics::*; diff --git a/crates/promql_utilities/src/query_logics/enums.rs b/crates/promql_utilities/src/query_logics/enums.rs index cdbcae26..2332341b 100644 --- a/crates/promql_utilities/src/query_logics/enums.rs +++ b/crates/promql_utilities/src/query_logics/enums.rs @@ -1,83 +1,6 @@ use serde::{Deserialize, Serialize}; use std::fmt; use std::str::FromStr; -use tracing::debug; - -#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)] -pub enum Statistic { - Count, - Sum, - Cardinality, - Increase, - Rate, - Min, - Max, - Quantile, - Topk, -} - -impl std::fmt::Display for Statistic { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - debug!("Formatting Statistic: {:?}", self); - match self { - Statistic::Count => write!(f, "count"), - Statistic::Sum => write!(f, "sum"), - Statistic::Cardinality => write!(f, "cardinality"), - Statistic::Increase => write!(f, "increase"), - Statistic::Rate => write!(f, "rate"), - Statistic::Min => write!(f, "min"), - Statistic::Max => write!(f, "max"), - Statistic::Quantile => write!(f, "quantile"), - Statistic::Topk => write!(f, "topk"), - } - } -} - -#[allow(clippy::should_implement_trait)] -impl Statistic { - pub fn from_str(s: &str) -> Option { - debug!("Parsing Statistic from string: {}", s); - match s.to_lowercase().as_str() { - "count" => Some(Statistic::Count), - "sum" => Some(Statistic::Sum), - "cardinality" => Some(Statistic::Cardinality), - "increase" => Some(Statistic::Increase), - "rate" => Some(Statistic::Rate), - "min" => Some(Statistic::Min), - "max" => Some(Statistic::Max), - "quantile" => Some(Statistic::Quantile), - "topk" => Some(Statistic::Topk), - _ => None, - } - } -} - -impl std::str::FromStr for Statistic { - type Err = (); - - /// Parse a statistic from a string (case-insensitive). - /// Use `s.parse::()` or `Statistic::from_str(s)`. - fn from_str(s: &str) -> Result { - debug!("FromStr trait parsing Statistic: {}", s); - Statistic::from_str(s).ok_or(()) - } -} - -#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)] -pub enum QueryResultType { - InstantVector, - RangeVector, -} - -impl std::fmt::Display for QueryResultType { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - debug!("Formatting QueryResultType: {:?}", self); - match self { - QueryResultType::InstantVector => write!(f, "instant_vector"), - QueryResultType::RangeVector => write!(f, "range_vector"), - } - } -} /// Concrete aggregation/sketch type used in precompute configs and accumulator dispatch. /// diff --git a/data_plane/benches/sketch_db.rs b/data_plane/benches/sketch_db.rs index a79d447f..5ac0c041 100644 --- a/data_plane/benches/sketch_db.rs +++ b/data_plane/benches/sketch_db.rs @@ -389,7 +389,7 @@ fn bench_query_precomputes_by_agg(c: &mut Criterion) { fn matching_streaming_config(metric: &str) -> data_plane::storage_engines::types::StreamingConfig { use asap_types::aggregation_config::AggregationConfig; use asap_types::enums::{AggregationType as AT, WindowType}; - use promql_utilities::data_model::key_by_label_names::KeyByLabelNames; + use asap_types::KeyByLabelNames; use std::collections::HashMap; let cfg = AggregationConfig::new( diff --git a/data_plane/src/drivers/control_plane_client/miss_notifier.rs b/data_plane/src/drivers/control_plane_client/miss_notifier.rs index 93fbe227..5a5a2af6 100644 --- a/data_plane/src/drivers/control_plane_client/miss_notifier.rs +++ b/data_plane/src/drivers/control_plane_client/miss_notifier.rs @@ -178,8 +178,8 @@ pub fn spawn_capability_miss_notify( #[cfg(test)] mod tests { use super::*; - use promql_utilities::data_model::KeyByLabelNames; - use promql_utilities::query_logics::enums::Statistic; + use asap_types::KeyByLabelNames; + use asap_types::Statistic; use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::Mutex; diff --git a/data_plane/src/drivers/ingest/otel.rs b/data_plane/src/drivers/ingest/otel.rs index e8e9d9bd..77b89828 100644 --- a/data_plane/src/drivers/ingest/otel.rs +++ b/data_plane/src/drivers/ingest/otel.rs @@ -4004,7 +4004,7 @@ mod sid_bucketing_tests { }; use asap_types::aggregation_config::AggregationConfig; use asap_types::enums::{AggregationType, WindowType}; - use promql_utilities::data_model::key_by_label_names::KeyByLabelNames; + use asap_types::KeyByLabelNames; use std::collections::HashMap; use std::sync::Arc; use tokio::sync::mpsc; diff --git a/data_plane/src/drivers/query/adapters/prometheus_http.rs b/data_plane/src/drivers/query/adapters/prometheus_http.rs index 6a838b7a..63a08811 100644 --- a/data_plane/src/drivers/query/adapters/prometheus_http.rs +++ b/data_plane/src/drivers/query/adapters/prometheus_http.rs @@ -2,13 +2,13 @@ use super::config::AdapterConfig; use super::traits::*; use crate::query_engines::QueryResult; use crate::utils::http::{convert_query_result_to_prometheus, convert_range_result_to_prometheus}; +use asap_types::KeyByLabelNames; use async_trait::async_trait; use axum::{ extract::{Form, Query}, http::StatusCode, response::{IntoResponse, Json, Response}, }; -use promql_utilities::data_model::KeyByLabelNames; use serde::{Deserialize, Serialize}; use serde_json::{json, Value}; use std::collections::HashMap; diff --git a/data_plane/src/drivers/query/adapters/traits.rs b/data_plane/src/drivers/query/adapters/traits.rs index 24ac3fa6..bbeb5997 100644 --- a/data_plane/src/drivers/query/adapters/traits.rs +++ b/data_plane/src/drivers/query/adapters/traits.rs @@ -1,3 +1,4 @@ +use asap_types::KeyByLabelNames; use async_trait::async_trait; use axum::{ body::Bytes, @@ -5,7 +6,6 @@ use axum::{ http::StatusCode, response::{Json, Response}, }; -use promql_utilities::data_model::KeyByLabelNames; use serde_json::Value; use std::collections::HashMap; diff --git a/data_plane/src/drivers/query/servers/http.rs b/data_plane/src/drivers/query/servers/http.rs index 8b30303a..8a81b034 100644 --- a/data_plane/src/drivers/query/servers/http.rs +++ b/data_plane/src/drivers/query/servers/http.rs @@ -20,8 +20,8 @@ use crate::query_engines::routing::{ EngineRouter, EngineRouterError, FreshnessProbeCache, QueryEngine, }; use crate::query_engines::ASAPQueryEngine; +use asap_types::Statistic; use asap_types::{AccuracyTarget, StorageBackend}; -use promql_utilities::query_logics::enums::Statistic; // ─── Control-plane-pushed precompute job registry ──────────────────────────── // @@ -1007,7 +1007,7 @@ async fn try_answer_freshness_probe( ) -> Option { use crate::drivers::query::adapters::QueryExecutionResult; use crate::query_engines::query_result::{InstantVectorElement, QueryResult}; - use promql_utilities::data_model::KeyByLabelNames; + use asap_types::KeyByLabelNames; let cache = state.probe_cache.as_ref()?; let (metric, range_ms) = parse_last_over_time_probe(&parsed_request.query)?; @@ -1140,7 +1140,7 @@ async fn process_via_simple_engine( query_duration.as_secs_f64() * 1000.0 ); let execution_result = QueryExecutionResult { - query_output_labels: promql_utilities::data_model::KeyByLabelNames::default(), + query_output_labels: asap_types::KeyByLabelNames::default(), query_result, }; let total_duration = start_time.elapsed(); @@ -1267,7 +1267,7 @@ async fn process_via_named_engine( // `process_via_router`. Default to empty so the // Prometheus adapter renders `metric: {}` for every // returned series. - let query_output_labels = promql_utilities::data_model::KeyByLabelNames::default(); + let query_output_labels = asap_types::KeyByLabelNames::default(); let execution_result = QueryExecutionResult { query_output_labels, query_result, @@ -1389,7 +1389,7 @@ async fn process_via_router( // — the Prometheus adapter renders an empty `metric: {}`, // which is a valid Prometheus shape (every label is just // unset) and matches `wrap_result`'s Phase-4 contract. - let query_output_labels = promql_utilities::data_model::KeyByLabelNames::default(); + let query_output_labels = asap_types::KeyByLabelNames::default(); let execution_result = QueryExecutionResult { query_output_labels, query_result, @@ -1944,7 +1944,7 @@ async fn process_range_query_request( .adapter .format_range_success_response( &query_result, - &promql_utilities::data_model::KeyByLabelNames::default(), + &asap_types::KeyByLabelNames::default(), ) .await { @@ -3045,7 +3045,7 @@ aggregations: ) -> (u16, std::collections::HashMap) { use asap_types::aggregation_config::AggregationConfig; use asap_types::enums::{AggregationType, WindowType}; - use promql_utilities::data_model::key_by_label_names::KeyByLabelNames; + use asap_types::KeyByLabelNames; use std::collections::HashMap; let adapter_config = diff --git a/data_plane/src/precompute_engine/accumulator_factory.rs b/data_plane/src/precompute_engine/accumulator_factory.rs index b7230126..2ddbf538 100644 --- a/data_plane/src/precompute_engine/accumulator_factory.rs +++ b/data_plane/src/precompute_engine/accumulator_factory.rs @@ -660,9 +660,7 @@ impl AccumulatorUpdater for CmsHeapAccumulatorUpdater { // Σ count: one occurrence per event, regardless of value. TopkWeight::Count => 1.0, }; - self.acc - .inner - .update(&key.to_semicolon_str(), weighted); + self.acc.inner.update(&key.to_semicolon_str(), weighted); } impl_clone_accumulator_methods!(acc); @@ -1031,9 +1029,9 @@ mod tests { agg_type, sub_type.to_string(), HashMap::new(), - promql_utilities::data_model::key_by_label_names::KeyByLabelNames::new(vec![]), - promql_utilities::data_model::key_by_label_names::KeyByLabelNames::new(vec![]), - promql_utilities::data_model::key_by_label_names::KeyByLabelNames::new(vec![]), + asap_types::KeyByLabelNames::new(vec![]), + asap_types::KeyByLabelNames::new(vec![]), + asap_types::KeyByLabelNames::new(vec![]), String::new(), 60, 0, @@ -1125,9 +1123,9 @@ mod tests { AggregationType::SingleSubpopulation, "DatasketchesKLL".to_string(), params, - promql_utilities::data_model::key_by_label_names::KeyByLabelNames::new(vec![]), - promql_utilities::data_model::key_by_label_names::KeyByLabelNames::new(vec![]), - promql_utilities::data_model::key_by_label_names::KeyByLabelNames::new(vec![]), + asap_types::KeyByLabelNames::new(vec![]), + asap_types::KeyByLabelNames::new(vec![]), + asap_types::KeyByLabelNames::new(vec![]), String::new(), 60, 0, @@ -1162,9 +1160,9 @@ mod tests { AggregationType::CountMinSketch, String::new(), params, - promql_utilities::data_model::key_by_label_names::KeyByLabelNames::new(vec![]), - promql_utilities::data_model::key_by_label_names::KeyByLabelNames::new(vec![]), - promql_utilities::data_model::key_by_label_names::KeyByLabelNames::new(vec![]), + asap_types::KeyByLabelNames::new(vec![]), + asap_types::KeyByLabelNames::new(vec![]), + asap_types::KeyByLabelNames::new(vec![]), String::new(), 60, 0, @@ -1182,9 +1180,9 @@ mod tests { AggregationType::CountMinSketch, String::new(), HashMap::new(), - promql_utilities::data_model::key_by_label_names::KeyByLabelNames::new(vec![]), - promql_utilities::data_model::key_by_label_names::KeyByLabelNames::new(vec![]), - promql_utilities::data_model::key_by_label_names::KeyByLabelNames::new(vec![]), + asap_types::KeyByLabelNames::new(vec![]), + asap_types::KeyByLabelNames::new(vec![]), + asap_types::KeyByLabelNames::new(vec![]), String::new(), 60, 0, @@ -1218,12 +1216,10 @@ mod tests { agg_type, String::new(), params, - promql_utilities::data_model::key_by_label_names::KeyByLabelNames::new(vec![]), + asap_types::KeyByLabelNames::new(vec![]), // group-by = `host` (NOT the metric label `item`). - promql_utilities::data_model::key_by_label_names::KeyByLabelNames::new(vec![ - "host".to_string(), - ]), - promql_utilities::data_model::key_by_label_names::KeyByLabelNames::new(vec![]), + asap_types::KeyByLabelNames::new(vec!["host".to_string()]), + asap_types::KeyByLabelNames::new(vec![]), String::new(), 60, 0, @@ -1345,10 +1341,7 @@ mod tests { #[test] fn topk_weight_param_parses_modes() { assert_eq!( - super::topk_weight_param(&topk_config( - AggregationType::CountMinSketchWithHeap, - None - )), + super::topk_weight_param(&topk_config(AggregationType::CountMinSketchWithHeap, None)), TopkWeight::Value, "unset defaults to value-weighted" ); diff --git a/data_plane/src/precompute_engine/ingest_handler.rs b/data_plane/src/precompute_engine/ingest_handler.rs index b08d035c..0b08c9d4 100644 --- a/data_plane/src/precompute_engine/ingest_handler.rs +++ b/data_plane/src/precompute_engine/ingest_handler.rs @@ -299,7 +299,7 @@ mod tests { use crate::storage_engines::types::StreamingConfig; use asap_types::aggregation_config::AggregationConfig; use asap_types::enums::{AggregationType, WindowType}; - use promql_utilities::data_model::key_by_label_names::KeyByLabelNames; + use asap_types::KeyByLabelNames; use std::sync::Arc; use tokio::sync::mpsc; diff --git a/data_plane/src/precompute_engine/operators/count_min_sketch_accumulator.rs b/data_plane/src/precompute_engine/operators/count_min_sketch_accumulator.rs index 7eab396b..b3307fdf 100644 --- a/data_plane/src/precompute_engine/operators/count_min_sketch_accumulator.rs +++ b/data_plane/src/precompute_engine/operators/count_min_sketch_accumulator.rs @@ -7,7 +7,7 @@ use asap_sketchlib::{CountMinSketch, CountMinSketchDelta, MessagePackCodec}; use serde_json::Value; use std::collections::HashMap; -use promql_utilities::query_logics::enums::Statistic; +use asap_types::Statistic; /// Count-Min Sketch accumulator — wraps asap_sketchlib::CountMinSketch. /// Core struct, update/merge/serde logic live in `asap_sketchlib::sketches`. @@ -511,12 +511,12 @@ impl AggregateCore for CountMinSketchAccumulator { fn query_statistic( &self, - statistic: promql_utilities::query_logics::enums::Statistic, + statistic: asap_types::Statistic, key: &Option, query_kwargs: &std::collections::HashMap, ) -> Result> { use crate::storage_engines::types::MultipleSubpopulationAggregate; - use promql_utilities::query_logics::enums::Statistic; + use asap_types::Statistic; // Key-provided path: route to MultipleSubpopulationAggregate::query // (the canonical "what's the count of this key?" lookup). @@ -1188,7 +1188,10 @@ mod tests { let raw = unsampled.query_key(&key); let rescaled = sampled.query_key(&key); - assert!(raw >= 10.0, "raw estimate should be >= inserted 10, got {raw}"); + assert!( + raw >= 10.0, + "raw estimate should be >= inserted 10, got {raw}" + ); assert!( (rescaled - raw * 4.0).abs() < 1e-9, "expected point-frequency rescaled ≈ 4×raw ({}), got {rescaled}", @@ -1198,7 +1201,7 @@ mod tests { #[test] fn test_aggregate_statistics_rescaled_by_sample_p() { - use promql_utilities::query_logics::enums::Statistic; + use asap_types::Statistic; // Build a CMS with a known min-row-sum of 12 events, sampled at // p=0.25 → every aggregate statistic should report 12 / 0.25 = 48. let cms = CountMinSketchAccumulator { @@ -1260,7 +1263,7 @@ mod tests { use asap_sketchlib::proto::sketchlib::{ sketch_envelope, CountMinState, CounterType, SketchEnvelope, }; - use promql_utilities::query_logics::enums::Statistic; + use asap_types::Statistic; use prost::Message; // min-row-sum = 12 raw; sample_p 0.25 → Count = 48. let state = CountMinState { diff --git a/data_plane/src/precompute_engine/operators/count_min_sketch_with_heap_accumulator.rs b/data_plane/src/precompute_engine/operators/count_min_sketch_with_heap_accumulator.rs index 59f12bbb..3eea0afd 100644 --- a/data_plane/src/precompute_engine/operators/count_min_sketch_with_heap_accumulator.rs +++ b/data_plane/src/precompute_engine/operators/count_min_sketch_with_heap_accumulator.rs @@ -7,7 +7,7 @@ use serde::Deserialize; use serde_json::Value; use std::collections::HashMap; -use promql_utilities::query_logics::enums::Statistic; +use asap_types::Statistic; /// Local serde view of the DELTA-HEAP wire frame produced by sketchlib-go's /// `CountSketch.SerializeMsgpackWithHeapDelta` (encoding `MSGPACK_DELTA`). @@ -386,7 +386,7 @@ impl AggregateCore for CountMinSketchWithHeapAccumulator { fn query_statistic( &self, - statistic: promql_utilities::query_logics::enums::Statistic, + statistic: asap_types::Statistic, key: &Option, query_kwargs: &std::collections::HashMap, ) -> Result> { diff --git a/data_plane/src/precompute_engine/operators/count_sketch_accumulator.rs b/data_plane/src/precompute_engine/operators/count_sketch_accumulator.rs index ebd00762..bd0b63fc 100644 --- a/data_plane/src/precompute_engine/operators/count_sketch_accumulator.rs +++ b/data_plane/src/precompute_engine/operators/count_sketch_accumulator.rs @@ -281,11 +281,11 @@ impl AggregateCore for CountSketchAccumulator { fn query_statistic( &self, - statistic: promql_utilities::query_logics::enums::Statistic, + statistic: asap_types::Statistic, _key: &Option, query_kwargs: &HashMap, ) -> Result> { - use promql_utilities::query_logics::enums::Statistic; + use asap_types::Statistic; // Use median-of-row estimator for a specific key when the // caller provides one in `query_kwargs["key"]`. Without a // key, fall back to summing the absolute counter values diff --git a/data_plane/src/precompute_engine/operators/datasketches_kll_accumulator.rs b/data_plane/src/precompute_engine/operators/datasketches_kll_accumulator.rs index 9bdf530c..9b8dda9f 100644 --- a/data_plane/src/precompute_engine/operators/datasketches_kll_accumulator.rs +++ b/data_plane/src/precompute_engine/operators/datasketches_kll_accumulator.rs @@ -10,7 +10,7 @@ use std::collections::HashMap; use std::time::Instant; use tracing::debug; -use promql_utilities::query_logics::enums::Statistic; +use asap_types::Statistic; /// KLL sketch accumulator — wraps asap_sketchlib::KllSketch. /// Core struct, update/merge/serde logic live in `asap_sketchlib::sketches`. @@ -314,7 +314,7 @@ impl AggregateCore for DatasketchesKLLAccumulator { fn query_statistic( &self, - statistic: promql_utilities::query_logics::enums::Statistic, + statistic: asap_types::Statistic, _key: &Option, query_kwargs: &std::collections::HashMap, ) -> Result> { diff --git a/data_plane/src/precompute_engine/operators/dd_sketch_accumulator.rs b/data_plane/src/precompute_engine/operators/dd_sketch_accumulator.rs index f2a62760..6a809234 100644 --- a/data_plane/src/precompute_engine/operators/dd_sketch_accumulator.rs +++ b/data_plane/src/precompute_engine/operators/dd_sketch_accumulator.rs @@ -272,11 +272,11 @@ impl AggregateCore for DDSketchAccumulator { fn query_statistic( &self, - statistic: promql_utilities::query_logics::enums::Statistic, + statistic: asap_types::Statistic, _key: &Option, query_kwargs: &HashMap, ) -> Result> { - use promql_utilities::query_logics::enums::Statistic; + use asap_types::Statistic; match statistic { Statistic::Quantile => { @@ -507,7 +507,7 @@ mod tests { #[test] fn test_query_statistic_quantile_is_sketch_derived() { - use promql_utilities::query_logics::enums::Statistic; + use asap_types::Statistic; let acc = sample_accumulator(); let mut kwargs = HashMap::new(); kwargs.insert("quantile".to_string(), "0.5".to_string()); @@ -522,7 +522,7 @@ mod tests { #[test] fn test_query_statistic_count_is_bucket_derived() { - use promql_utilities::query_logics::enums::Statistic; + use asap_types::Statistic; let acc = sample_accumulator(); let v = acc .query_statistic(Statistic::Count, &None, &HashMap::new()) @@ -533,7 +533,7 @@ mod tests { #[test] fn test_query_statistic_sum_min_max_return_unavailable_error() { - use promql_utilities::query_logics::enums::Statistic; + use asap_types::Statistic; let acc = sample_accumulator(); for stat in [Statistic::Sum, Statistic::Min, Statistic::Max] { let result = acc.query_statistic(stat, &None, &HashMap::new()); @@ -557,7 +557,7 @@ mod tests { #[test] fn test_count_is_rescaled_by_sample_p() { - use promql_utilities::query_logics::enums::Statistic; + use asap_types::Statistic; let acc = DDSketchAccumulator { inner: DdSketch::from_raw(0.01, vec![1, 2, 3, 4], -2), sample_p: 0.1, @@ -571,7 +571,7 @@ mod tests { #[test] fn test_quantile_ignores_sample_p() { - use promql_utilities::query_logics::enums::Statistic; + use asap_types::Statistic; let mut kwargs = HashMap::new(); kwargs.insert("quantile".to_string(), "0.5".to_string()); let unsampled = DDSketchAccumulator { @@ -594,7 +594,7 @@ mod tests { #[test] fn test_from_sketchlib_proto_bytes_reads_envelope_sample_p() { use asap_sketchlib::proto::sketchlib::{sketch_envelope, DdSketchState, SketchEnvelope}; - use promql_utilities::query_logics::enums::Statistic; + use asap_types::Statistic; use prost::Message; let env = SketchEnvelope { diff --git a/data_plane/src/precompute_engine/operators/hll_sketch_accumulator.rs b/data_plane/src/precompute_engine/operators/hll_sketch_accumulator.rs index b5eff48d..b2172c7e 100644 --- a/data_plane/src/precompute_engine/operators/hll_sketch_accumulator.rs +++ b/data_plane/src/precompute_engine/operators/hll_sketch_accumulator.rs @@ -335,11 +335,11 @@ impl AggregateCore for HllSketchAccumulator { fn query_statistic( &self, - statistic: promql_utilities::query_logics::enums::Statistic, + statistic: asap_types::Statistic, _key: &Option, _query_kwargs: &HashMap, ) -> Result> { - use promql_utilities::query_logics::enums::Statistic; + use asap_types::Statistic; match statistic { // HLL's natural answer is unique-cardinality. PromQL's // `count_over_time(...)` and `count(...)` both surface @@ -630,7 +630,7 @@ mod tests { #[test] fn test_cardinality_is_rescaled_by_sample_p() { - use promql_utilities::query_logics::enums::Statistic; + use asap_types::Statistic; // Build two accumulators with identical registers but different // sample_p. The sampled one (p=0.25) must report ~4× the unsampled // estimate. Use precision 8 (256 registers) with a spread of @@ -664,7 +664,7 @@ mod tests { #[test] fn test_count_statistic_also_rescaled_by_sample_p() { - use promql_utilities::query_logics::enums::Statistic; + use asap_types::Statistic; // Count maps to the same cardinality estimate for HLL, so it must // rescale identically. let registers = vec![3u8; 16]; @@ -717,7 +717,7 @@ mod tests { use asap_sketchlib::proto::sketchlib::{ sketch_envelope, HllVariant as ProtoVariant, HyperLogLogState, SketchEnvelope, }; - use promql_utilities::query_logics::enums::Statistic; + use asap_types::Statistic; use prost::Message; let registers = vec![3u8; 16]; @@ -750,7 +750,10 @@ mod tests { let rescaled = acc .query_statistic(Statistic::Cardinality, &None, &HashMap::new()) .expect("cardinality ok"); - assert!((rescaled - raw * 4.0).abs() < 1e-9, "expected 4×raw rescale"); + assert!( + (rescaled - raw * 4.0).abs() < 1e-9, + "expected 4×raw rescale" + ); } #[test] diff --git a/data_plane/src/precompute_engine/operators/hydra_kll_accumulator.rs b/data_plane/src/precompute_engine/operators/hydra_kll_accumulator.rs index f059db7c..c3793584 100644 --- a/data_plane/src/precompute_engine/operators/hydra_kll_accumulator.rs +++ b/data_plane/src/precompute_engine/operators/hydra_kll_accumulator.rs @@ -9,7 +9,7 @@ use asap_sketchlib::{HydraKllSketch, MessagePackCodec}; use base64::{engine::general_purpose, Engine as _}; use std::collections::HashMap; -use promql_utilities::query_logics::enums::Statistic; +use asap_types::Statistic; /// HydraKLL sketch accumulator — wraps asap_sketchlib::HydraKllSketch. /// Core struct, update/merge/serde logic live in `asap_sketchlib::sketches`. @@ -123,7 +123,7 @@ impl AggregateCore for HydraKllSketchAccumulator { fn query_statistic( &self, - statistic: promql_utilities::query_logics::enums::Statistic, + statistic: asap_types::Statistic, key: &Option, query_kwargs: &std::collections::HashMap, ) -> Result> { diff --git a/data_plane/src/precompute_engine/operators/increase_accumulator.rs b/data_plane/src/precompute_engine/operators/increase_accumulator.rs index 1085907c..9d55a5ad 100644 --- a/data_plane/src/precompute_engine/operators/increase_accumulator.rs +++ b/data_plane/src/precompute_engine/operators/increase_accumulator.rs @@ -6,7 +6,7 @@ use serde::{Deserialize, Serialize}; use serde_json::Value; use std::collections::HashMap; -use promql_utilities::query_logics::enums::Statistic; +use asap_types::Statistic; /// Accumulator for tracking increases in counter metrics /// Stores the starting and last seen measurements with timestamps @@ -260,7 +260,7 @@ impl AggregateCore for IncreaseAccumulator { fn query_statistic( &self, - statistic: promql_utilities::query_logics::enums::Statistic, + statistic: asap_types::Statistic, _key: &Option, _query_kwargs: &std::collections::HashMap, ) -> Result> { diff --git a/data_plane/src/precompute_engine/operators/min_max_accumulator.rs b/data_plane/src/precompute_engine/operators/min_max_accumulator.rs index 50c14574..6162b4a9 100644 --- a/data_plane/src/precompute_engine/operators/min_max_accumulator.rs +++ b/data_plane/src/precompute_engine/operators/min_max_accumulator.rs @@ -6,7 +6,7 @@ use serde::{Deserialize, Serialize}; use serde_json::Value; use std::collections::HashMap; -use promql_utilities::query_logics::enums::Statistic; +use asap_types::Statistic; #[derive(Debug, Clone, Serialize, Deserialize)] pub struct MinMaxAccumulator { @@ -221,7 +221,7 @@ impl AggregateCore for MinMaxAccumulator { fn query_statistic( &self, - statistic: promql_utilities::query_logics::enums::Statistic, + statistic: asap_types::Statistic, _key: &Option, _query_kwargs: &std::collections::HashMap, ) -> Result> { diff --git a/data_plane/src/precompute_engine/operators/multiple_increase_accumulator.rs b/data_plane/src/precompute_engine/operators/multiple_increase_accumulator.rs index a7a092c6..3cbad333 100644 --- a/data_plane/src/precompute_engine/operators/multiple_increase_accumulator.rs +++ b/data_plane/src/precompute_engine/operators/multiple_increase_accumulator.rs @@ -7,7 +7,7 @@ use serde::{Deserialize, Serialize}; use serde_json::Value; use std::collections::HashMap; -use promql_utilities::query_logics::enums::Statistic; +use asap_types::Statistic; /// Accumulator that maintains separate increase accumulators for multiple keys /// Allows tracking rate/increase for different label combinations @@ -235,7 +235,7 @@ impl AggregateCore for MultipleIncreaseAccumulator { fn query_statistic( &self, - statistic: promql_utilities::query_logics::enums::Statistic, + statistic: asap_types::Statistic, key: &Option, query_kwargs: &std::collections::HashMap, ) -> Result> { diff --git a/data_plane/src/precompute_engine/operators/multiple_min_max_accumulator.rs b/data_plane/src/precompute_engine/operators/multiple_min_max_accumulator.rs index 6a876c1b..46c9277d 100644 --- a/data_plane/src/precompute_engine/operators/multiple_min_max_accumulator.rs +++ b/data_plane/src/precompute_engine/operators/multiple_min_max_accumulator.rs @@ -6,7 +6,7 @@ use serde::{Deserialize, Serialize}; use serde_json::Value; use std::collections::HashMap; -use promql_utilities::query_logics::enums::Statistic; +use asap_types::Statistic; /// Accumulator that maintains separate min/max values for multiple keys /// Allows querying min/max for specific label combinations @@ -255,7 +255,7 @@ impl AggregateCore for MultipleMinMaxAccumulator { fn query_statistic( &self, - statistic: promql_utilities::query_logics::enums::Statistic, + statistic: asap_types::Statistic, key: &Option, query_kwargs: &std::collections::HashMap, ) -> Result> { diff --git a/data_plane/src/precompute_engine/operators/multiple_sum_accumulator.rs b/data_plane/src/precompute_engine/operators/multiple_sum_accumulator.rs index 2b4863eb..c20a4c8f 100644 --- a/data_plane/src/precompute_engine/operators/multiple_sum_accumulator.rs +++ b/data_plane/src/precompute_engine/operators/multiple_sum_accumulator.rs @@ -6,7 +6,7 @@ use serde::{Deserialize, Serialize}; use serde_json::Value; use std::collections::HashMap; -use promql_utilities::query_logics::enums::Statistic; +use asap_types::Statistic; /// Accumulator that maintains separate sum values for multiple keys /// Allows querying sums for specific label combinations @@ -214,7 +214,7 @@ impl AggregateCore for MultipleSumAccumulator { fn query_statistic( &self, - statistic: promql_utilities::query_logics::enums::Statistic, + statistic: asap_types::Statistic, key: &Option, query_kwargs: &std::collections::HashMap, ) -> Result> { diff --git a/data_plane/src/precompute_engine/operators/sketch_envelope_accumulator.rs b/data_plane/src/precompute_engine/operators/sketch_envelope_accumulator.rs index f3e41d3d..16b0bfaf 100644 --- a/data_plane/src/precompute_engine/operators/sketch_envelope_accumulator.rs +++ b/data_plane/src/precompute_engine/operators/sketch_envelope_accumulator.rs @@ -11,7 +11,8 @@ use prost::Message; use serde_json::Value; use std::collections::HashMap; -use promql_utilities::query_logics::enums::{AggregationType, Statistic}; +use asap_types::Statistic; +use promql_utilities::query_logics::enums::AggregationType; /// Accumulator that stores a serialized `SketchEnvelope` protobuf. /// diff --git a/data_plane/src/precompute_engine/operators/sum_accumulator.rs b/data_plane/src/precompute_engine/operators/sum_accumulator.rs index 6c6fa0c4..870841e7 100644 --- a/data_plane/src/precompute_engine/operators/sum_accumulator.rs +++ b/data_plane/src/precompute_engine/operators/sum_accumulator.rs @@ -6,7 +6,7 @@ use serde::{Deserialize, Serialize}; use serde_json::Value; use std::collections::HashMap; -use promql_utilities::query_logics::enums::Statistic; +use asap_types::Statistic; #[derive(Debug, Clone, Serialize, Deserialize)] pub struct SumAccumulator { @@ -150,7 +150,7 @@ impl AggregateCore for SumAccumulator { fn query_statistic( &self, - statistic: promql_utilities::query_logics::enums::Statistic, + statistic: asap_types::Statistic, _key: &Option, _query_kwargs: &std::collections::HashMap, ) -> Result> { @@ -329,7 +329,7 @@ mod tests { #[test] fn aux_stats_try_answer_on_sum_statistic() { - use promql_utilities::query_logics::enums::Statistic; + use asap_types::Statistic; let acc = SumAccumulator::with_sum(42.0); // Sum statistic is covered by aux without deserialising. assert_eq!(acc.aux_stats().try_answer(Statistic::Sum), Some(42.0)); diff --git a/data_plane/src/precompute_engine/output_sink.rs b/data_plane/src/precompute_engine/output_sink.rs index e5cd71a3..f4639e82 100644 --- a/data_plane/src/precompute_engine/output_sink.rs +++ b/data_plane/src/precompute_engine/output_sink.rs @@ -246,7 +246,7 @@ mod tests { use crate::storage_engines::types::{KeyByLabelValues, StreamingConfig}; use asap_types::aggregation_config::AggregationConfig; use asap_types::enums::WindowType; - use promql_utilities::data_model::key_by_label_names::KeyByLabelNames; + use asap_types::KeyByLabelNames; use promql_utilities::query_logics::enums::AggregationType; use std::collections::HashMap; diff --git a/data_plane/src/precompute_engine/worker.rs b/data_plane/src/precompute_engine/worker.rs index bea71e6c..f39d1ff7 100644 --- a/data_plane/src/precompute_engine/worker.rs +++ b/data_plane/src/precompute_engine/worker.rs @@ -1417,13 +1417,9 @@ mod tests { agg_type, agg_sub_type.to_string(), HashMap::new(), - promql_utilities::data_model::key_by_label_names::KeyByLabelNames::new( - grouping.iter().map(|s| s.to_string()).collect(), - ), - promql_utilities::data_model::key_by_label_names::KeyByLabelNames::new( - aggregated.iter().map(|s| s.to_string()).collect(), - ), - promql_utilities::data_model::key_by_label_names::KeyByLabelNames::new(vec![]), + asap_types::KeyByLabelNames::new(grouping.iter().map(|s| s.to_string()).collect()), + asap_types::KeyByLabelNames::new(aggregated.iter().map(|s| s.to_string()).collect()), + asap_types::KeyByLabelNames::new(vec![]), String::new(), window_secs, slide_secs, @@ -2181,12 +2177,9 @@ aggregations: AggregationType::SingleSubpopulation, "Sum".to_string(), HashMap::new(), - promql_utilities::data_model::key_by_label_names::KeyByLabelNames::new(vec![ - "method".to_string(), - "status".to_string(), - ]), - promql_utilities::data_model::key_by_label_names::KeyByLabelNames::new(vec![]), - promql_utilities::data_model::key_by_label_names::KeyByLabelNames::new(vec![]), + asap_types::KeyByLabelNames::new(vec!["method".to_string(), "status".to_string()]), + asap_types::KeyByLabelNames::new(vec![]), + asap_types::KeyByLabelNames::new(vec![]), String::new(), 60, 0, @@ -2893,7 +2886,12 @@ aggregations: let pf = PolicyFingerprint(1); for i in 0..5 { worker - .process_group_samples(1, pf, "", group_samples("cpu", vec![(1_000 + i * 100, 1.0)])) + .process_group_samples( + 1, + pf, + "", + group_samples("cpu", vec![(1_000 + i * 100, 1.0)]), + ) .unwrap(); } diff --git a/data_plane/src/query_engines/asap_query_engine/engine.rs b/data_plane/src/query_engines/asap_query_engine/engine.rs index 85246144..36acd4e3 100644 --- a/data_plane/src/query_engines/asap_query_engine/engine.rs +++ b/data_plane/src/query_engines/asap_query_engine/engine.rs @@ -2,14 +2,14 @@ use crate::storage_engines::types::StreamingConfig; use std::sync::Arc; use asap_types::query_requirements::QueryRequirements; -use promql_utilities::data_model::KeyByLabelNames; +use asap_types::KeyByLabelNames; #[cfg(test)] use crate::storage_engines::types::KeyByLabelValues; #[cfg(test)] use crate::AggregateCore; #[cfg(test)] -use promql_utilities::query_logics::enums::Statistic; +use asap_types::Statistic; #[cfg(test)] use std::collections::HashMap; @@ -916,9 +916,7 @@ impl ASAPQueryEngine { .execute_range(query, start_ms, end_ms, step_ms) .await { - return Ok(stitch_warm_and_archive( - warm_qr, archive_qr, cov_lo, cov_hi, - )); + return Ok(stitch_warm_and_archive(warm_qr, archive_qr, cov_lo, cov_hi)); } // Archive error → fall back to warm-only (best effort). } @@ -2205,7 +2203,7 @@ mod hot_reload_phase2_tests { use crate::storage_engines::types::{ AggregationType, CleanupPolicy, HotReloadStreamingConfig, StreamingConfig, WindowType, }; - use promql_utilities::data_model::key_by_label_names::KeyByLabelNames; + use asap_types::KeyByLabelNames; #[test] fn extract_filter_value_pulls_item_value() { @@ -2370,7 +2368,7 @@ mod aux_pushdown_tests { min_max_accumulator::MinMaxAccumulator, sum_accumulator::SumAccumulator, }; use crate::storage_engines::types::AggregationType; - use promql_utilities::query_logics::enums::Statistic; + use asap_types::Statistic; use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::Arc; @@ -4630,12 +4628,8 @@ mod hybrid_stitch_tests { #[cfg(test)] mod range_stitch_tests { use super::*; - use crate::query_engines::query_result::{ - QueryResult, RangeVectorElement, Sample, - }; - use crate::query_engines::routing::query_engine_routing::{ - EngineCapabilities, QueryEngine, - }; + use crate::query_engines::query_result::{QueryResult, RangeVectorElement, Sample}; + use crate::query_engines::routing::query_engine_routing::{EngineCapabilities, QueryEngine}; use crate::query_engines::EngineError; use crate::storage_engines::sketch_db::index::{ AccuracyBound, Capability, SketchConfig, SketchEncoding, SketchInstanceMetadata, @@ -4768,9 +4762,7 @@ mod range_stitch_tests { let mid_ts = now_ms.saturating_sub(300_000) as i64; arch_el.samples.push(Sample::new(prefix_ts as u64, 999.0)); arch_el.samples.push(Sample::new(mid_ts as u64, 998.0)); - arch_el - .samples - .push(Sample::new(warm_w1_end, 1.0)); // overlap: warm should win + arch_el.samples.push(Sample::new(warm_w1_end, 1.0)); // overlap: warm should win let archive = Arc::new(FakeArchive { matrix: QueryResult::matrix(vec![arch_el]), }); @@ -4782,12 +4774,7 @@ mod range_stitch_tests { .with_archive_engine(archive); let result = engine - .execute_range_promql_modern( - "count_over_time(req_count[5m])", - start_ms, - end_ms, - 15_000, - ) + .execute_range_promql_modern("count_over_time(req_count[5m])", start_ms, end_ms, 15_000) .await .expect("range query must answer (stitched), not error"); diff --git a/data_plane/src/query_engines/query_result.rs b/data_plane/src/query_engines/query_result.rs index de171049..30b6743c 100644 --- a/data_plane/src/query_engines/query_result.rs +++ b/data_plane/src/query_engines/query_result.rs @@ -2,7 +2,26 @@ use crate::storage_engines::sketch_db::AccuracyEnvelope; use crate::storage_engines::types::KeyByLabelValues; use serde::{Deserialize, Serialize}; -use promql_utilities::query_logics::enums::QueryResultType; +/// Whether a [`QueryResult`] is a PromQL instant-vector or range-vector +/// result -- mirrors the Prometheus HTTP API's `resultType` response +/// field. Formerly `promql_utilities::query_logics::enums::QueryResultType`; +/// moved here (its only real production consumer) since it's an +/// HTTP-response-shape tag with no meaning outside a query server -- +/// ASAPController has no HTTP query server and no equivalent concept. +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)] +pub enum QueryResultType { + InstantVector, + RangeVector, +} + +impl std::fmt::Display for QueryResultType { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + QueryResultType::InstantVector => write!(f, "instant_vector"), + QueryResultType::RangeVector => write!(f, "range_vector"), + } + } +} /// Represents the result of a PromQL query #[derive(Debug, Clone, Serialize, Deserialize)] diff --git a/data_plane/src/query_engines/routing/query_engine_routing.rs b/data_plane/src/query_engines/routing/query_engine_routing.rs index 20524983..ce69147e 100644 --- a/data_plane/src/query_engines/routing/query_engine_routing.rs +++ b/data_plane/src/query_engines/routing/query_engine_routing.rs @@ -20,8 +20,8 @@ use async_trait::async_trait; use thiserror::Error; use tracing::{debug, warn}; +use asap_types::Statistic; use asap_types::{compatible_storage_backends, AccuracyTarget, StorageBackend}; -use promql_utilities::query_logics::enums::Statistic; use crate::query_engines::{EngineError, QueryResult}; diff --git a/data_plane/src/storage_engines/sketch_db/accuracy.rs b/data_plane/src/storage_engines/sketch_db/accuracy.rs index f111dfa0..646670a0 100644 --- a/data_plane/src/storage_engines/sketch_db/accuracy.rs +++ b/data_plane/src/storage_engines/sketch_db/accuracy.rs @@ -475,7 +475,7 @@ impl AccuracyEnvelope { mod tests { use super::*; use asap_types::enums::WindowType; - use promql_utilities::data_model::key_by_label_names::KeyByLabelNames; + use asap_types::KeyByLabelNames; use serde_json::{json, Value}; use std::collections::HashMap; @@ -523,10 +523,10 @@ mod tests { let mut params = HashMap::new(); params.insert("d".to_string(), json!(5)); params.insert("w".to_string(), json!(256)); - let base = AccuracyProfile::derive(&base_config(AggregationType::CountSketch, params.clone())); + let base = + AccuracyProfile::derive(&base_config(AggregationType::CountSketch, params.clone())); params.insert("gos_delta_epsilon".to_string(), json!(0.05)); - let widened = - AccuracyProfile::derive(&base_config(AggregationType::CountSketch, params)); + let widened = AccuracyProfile::derive(&base_config(AggregationType::CountSketch, params)); assert!((widened.epsilon - (base.epsilon + 0.05)).abs() < 1e-12); assert_eq!(widened.delta, base.delta); assert_eq!(widened.kind, base.kind); diff --git a/data_plane/src/storage_engines/sketch_db/backfill/processor.rs b/data_plane/src/storage_engines/sketch_db/backfill/processor.rs index 1a9b0ad8..e417068a 100644 --- a/data_plane/src/storage_engines/sketch_db/backfill/processor.rs +++ b/data_plane/src/storage_engines/sketch_db/backfill/processor.rs @@ -404,7 +404,7 @@ mod tests { use crate::storage_engines::sketch_db::backfill::BackfillSource; use crate::storage_engines::types::StreamingConfig; use asap_types::enums::{AggregationType, WindowType}; - use promql_utilities::data_model::key_by_label_names::KeyByLabelNames; + use asap_types::KeyByLabelNames; use std::sync::Arc; fn sum_config(_agg_id: u64, metric: &str, grouping: Vec<&str>) -> AggregationConfig { diff --git a/data_plane/src/storage_engines/sketch_db/backfill/service.rs b/data_plane/src/storage_engines/sketch_db/backfill/service.rs index bc1a8379..1e896a1f 100644 --- a/data_plane/src/storage_engines/sketch_db/backfill/service.rs +++ b/data_plane/src/storage_engines/sketch_db/backfill/service.rs @@ -330,7 +330,7 @@ mod tests { use crate::storage_engines::types::StreamingConfig; use asap_types::aggregation_config::AggregationConfig; use asap_types::enums::{AggregationType, WindowType}; - use promql_utilities::data_model::key_by_label_names::KeyByLabelNames; + use asap_types::KeyByLabelNames; use std::sync::Mutex; fn sum_config(_agg_id: u64, metric: &str) -> AggregationConfig { diff --git a/data_plane/src/storage_engines/sketch_db/backfill/window_builder.rs b/data_plane/src/storage_engines/sketch_db/backfill/window_builder.rs index 1b43a644..9a47b784 100644 --- a/data_plane/src/storage_engines/sketch_db/backfill/window_builder.rs +++ b/data_plane/src/storage_engines/sketch_db/backfill/window_builder.rs @@ -119,7 +119,7 @@ mod tests { use super::*; use asap_types::aggregation_config::AggregationConfig; use asap_types::enums::{AggregationType, WindowType}; - use promql_utilities::data_model::key_by_label_names::KeyByLabelNames; + use asap_types::KeyByLabelNames; use std::collections::HashMap; fn sum_config() -> AggregationConfig { diff --git a/data_plane/src/storage_engines/sketch_db/lifecycle/eviction.rs b/data_plane/src/storage_engines/sketch_db/lifecycle/eviction.rs index b7e6bfe2..abf0edeb 100644 --- a/data_plane/src/storage_engines/sketch_db/lifecycle/eviction.rs +++ b/data_plane/src/storage_engines/sketch_db/lifecycle/eviction.rs @@ -252,7 +252,7 @@ mod tests { use crate::storage_engines::types::{AggregationType, StreamingConfig}; use asap_types::aggregation_config::AggregationConfig; use asap_types::enums::WindowType; - use promql_utilities::data_model::key_by_label_names::KeyByLabelNames; + use asap_types::KeyByLabelNames; use std::collections::HashMap; fn sum_agg_config(id: u64) -> AggregationConfig { diff --git a/data_plane/src/storage_engines/sketch_db/lifecycle/reconcile.rs b/data_plane/src/storage_engines/sketch_db/lifecycle/reconcile.rs index bae21a98..5f59a26e 100644 --- a/data_plane/src/storage_engines/sketch_db/lifecycle/reconcile.rs +++ b/data_plane/src/storage_engines/sketch_db/lifecycle/reconcile.rs @@ -277,7 +277,7 @@ mod tests { use asap_types::aggregation_config::AggregationConfig; use asap_types::enums::{AggregationType, WindowType}; - use promql_utilities::data_model::key_by_label_names::KeyByLabelNames; + use asap_types::KeyByLabelNames; use crate::storage_engines::sketch_db::data::AggKind; use crate::storage_engines::sketch_db::index::{SketchInstanceMetadata, SketchStore}; diff --git a/data_plane/src/storage_engines/sketch_db/query/sketch_reducer.rs b/data_plane/src/storage_engines/sketch_db/query/sketch_reducer.rs index 0ab50536..ec974ced 100644 --- a/data_plane/src/storage_engines/sketch_db/query/sketch_reducer.rs +++ b/data_plane/src/storage_engines/sketch_db/query/sketch_reducer.rs @@ -67,7 +67,7 @@ use crate::storage_engines::sketch_db::query::decoders::{ use crate::storage_engines::sketch_db::query::delta_apply::{ cumulative_evaluate, per_window_evaluate, DeltaSketchKind, }; -use promql_utilities::query_logics::enums::Statistic; +use asap_types::Statistic; /// Reducer wrapping a `&SketchStore`. Constructed per-query; cheap. pub struct SketchReducer<'a> { @@ -478,23 +478,23 @@ impl<'a> SketchReducer<'a> { cov_lo = cov_lo.min(w); cov_hi = cov_hi.max(w); } - let series_state = - cumulative_hll_state(&samples_vec, precision).map_err(|e| { - ASAPTierError::DeserializeFailure { - sid, - encoding: SketchEncoding::ProtoFull, - reason: e, - } - })?; + let series_state = cumulative_hll_state(&samples_vec, precision).map_err(|e| { + ASAPTierError::DeserializeFailure { + sid, + encoding: SketchEncoding::ProtoFull, + reason: e, + } + })?; if let Some(sk) = series_state { merged = Some(match merged.take() { None => sk, Some(mut acc) => { - acc.merge(&sk).map_err(|e| ASAPTierError::DeserializeFailure { - sid, - encoding: SketchEncoding::ProtoFull, - reason: format!("global HLL merge: {e}"), - })?; + acc.merge(&sk) + .map_err(|e| ASAPTierError::DeserializeFailure { + sid, + encoding: SketchEncoding::ProtoFull, + reason: format!("global HLL merge: {e}"), + })?; acc } }); @@ -509,7 +509,11 @@ impl<'a> SketchReducer<'a> { }; let _ = any_window; let estimate = merged.estimate(); - let window_end = if cov_hi > 0 { cov_hi as i64 } else { t1_ms as i64 }; + let window_end = if cov_hi > 0 { + cov_hi as i64 + } else { + t1_ms as i64 + }; let coverage = if cov_lo <= cov_hi { Some((cov_lo, cov_hi)) } else { @@ -673,10 +677,12 @@ impl<'a> SketchReducer<'a> { } _ => decode_cms_with_heap_from_msgpack(&state.bytes), } - .map_err(|e| ASAPTierError::DeserializeFailure { - sid, - encoding: state.encoding, - reason: e, + .map_err(|e| { + ASAPTierError::DeserializeFailure { + sid, + encoding: state.encoding, + reason: e, + } })?; for item in decoded.topk_heap_items() { *summed.entry(item.key).or_insert(0.0) += item.value; @@ -700,9 +706,8 @@ impl<'a> SketchReducer<'a> { } // Sort descending by summed count, take top-k. let mut items: Vec<(String, f64)> = summed.into_iter().collect(); - items.sort_by(|a, b| { - b.1.partial_cmp(&a.1).unwrap_or(std::cmp::Ordering::Equal) - }); + items + .sort_by(|a, b| b.1.partial_cmp(&a.1).unwrap_or(std::cmp::Ordering::Equal)); for (key, value) in items.into_iter().take(k) { let mut lv = ts.series_label_values.clone(); lv.insert("item".to_string(), key); diff --git a/data_plane/src/storage_engines/sketch_db/query/timeline_dispatch.rs b/data_plane/src/storage_engines/sketch_db/query/timeline_dispatch.rs index 8fe77d41..47009aad 100644 --- a/data_plane/src/storage_engines/sketch_db/query/timeline_dispatch.rs +++ b/data_plane/src/storage_engines/sketch_db/query/timeline_dispatch.rs @@ -40,7 +40,7 @@ //! how to render that (warning, fall-through to exact DB, or //! error). -use promql_utilities::query_logics::enums::Statistic; +use asap_types::Statistic; use crate::storage_engines::sketch_db::TimelineSegment; diff --git a/data_plane/src/storage_engines/sketch_db/query/window_merger.rs b/data_plane/src/storage_engines/sketch_db/query/window_merger.rs index fe4107a3..5df9853d 100644 --- a/data_plane/src/storage_engines/sketch_db/query/window_merger.rs +++ b/data_plane/src/storage_engines/sketch_db/query/window_merger.rs @@ -173,7 +173,7 @@ mod tests { fn query_statistic( &self, - _statistic: promql_utilities::query_logics::enums::Statistic, + _statistic: asap_types::Statistic, _key: &Option, _query_kwargs: &std::collections::HashMap, ) -> Result> { diff --git a/data_plane/src/storage_engines/types/hot_reload_config.rs b/data_plane/src/storage_engines/types/hot_reload_config.rs index e7234923..eddb3eaa 100644 --- a/data_plane/src/storage_engines/types/hot_reload_config.rs +++ b/data_plane/src/storage_engines/types/hot_reload_config.rs @@ -139,7 +139,7 @@ mod tests { use super::*; use crate::storage_engines::types::AggregationConfig; use asap_types::enums::{AggregationType, WindowType}; - use promql_utilities::data_model::key_by_label_names::KeyByLabelNames; + use asap_types::KeyByLabelNames; use std::collections::HashMap; use std::thread; diff --git a/data_plane/src/storage_engines/types/traits.rs b/data_plane/src/storage_engines/types/traits.rs index 846c45b2..5d78eb44 100644 --- a/data_plane/src/storage_engines/types/traits.rs +++ b/data_plane/src/storage_engines/types/traits.rs @@ -2,7 +2,8 @@ use crate::storage_engines::types::KeyByLabelValues; use serde_json::Value; use std::collections::HashMap; -use promql_utilities::query_logics::enums::{AggregationType, Statistic}; +use asap_types::Statistic; +use promql_utilities::query_logics::enums::AggregationType; pub use asap_types::traits::SerializableToSink; diff --git a/data_plane/src/tests/accuracy_empirical_validation_tests.rs b/data_plane/src/tests/accuracy_empirical_validation_tests.rs index 72466b5c..ef5add07 100644 --- a/data_plane/src/tests/accuracy_empirical_validation_tests.rs +++ b/data_plane/src/tests/accuracy_empirical_validation_tests.rs @@ -29,7 +29,7 @@ use std::collections::HashMap; use asap_types::aggregation_config::AggregationConfig; use asap_types::enums::WindowType; -use promql_utilities::data_model::key_by_label_names::KeyByLabelNames; +use asap_types::KeyByLabelNames; use promql_utilities::query_logics::enums::AggregationType; use serde_json::{json, Value}; diff --git a/data_plane/src/tests/test_utilities/engine_factories.rs b/data_plane/src/tests/test_utilities/engine_factories.rs index 32d7a945..c71c326e 100644 --- a/data_plane/src/tests/test_utilities/engine_factories.rs +++ b/data_plane/src/tests/test_utilities/engine_factories.rs @@ -13,7 +13,7 @@ use crate::storage_engines::types::{ StreamingConfig, WindowType, }; use crate::AggregateCore; -use promql_utilities::data_model::KeyByLabelNames; +use asap_types::KeyByLabelNames; use std::collections::HashMap; /// Helper for test factories — wraps the closure-mint call with a diff --git a/data_plane/src/tests/trait_design_tests.rs b/data_plane/src/tests/trait_design_tests.rs index 03636bcf..b56408a2 100644 --- a/data_plane/src/tests/trait_design_tests.rs +++ b/data_plane/src/tests/trait_design_tests.rs @@ -3,7 +3,7 @@ use crate::precompute_engine::operators::{MultipleSumAccumulator, SumAccumulator use crate::storage_engines::types::{ KeyByLabelValues, MultipleSubpopulationAggregate, SingleSubpopulationAggregate, }; -use promql_utilities::Statistic; +use asap_types::Statistic; #[test] fn test_single_subpopulation_interface() { diff --git a/data_plane/src/utils/http.rs b/data_plane/src/utils/http.rs index fe3e8575..77c9a1bf 100644 --- a/data_plane/src/utils/http.rs +++ b/data_plane/src/utils/http.rs @@ -1,4 +1,4 @@ -use promql_utilities::KeyByLabelNames; +use asap_types::KeyByLabelNames; use serde_json::{json, Value}; use std::collections::HashMap; diff --git a/data_plane/tests/e2e_modified_otlp_sketch_path.rs b/data_plane/tests/e2e_modified_otlp_sketch_path.rs index 3ef42eba..7f41bbfc 100644 --- a/data_plane/tests/e2e_modified_otlp_sketch_path.rs +++ b/data_plane/tests/e2e_modified_otlp_sketch_path.rs @@ -71,11 +71,9 @@ fn make_count_min_agg_config( AggregationType::CountMinSketch, String::new(), params, - promql_utilities::data_model::key_by_label_names::KeyByLabelNames::new( - grouping.iter().map(|s| s.to_string()).collect(), - ), - promql_utilities::data_model::key_by_label_names::KeyByLabelNames::new(vec![]), - promql_utilities::data_model::key_by_label_names::KeyByLabelNames::new(vec![]), + asap_types::KeyByLabelNames::new(grouping.iter().map(|s| s.to_string()).collect()), + asap_types::KeyByLabelNames::new(vec![]), + asap_types::KeyByLabelNames::new(vec![]), String::new(), window_secs, 0, @@ -339,11 +337,9 @@ fn make_count_sketch_agg_config( AggregationType::CountSketch, String::new(), params, - promql_utilities::data_model::key_by_label_names::KeyByLabelNames::new( - grouping.iter().map(|s| s.to_string()).collect(), - ), - promql_utilities::data_model::key_by_label_names::KeyByLabelNames::new(vec![]), - promql_utilities::data_model::key_by_label_names::KeyByLabelNames::new(vec![]), + asap_types::KeyByLabelNames::new(grouping.iter().map(|s| s.to_string()).collect()), + asap_types::KeyByLabelNames::new(vec![]), + asap_types::KeyByLabelNames::new(vec![]), String::new(), window_secs, 0, @@ -552,11 +548,9 @@ fn make_kll_agg_config( AggregationType::DatasketchesKLL, "DatasketchesKLL".to_string(), params, - promql_utilities::data_model::key_by_label_names::KeyByLabelNames::new( - grouping.iter().map(|s| s.to_string()).collect(), - ), - promql_utilities::data_model::key_by_label_names::KeyByLabelNames::new(vec![]), - promql_utilities::data_model::key_by_label_names::KeyByLabelNames::new(vec![]), + asap_types::KeyByLabelNames::new(grouping.iter().map(|s| s.to_string()).collect()), + asap_types::KeyByLabelNames::new(vec![]), + asap_types::KeyByLabelNames::new(vec![]), String::new(), window_secs, 0, @@ -734,11 +728,9 @@ fn make_dd_sketch_agg_config( AggregationType::DDSketch, String::new(), params, - promql_utilities::data_model::key_by_label_names::KeyByLabelNames::new( - grouping.iter().map(|s| s.to_string()).collect(), - ), - promql_utilities::data_model::key_by_label_names::KeyByLabelNames::new(vec![]), - promql_utilities::data_model::key_by_label_names::KeyByLabelNames::new(vec![]), + asap_types::KeyByLabelNames::new(grouping.iter().map(|s| s.to_string()).collect()), + asap_types::KeyByLabelNames::new(vec![]), + asap_types::KeyByLabelNames::new(vec![]), String::new(), window_secs, 0, @@ -908,11 +900,9 @@ fn make_hll_agg_config( AggregationType::HLL, String::new(), params, - promql_utilities::data_model::key_by_label_names::KeyByLabelNames::new( - grouping.iter().map(|s| s.to_string()).collect(), - ), - promql_utilities::data_model::key_by_label_names::KeyByLabelNames::new(vec![]), - promql_utilities::data_model::key_by_label_names::KeyByLabelNames::new(vec![]), + asap_types::KeyByLabelNames::new(grouping.iter().map(|s| s.to_string()).collect()), + asap_types::KeyByLabelNames::new(vec![]), + asap_types::KeyByLabelNames::new(vec![]), String::new(), window_secs, 0, diff --git a/data_plane/tests/edge_runtime_consumes_precompute_rs.rs b/data_plane/tests/edge_runtime_consumes_precompute_rs.rs index 0468d4bc..3dee9e81 100644 --- a/data_plane/tests/edge_runtime_consumes_precompute_rs.rs +++ b/data_plane/tests/edge_runtime_consumes_precompute_rs.rs @@ -139,7 +139,7 @@ fn ddsketch_envelope_ends_up_in_backend_accumulator() { let q = acc .query_statistic( - promql_utilities::query_logics::enums::Statistic::Quantile, + asap_types::Statistic::Quantile, &None, &[("quantile".to_string(), "0.5".to_string())] .into_iter() @@ -151,11 +151,7 @@ fn ddsketch_envelope_ends_up_in_backend_accumulator() { "median estimate close to 50: got {q}" ); let count = acc - .query_statistic( - promql_utilities::query_logics::enums::Statistic::Count, - &None, - &Default::default(), - ) + .query_statistic(asap_types::Statistic::Count, &None, &Default::default()) .expect("count query"); assert_eq!(count as u64, 100); }