Dispatch an aggregate scan to the Data Plane via the SPSC bridge. Builds a `TimeseriesOp::Scan` with the alert's aggregate function and group-by columns, dispatches via `dispatch_async`, and decodes the MessagePack response into `(group_key, agg_value)` pairs.
(
state: &Arc<SharedState>,
tenant_id: TenantId,
alert: &AlertDef,
window_start: i64,
window_end: i64,
)
| 147 | /// group-by columns, dispatches via `dispatch_async`, and decodes the |
| 148 | /// MessagePack response into `(group_key, agg_value)` pairs. |
| 149 | async fn execute_aggregate_scan( |
| 150 | state: &Arc<SharedState>, |
| 151 | tenant_id: TenantId, |
| 152 | alert: &AlertDef, |
| 153 | window_start: i64, |
| 154 | window_end: i64, |
| 155 | ) -> crate::Result<Vec<(String, f64)>> { |
| 156 | // Encode WHERE filter as MessagePack for the Data Plane filter evaluator. |
| 157 | let filters = match &alert.where_filter { |
| 158 | Some(f) => zerompk::to_msgpack_vec(f).unwrap_or_default(), |
| 159 | None => Vec::new(), |
| 160 | }; |
| 161 | |
| 162 | let plan = PhysicalPlan::Timeseries(TimeseriesOp::Scan { |
| 163 | collection: alert.collection.clone(), |
| 164 | time_range: (window_start, window_end), |
| 165 | projection: Vec::new(), |
| 166 | limit: 10_000, // Safety cap on group cardinality. |
| 167 | filters, |
| 168 | bucket_interval_ms: 0, // No time bucketing — aggregate over entire window. |
| 169 | group_by: alert.group_by.clone(), |
| 170 | aggregates: vec![( |
| 171 | alert.condition.agg_func.clone(), |
| 172 | alert.condition.column.clone(), |
| 173 | )], |
| 174 | gap_fill: String::new(), |
| 175 | computed_columns: Vec::new(), |
| 176 | rls_filters: Vec::new(), |
| 177 | system_as_of_ms: None, |
| 178 | valid_at_ms: None, |
| 179 | }); |
| 180 | |
| 181 | let payload = sync_dispatch::dispatch_async( |
| 182 | state, |
| 183 | tenant_id, |
| 184 | &alert.collection, |
| 185 | plan, |
| 186 | Duration::from_secs(30), |
| 187 | ) |
| 188 | .await?; |
| 189 | |
| 190 | decode_aggregate_response(&payload, &alert.group_by, &alert.condition.agg_func) |
| 191 | } |
| 192 | |
| 193 | /// Decode the Data Plane's MessagePack response into (group_key, agg_value) pairs. |
| 194 | /// |
no test coverage detected