Skip to content

Commit fd62ee9

Browse files
zzylolclaude
andcommitted
test: port the Stage 1 callers to Operator<NodeId> payloads
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W7qG9aFyPij5uWsyAJCxDW
1 parent 171d229 commit fd62ee9

3 files changed

Lines changed: 56 additions & 60 deletions

File tree

‎crates/executor/tests/deployment_computation.rs‎

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//! Planner-selected PromQL computation compiles from the timed DAG alone;
22
//! the deployment supplies only raw rows at the ingestion frontier.
33
mod common;
4-
use planner_types::ir::ASAPOp;
54
use asap_executor::{
65
operators::Operator,
76
physical_planner::{compile, promql_rows, CompiledPhysicalDAG, InputContract, Source},
@@ -11,6 +10,7 @@ use asap_executor::{
1110
use common::{compile_physical_asap_dag, selected_dag, stage1_candidates};
1211
use futures::{executor::block_on, StreamExt};
1312
use planner_types::ir::physical_export::{PhysicalASAPDAG, PhysicalASAPOperatorPayload};
13+
use planner_types::ir::ASAPOp;
1414
use planner_types::{ir::schema::*, types::AccuracyTarget, workload::*};
1515
use std::{collections::BTreeMap, rc::Rc, sync::Arc};
1616

@@ -71,14 +71,18 @@ fn raw_inputs(dag: &PhysicalASAPDAG) -> Vec<(u64, Arc<Schema>, String)> {
7171
dag.nodes
7272
.iter()
7373
.filter_map(|node| match &node.payload {
74-
PhysicalASAPOperatorPayload::NonASAP(planner_types::ir::NonASAPOp::TimeRange { .. }) => {
74+
PhysicalASAPOperatorPayload::NonASAP(planner_types::ir::NonASAPOp::TimeRange {
75+
..
76+
}) => {
7577
let mut id = node.id;
7678
loop {
7779
let n = dag.nodes.iter().find(|n| n.id == id)?;
78-
if let PhysicalASAPOperatorPayload::NonASAP(planner_types::ir::NonASAPOp::Scan {
79-
source: planner_types::ir::operator::Source::TimeSeries { metric },
80-
..
81-
}) = &n.payload
80+
if let PhysicalASAPOperatorPayload::NonASAP(
81+
planner_types::ir::NonASAPOp::Scan {
82+
source: planner_types::ir::operator::Source::TimeSeries { metric },
83+
..
84+
},
85+
) = &n.payload
8286
{
8387
return Some((
8488
node.id as u64,
@@ -327,9 +331,10 @@ fn with_kind(
327331
) -> PhysicalASAPDAG {
328332
for node in &mut dag.nodes {
329333
if let PhysicalASAPOperatorPayload::NonASAP(planner_types::ir::NonASAPOp::BinaryOp {
330-
operator,
331-
return_bool,
332-
}) = &mut node.payload
334+
operator,
335+
return_bool,
336+
..
337+
}) = &mut node.payload
333338
{
334339
operator.kind = kind.clone();
335340
*return_bool = bool_result;
@@ -526,9 +531,10 @@ fn with_vector_match(
526531
) -> PhysicalASAPDAG {
527532
for node in &mut dag.nodes {
528533
if let PhysicalASAPOperatorPayload::NonASAP(planner_types::ir::NonASAPOp::BinaryOp {
529-
operator,
530-
return_bool: _,
531-
}) = &mut node.payload
534+
operator,
535+
return_bool: _,
536+
..
537+
}) = &mut node.payload
532538
{
533539
operator.vector_match = Some(planner_types::ir::operator::VectorMatch {
534540
kind: kind.clone(),
@@ -614,7 +620,8 @@ fn stored_count_min_bare_count_compiles_to_a_evaluation() {
614620
matches!(
615621
&n.payload,
616622
PhysicalASAPOperatorPayload::ASAP(ASAPOp::SummaryEstimate {
617-
query: SketchStatistic::PointCount { value: None, .. }
623+
query: SketchStatistic::PointCount { value: None, .. },
624+
..
618625
})
619626
)
620627
});
@@ -629,7 +636,12 @@ fn stored_count_min_bare_count_compiles_to_a_evaluation() {
629636
let state = dag
630637
.nodes
631638
.iter()
632-
.find(|n| matches!(n.payload, PhysicalASAPOperatorPayload::ASAP(ASAPOp::SummaryAgg { .. })))
639+
.find(|n| {
640+
matches!(
641+
n.payload,
642+
PhysicalASAPOperatorPayload::ASAP(ASAPOp::SummaryAgg { .. })
643+
)
644+
})
633645
.unwrap();
634646
let PhysicalASAPOperatorPayload::ASAP(ASAPOp::SummaryAgg {
635647
family: FieldDataType::Sketch(kind, _),
@@ -644,10 +656,7 @@ fn stored_count_min_bare_count_compiles_to_a_evaluation() {
644656
let schema = Arc::new(state.output_schema.clone());
645657
let program = compile(
646658
&dag,
647-
BTreeMap::from([(
648-
state.id as u64,
649-
InputContract::bounded(schema.clone()),
650-
)]),
659+
BTreeMap::from([(state.id as u64, InputContract::bounded(schema.clone()))]),
651660
&[dag.roots[0] as u64],
652661
)
653662
.unwrap();

‎crates/executor/tests/weighted_topk_binding.rs‎

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
//! Planner output binds directly to the shared runtime at a declared rate-value frontier.
22
mod common;
3-
use planner_types::ir::ASAPOp;
43
use asap_executor::dag::{
54
operators::Operator,
65
planner::{compile, InputContract, Source},
@@ -12,6 +11,7 @@ use futures::{executor::block_on, StreamExt};
1211
use planner_types::ir::physical_export::{PhysicalASAPDAG, PhysicalASAPOperatorPayload};
1312
use planner_types::ir::properties::*;
1413
use planner_types::ir::schema::{DataType, *};
14+
use planner_types::ir::ASAPOp;
1515
use planner_types::types::AccuracyTarget;
1616
use std::{collections::BTreeMap, rc::Rc, sync::Arc};
1717
#[test]
@@ -106,18 +106,18 @@ fn assert_weighted_binding(algorithm: SketchAlgorithm) {
106106
as Source<'static>;
107107
let compiled = compile(
108108
&placed,
109-
BTreeMap::from([(rate_id.0 as u64, InputContract::bounded(rates.clone()))]),
110-
&[dag.roots[0].0 as u64],
109+
BTreeMap::from([(rate_id as u64, InputContract::bounded(rates.clone()))]),
110+
&[dag.roots[0] as u64],
111111
)
112112
.unwrap();
113113
let physical_dag = compiled
114-
.instantiate(BTreeMap::from([(rate_id.0 as u64, source)]))
114+
.instantiate(BTreeMap::from([(rate_id as u64, source)]))
115115
.unwrap();
116116
let context = RunContext::new(scope, Limits::default()).unwrap();
117117
let output = block_on(async {
118118
let mut output = Vec::new();
119119
let mut stream = physical_dag
120-
.execute(&[dag.roots[0].0 as u64], context)
120+
.execute(&[dag.roots[0] as u64], context)
121121
.unwrap()
122122
.remove(0);
123123
while let Some(batch) = stream.next().await {
@@ -287,17 +287,16 @@ fn direct_rate_topk_preserves_dynamic_unreferenced_labels() {
287287
.find(|node| {
288288
matches!(
289289
&node.payload,
290-
PhysicalASAPOperatorPayload::NonASAP(planner_types::ir::NonASAPOp::TimeRange { .. })
290+
PhysicalASAPOperatorPayload::NonASAP(
291+
planner_types::ir::NonASAPOp::TimeRange { .. }
292+
)
291293
)
292294
})
293295
.unwrap_or_else(|| panic!("no raw counter source: {dag:?}"));
294296
let raw_schema = Arc::new(raw.output_schema.clone());
295297
let raw_compiled = compile(
296298
&dag,
297-
BTreeMap::from([(
298-
raw.id as u64,
299-
InputContract::bounded(raw_schema.clone()),
300-
)]),
299+
BTreeMap::from([(raw.id as u64, InputContract::bounded(raw_schema.clone()))]),
301300
&[dag.roots[0] as u64],
302301
)
303302
.unwrap();
@@ -407,10 +406,7 @@ fn direct_rate_topk_preserves_dynamic_unreferenced_labels() {
407406
}
408407
let compiled = compile(
409408
&dag,
410-
BTreeMap::from([(
411-
input_id as u64,
412-
InputContract::bounded(schema.clone()),
413-
)]),
409+
BTreeMap::from([(input_id as u64, InputContract::bounded(schema.clone()))]),
414410
&[dag.roots[0] as u64],
415411
)
416412
.unwrap();
@@ -510,7 +506,12 @@ fn continuously_maintained_dag(candidate: &Rc<planner_types::ir::OperatorNode>)
510506
let mut pending: Vec<_> = dag
511507
.nodes
512508
.iter()
513-
.filter(|node| matches!(node.payload, PhysicalASAPOperatorPayload::ASAP(ASAPOp::SummaryAgg { .. })))
509+
.filter(|node| {
510+
matches!(
511+
node.payload,
512+
PhysicalASAPOperatorPayload::ASAP(ASAPOp::SummaryAgg { .. })
513+
)
514+
})
514515
.map(|node| node.id)
515516
.collect();
516517
let mut ingestion = std::collections::HashSet::new();

‎crates/integration-tests/tests/precompute_raw_samples.rs‎

Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,12 @@ fn candidates(query: &str, accuracy: AccuracyTarget) -> Vec<Rc<OperatorNode>> {
9393
fn raw_summaries(dag: &PhysicalASAPDAG) -> Vec<(u64, u64)> {
9494
dag.nodes
9595
.iter()
96-
.filter(|node| matches!(node.payload, PhysicalASAPOperatorPayload::ASAP(ASAPOp::SummaryAgg { .. })))
96+
.filter(|node| {
97+
matches!(
98+
node.payload,
99+
PhysicalASAPOperatorPayload::ASAP(ASAPOp::SummaryAgg { .. })
100+
)
101+
})
97102
.filter_map(|node| {
98103
let inputs = dag
99104
.edges
@@ -314,11 +319,7 @@ fn check(
314319
root: u64,
315320
rows: &[(Series, i64, f64)],
316321
) -> Result<String, String> {
317-
let node = dag
318-
.nodes
319-
.iter()
320-
.find(|n| n.id as u64 == root)
321-
.unwrap();
322+
let node = dag.nodes.iter().find(|n| n.id as u64 == root).unwrap();
322323
let PhysicalASAPOperatorPayload::ASAP(ASAPOp::SummaryAgg {
323324
family,
324325
input,
@@ -329,11 +330,7 @@ fn check(
329330
else {
330331
unreachable!()
331332
};
332-
let source_node = dag
333-
.nodes
334-
.iter()
335-
.find(|n| n.id as u64 == source)
336-
.unwrap();
333+
let source_node = dag.nodes.iter().find(|n| n.id as u64 == source).unwrap();
337334
let keys = match reduction {
338335
Reduction::Reduce(keys) => keys
339336
.keys()
@@ -506,11 +503,7 @@ fn grouped_raw_summary(family: FieldDataType, input: SummaryUpdate) -> (Physical
506503
.unwrap();
507504
let mut dag = compile_maintained_physical_asap_dag(&candidate).unwrap();
508505
let (source, root) = raw_summaries(&dag)[0];
509-
let node = dag
510-
.nodes
511-
.iter_mut()
512-
.find(|n| n.id as u64 == root)
513-
.unwrap();
506+
let node = dag.nodes.iter_mut().find(|n| n.id as u64 == root).unwrap();
514507
let PhysicalASAPOperatorPayload::ASAP(ASAPOp::SummaryAgg {
515508
family: old,
516509
input: update,
@@ -527,11 +520,7 @@ fn grouped_raw_summary(family: FieldDataType, input: SummaryUpdate) -> (Physical
527520
*old = family;
528521
*update = input;
529522
let schema = node.output_schema.clone();
530-
for edge in dag
531-
.edges
532-
.iter_mut()
533-
.filter(|e| u64::from(e.producer.0) == root)
534-
{
523+
for edge in dag.edges.iter_mut().filter(|e| e.producer as u64 == root) {
535524
edge.intermediate_schema = schema.clone();
536525
}
537526
(dag, source, root)
@@ -638,12 +627,9 @@ fn raw_sample_without_grouping_drops_labels_and_name() {
638627
.iter()
639628
.position(|f| f.name == "service")
640629
.unwrap();
641-
let node = dag
642-
.nodes
643-
.iter_mut()
644-
.find(|n| n.id as u64 == root)
645-
.unwrap();
646-
let PhysicalASAPOperatorPayload::ASAP(ASAPOp::SummaryAgg { reduction, .. }) = &mut node.payload else {
630+
let node = dag.nodes.iter_mut().find(|n| n.id as u64 == root).unwrap();
631+
let PhysicalASAPOperatorPayload::ASAP(ASAPOp::SummaryAgg { reduction, .. }) = &mut node.payload
632+
else {
647633
unreachable!()
648634
};
649635
*reduction = Reduction::Reduce(GroupKeys::without(vec![service]));

0 commit comments

Comments
 (0)