Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions control_plane/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ asap_types.workspace = true
# tagged releases yet. Re-pin as ASAPController's IR evolves; move to a tag
# once one exists.
#
# Bumped to 150ef7d (merge of PR #142, "derive PartialOrd/Ord for
# SummaryKind") for the sketch-identity unification work (see
# scratchpad/artifacts/enum-unification-plan.md) -- SummaryKind needs Ord
# for the BTreeSet<SummaryKind> deterministic-emission-order contract in
# control_plane::physical::colored_dag::emitter::EdgeStageConfig::metric_to_family.
asap-ir = { git = "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/ProjectASAP/ASAPController", rev = "150ef7d0786d24286b578dfae9dbbcefc8fbac3e" }
asap-sketch = { git = "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/ProjectASAP/ASAPController", rev = "150ef7d0786d24286b578dfae9dbbcefc8fbac3e" }
asap-plan = { git = "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/ProjectASAP/ASAPController", rev = "150ef7d0786d24286b578dfae9dbbcefc8fbac3e" }
# Bumped to 7fcaf91 (merge of PR #143, "add serving-time traits to
# WindowKind") for the WindowType -> WindowKind unification (see
# scratchpad/artifacts/enum-unification-plan.md) -- WindowKind needs
# Copy/Default/Hash/Display/FromStr + snake_case serde for
# asap_types::enums::WindowKind to replace the backend's own WindowType.
asap-ir = { git = "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/ProjectASAP/ASAPController", rev = "7fcaf914d87e71407c3a6d7ccac613b867f9c11b" }
asap-sketch = { git = "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/ProjectASAP/ASAPController", rev = "7fcaf914d87e71407c3a6d7ccac613b867f9c11b" }
asap-plan = { git = "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/ProjectASAP/ASAPController", rev = "7fcaf914d87e71407c3a6d7ccac613b867f9c11b" }

[dev-dependencies]
tokio = { version = "1", features = ["full", "test-util"] }
Expand Down
2 changes: 1 addition & 1 deletion control_plane/src/asap_tier_analysis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1442,7 +1442,7 @@ mod tests {
String::new(),
window_size,
window_size,
asap_types::enums::WindowType::Tumbling,
asap_types::enums::WindowKind::Tumbling,
spatial_filter.to_string(),
metric.to_string(),
None,
Expand Down
6 changes: 6 additions & 0 deletions crates/asap_types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,9 @@ serde_yaml.workspace = true
anyhow.workspace = true
clap.workspace = true
xxhash-rust = { version = "0.8", features = ["xxh64"] }

# First cross-crate ASAPController dependency for data_plane (transitively,
# via this crate): WindowType -> asap_ir::intent_algebra::query_expr::WindowKind
# unification (scratchpad/artifacts/enum-unification-plan.md). Pin matches
# control_plane's -- see control_plane/Cargo.toml's comment for the rationale.
asap-ir = { git = "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/ProjectASAP/ASAPController", rev = "7fcaf914d87e71407c3a6d7ccac613b867f9c11b" }
10 changes: 5 additions & 5 deletions crates/asap_types/src/aggregation_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use serde_json::Value;
use serde_yaml;
use std::collections::HashMap;

use crate::enums::{QueryLanguage, WindowType};
use crate::enums::{QueryLanguage, WindowKind};
use crate::policy_fingerprint::PolicyFingerprint;
use crate::traits::SerializableToSink;
use crate::utils::normalize_spatial_filter;
Expand Down Expand Up @@ -33,7 +33,7 @@ pub struct AggregationConfig {

pub window_size: u64, // Window size in seconds (e.g., 900s for 15m)
pub slide_interval: u64, // Slide/hop interval in seconds (e.g., 30s)
pub window_type: WindowType, // Tumbling or Sliding
pub window_type: WindowKind, // Tumbling or Sliding

pub spatial_filter: String,
pub spatial_filter_normalized: String,
Expand Down Expand Up @@ -86,7 +86,7 @@ impl AggregationConfig {
original_yaml: String,
window_size: u64,
slide_interval: u64,
window_type: WindowType,
window_type: WindowKind,
spatial_filter: String,
metric: String,
num_aggregates_to_retain: Option<u64>,
Expand Down Expand Up @@ -176,7 +176,7 @@ impl AggregationConfig {
.get("windowType")
.and_then(|v| v.as_str())
.unwrap_or("tumbling")
.parse::<WindowType>()
.parse::<WindowKind>()
.unwrap_or_default();

let slide_interval = data
Expand Down Expand Up @@ -296,7 +296,7 @@ impl AggregationConfig {
.get("windowType")
.and_then(|v| v.as_str())
.unwrap_or("tumbling")
.parse::<WindowType>()
.parse::<WindowKind>()
.unwrap_or_default();

let slide_interval = aggregation_data
Expand Down
43 changes: 12 additions & 31 deletions crates/asap_types/src/enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,34 +116,15 @@ impl FromStr for CleanupPolicy {
}
}

/// Window type for streaming aggregations.
#[derive(
Clone, Debug, Copy, Default, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize,
)]
#[serde(rename_all = "snake_case")]
pub enum WindowType {
#[default]
Tumbling,
Sliding,
}

impl fmt::Display for WindowType {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
WindowType::Tumbling => write!(f, "tumbling"),
WindowType::Sliding => write!(f, "sliding"),
}
}
}

impl FromStr for WindowType {
type Err = String;

fn from_str(s: &str) -> Result<Self, Self::Err> {
match s.to_lowercase().as_str() {
"tumbling" => Ok(WindowType::Tumbling),
"sliding" => Ok(WindowType::Sliding),
_ => Err(format!("Unknown window type: '{s}'")),
}
}
}
/// Window lifecycle/flush semantics for streaming aggregations.
///
/// Formerly a local `WindowType` (`Tumbling`/`Sliding`) enum. Retired in
/// favor of `asap_ir::intent_algebra::query_expr::WindowKind` directly —
/// same concept, plus a `Session` variant this workspace didn't have.
/// `Copy`/`Default`/`Hash`/`Display`/`FromStr` and
/// `#[serde(rename_all = "snake_case")]` were added upstream
/// (ASAPController PR #143) specifically so this re-export could replace
/// the old local type without touching any call site's behavior: same
/// `Tumbling` default, same lowercase `Display`/`FromStr` round-trip, same
/// wire format.
pub use asap_ir::intent_algebra::query_expr::WindowKind;
4 changes: 2 additions & 2 deletions crates/asap_types/src/policy_fingerprint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ impl std::fmt::Display for PolicyFingerprint {
#[cfg(test)]
mod tests {
use super::*;
use crate::enums::WindowType;
use crate::enums::WindowKind;
use crate::AggregationType;
use crate::KeyByLabelNames;
use std::collections::HashMap;
Expand All @@ -195,7 +195,7 @@ mod tests {
String::new(),
window_size,
window_size,
WindowType::Tumbling,
WindowKind::Tumbling,
spatial_filter.to_string(),
metric.to_string(),
None,
Expand Down
4 changes: 2 additions & 2 deletions crates/asap_types/src/policy_registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ impl PolicyRegistry {
#[cfg(test)]
mod tests {
use super::*;
use crate::enums::WindowType;
use crate::enums::WindowKind;
use crate::AggregationType;
use crate::KeyByLabelNames;
use std::collections::HashMap as StdHashMap;
Expand All @@ -134,7 +134,7 @@ mod tests {
String::new(),
60,
60,
WindowType::Tumbling,
WindowKind::Tumbling,
String::new(),
metric.to_string(),
None,
Expand Down
4 changes: 2 additions & 2 deletions data_plane/benches/sketch_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ fn bench_query_precomputes_by_agg(c: &mut Criterion) {
/// case, where the per-batch reconcile is pure scan overhead.
fn matching_streaming_config(metric: &str) -> data_plane::storage_engines::types::StreamingConfig {
use asap_types::aggregation_config::AggregationConfig;
use asap_types::enums::WindowType;
use asap_types::enums::WindowKind;
use asap_types::AggregationType as AT;
use asap_types::KeyByLabelNames;
use std::collections::HashMap;
Expand All @@ -403,7 +403,7 @@ fn matching_streaming_config(metric: &str) -> data_plane::storage_engines::types
String::new(),
60,
60,
WindowType::Tumbling,
WindowKind::Tumbling,
String::new(),
metric.to_string(),
None,
Expand Down
4 changes: 2 additions & 2 deletions data_plane/src/drivers/ingest/otel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4003,7 +4003,7 @@ mod sid_bucketing_tests {
Metric as PbMetric, NumberDataPoint, ResourceMetrics, ScopeMetrics,
};
use asap_types::aggregation_config::AggregationConfig;
use asap_types::enums::WindowType;
use asap_types::enums::WindowKind;
use asap_types::AggregationType;
use asap_types::KeyByLabelNames;
use std::collections::HashMap;
Expand All @@ -4030,7 +4030,7 @@ mod sid_bucketing_tests {
String::new(),
10,
10,
WindowType::Tumbling,
WindowKind::Tumbling,
String::new(),
metric.to_string(),
None,
Expand Down
4 changes: 2 additions & 2 deletions data_plane/src/drivers/query/servers/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3044,7 +3044,7 @@ aggregations:
active_agg_ids: &[u64],
) -> (u16, std::collections::HashMap<u64, u64>) {
use asap_types::aggregation_config::AggregationConfig;
use asap_types::enums::WindowType;
use asap_types::enums::WindowKind;
use asap_types::AggregationType;
use asap_types::KeyByLabelNames;
use std::collections::HashMap;
Expand Down Expand Up @@ -3075,7 +3075,7 @@ aggregations:
original_yaml: String::new(),
window_size: 1,
slide_interval: 1,
window_type: WindowType::Tumbling,
window_type: WindowKind::Tumbling,
spatial_filter: String::new(),
spatial_filter_normalized: String::new(),
metric: metric.clone(),
Expand Down
12 changes: 6 additions & 6 deletions data_plane/src/precompute_engine/accumulator_factory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -948,7 +948,7 @@ pub fn create_accumulator_updater(config: &AggregationConfig) -> Box<dyn Accumul
#[cfg(test)]
mod tests {
use super::*;
use asap_types::enums::WindowType;
use asap_types::enums::WindowKind;
use asap_types::AggregationType;

#[test]
Expand Down Expand Up @@ -1036,7 +1036,7 @@ mod tests {
String::new(),
60,
0,
WindowType::Tumbling,
WindowKind::Tumbling,
"m".to_string(),
"m".to_string(),
None,
Expand Down Expand Up @@ -1130,7 +1130,7 @@ mod tests {
String::new(),
60,
0,
WindowType::Tumbling,
WindowKind::Tumbling,
"m".to_string(),
"m".to_string(),
None,
Expand Down Expand Up @@ -1167,7 +1167,7 @@ mod tests {
String::new(),
60,
0,
WindowType::Tumbling,
WindowKind::Tumbling,
"m".to_string(),
"m".to_string(),
None,
Expand All @@ -1187,7 +1187,7 @@ mod tests {
String::new(),
60,
0,
WindowType::Tumbling,
WindowKind::Tumbling,
"m".to_string(),
"m".to_string(),
None,
Expand Down Expand Up @@ -1224,7 +1224,7 @@ mod tests {
String::new(),
60,
0,
WindowType::Tumbling,
WindowKind::Tumbling,
"cpu".to_string(),
"cpu".to_string(),
None,
Expand Down
4 changes: 2 additions & 2 deletions data_plane/src/precompute_engine/ingest_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ mod tests {
use crate::precompute_engine::series_router::SeriesRouter;
use crate::storage_engines::types::StreamingConfig;
use asap_types::aggregation_config::AggregationConfig;
use asap_types::enums::WindowType;
use asap_types::enums::WindowKind;
use asap_types::AggregationType;
use asap_types::KeyByLabelNames;
use std::sync::Arc;
Expand All @@ -318,7 +318,7 @@ mod tests {
String::new(),
60,
60,
WindowType::Tumbling,
WindowKind::Tumbling,
String::new(),
metric.to_string(),
None,
Expand Down
4 changes: 2 additions & 2 deletions data_plane/src/precompute_engine/output_sink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ mod tests {
use crate::storage_engines::sketch_db::index::{AggKind, SidLookup};
use crate::storage_engines::types::{KeyByLabelValues, StreamingConfig};
use asap_types::aggregation_config::AggregationConfig;
use asap_types::enums::WindowType;
use asap_types::enums::WindowKind;
use asap_types::AggregationType;
use asap_types::KeyByLabelNames;
use std::collections::HashMap;
Expand All @@ -266,7 +266,7 @@ mod tests {
original_yaml: String::new(),
window_size: 1,
slide_interval: 1,
window_type: WindowType::Tumbling,
window_type: WindowKind::Tumbling,
spatial_filter: String::new(),
spatial_filter_normalized: String::new(),
metric: metric.to_string(),
Expand Down
8 changes: 4 additions & 4 deletions data_plane/src/precompute_engine/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1370,7 +1370,7 @@ mod tests {
use crate::precompute_engine::output_sink::CapturingOutputSink;
use crate::storage_engines::types::StreamingConfig;
use asap_sketchlib::KllSketch;
use asap_types::enums::WindowType;
use asap_types::enums::WindowKind;
use asap_types::AggregationType;

fn make_agg_config(
Expand Down Expand Up @@ -1410,9 +1410,9 @@ mod tests {
// streaming-config map by reading `config.policy_fp_u64()`
// from the returned value.
let window_type = if slide_secs == 0 || slide_secs == window_secs {
WindowType::Tumbling
WindowKind::Tumbling
} else {
WindowType::Sliding
WindowKind::Sliding
};
AggregationConfig::new(
agg_type,
Expand Down Expand Up @@ -2184,7 +2184,7 @@ aggregations:
String::new(),
60,
0,
WindowType::Tumbling,
WindowKind::Tumbling,
"http_requests_total".to_string(),
"http_requests_total".to_string(),
Some(60),
Expand Down
4 changes: 2 additions & 2 deletions data_plane/src/query_engines/asap_query_engine/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2201,7 +2201,7 @@ mod sketch_query_tests {
mod hot_reload_phase2_tests {
use super::*;
use crate::storage_engines::types::{
AggregationType, CleanupPolicy, HotReloadStreamingConfig, StreamingConfig, WindowType,
AggregationType, CleanupPolicy, HotReloadStreamingConfig, StreamingConfig, WindowKind,
};
use asap_types::KeyByLabelNames;

Expand Down Expand Up @@ -2242,7 +2242,7 @@ mod hot_reload_phase2_tests {
String::new(),
60,
60,
WindowType::Tumbling,
WindowKind::Tumbling,
String::new(),
metric.to_string(),
None,
Expand Down
Loading