diff --git a/hydroflow/tests/snapshots/surface_lattice_bimorphism__cartesian_product@graphvis_dot.snap b/hydroflow/tests/snapshots/surface_lattice_bimorphism__cartesian_product@graphvis_dot.snap index dae12d839db5..9e81d0e6973d 100644 --- a/hydroflow/tests/snapshots/surface_lattice_bimorphism__cartesian_product@graphvis_dot.snap +++ b/hydroflow/tests/snapshots/surface_lattice_bimorphism__cartesian_product@graphvis_dot.snap @@ -12,22 +12,18 @@ digraph { n5v1 [label="(n5v1) map(SetUnionSingletonSet::new_from)", shape=invhouse, fillcolor="#88aaff"] n6v1 [label="(n6v1) state::<'static, SetUnionHashSet>()", shape=invhouse, fillcolor="#88aaff"] n7v1 [label="(n7v1) lattice_bimorphism(CartesianProductBimorphism::>::default(), lhs, rhs)", shape=invhouse, fillcolor="#88aaff"] - n8v1 [label="(n8v1) lattice_reduce()", shape=invhouse, fillcolor="#88aaff"] - n9v1 [label="(n9v1) for_each(|x| out_send.send(x).unwrap())", shape=house, fillcolor="#ffff88"] + n8v1 [label="(n8v1) for_each(|x| out_send.send(x).unwrap())", shape=house, fillcolor="#ffff88"] + n9v1 [label="(n9v1) handoff", shape=parallelogram, fillcolor="#ddddff"] n10v1 [label="(n10v1) handoff", shape=parallelogram, fillcolor="#ddddff"] - n11v1 [label="(n11v1) handoff", shape=parallelogram, fillcolor="#ddddff"] - n12v1 [label="(n12v1) handoff", shape=parallelogram, fillcolor="#ddddff"] n2v1 -> n3v1 n1v1 -> n2v1 n5v1 -> n6v1 n4v1 -> n5v1 - n3v1 -> n10v1 - n6v1 -> n11v1 - n8v1 -> n9v1 - n7v1 -> n12v1 - n10v1 -> n7v1 [label="0"] - n11v1 -> n7v1 [label="1"] - n12v1 -> n8v1 [color=red] + n3v1 -> n9v1 + n6v1 -> n10v1 + n7v1 -> n8v1 + n9v1 -> n7v1 [label="0"] + n10v1 -> n7v1 [label="1"] n3v1 -> n7v1 [color=red] n6v1 -> n7v1 [color=red] subgraph "cluster n1v1" { @@ -63,21 +59,11 @@ digraph { style=filled label = "sg_3v1\nstratum 1" n7v1 + n8v1 subgraph "cluster_sg_3v1_var_my_join" { label="var my_join" n7v1 - } - } - subgraph "cluster n4v1" { - fillcolor="#dddddd" - style=filled - label = "sg_4v1\nstratum 1" - n8v1 - n9v1 - subgraph "cluster_sg_4v1_var_my_join" { - label="var my_join" n8v1 - n9v1 } } } diff --git a/hydroflow/tests/snapshots/surface_lattice_bimorphism__cartesian_product@graphvis_mermaid.snap b/hydroflow/tests/snapshots/surface_lattice_bimorphism__cartesian_product@graphvis_mermaid.snap index 7b6a31512589..60c4b26b33f7 100644 --- a/hydroflow/tests/snapshots/surface_lattice_bimorphism__cartesian_product@graphvis_mermaid.snap +++ b/hydroflow/tests/snapshots/surface_lattice_bimorphism__cartesian_product@graphvis_mermaid.snap @@ -15,24 +15,20 @@ linkStyle default stroke:#aaa 5v1[\"(5v1) map(SetUnionSingletonSet::new_from)"/]:::pullClass 6v1[\"(6v1) state::<'static, SetUnionHashSet<u32>>()"/]:::pullClass 7v1[\"(7v1) lattice_bimorphism(CartesianProductBimorphism::<HashSet<_>>::default(), lhs, rhs)"/]:::pullClass -8v1[\"(8v1) lattice_reduce()"/]:::pullClass -9v1[/"(9v1) for_each(|x| out_send.send(x).unwrap())"\]:::pushClass +8v1[/"(8v1) for_each(|x| out_send.send(x).unwrap())"\]:::pushClass +9v1["(9v1) handoff"]:::otherClass 10v1["(10v1) handoff"]:::otherClass -11v1["(11v1) handoff"]:::otherClass -12v1["(12v1) handoff"]:::otherClass 2v1-->3v1 1v1-->2v1 5v1-->6v1 4v1-->5v1 -3v1-->10v1 -6v1-->11v1 -8v1-->9v1 -7v1-->12v1 -10v1-->|0|7v1 -11v1-->|1|7v1 -12v1-->8v1; linkStyle 10 stroke:#060 -3v1--x7v1; linkStyle 11 stroke:red -6v1--x7v1; linkStyle 12 stroke:red +3v1-->9v1 +6v1-->10v1 +7v1-->8v1 +9v1-->|0|7v1 +10v1-->|1|7v1 +3v1--x7v1; linkStyle 9 stroke:red +6v1--x7v1; linkStyle 10 stroke:red subgraph sg_1v1 ["sg_1v1 stratum 0"] 1v1 2v1 @@ -55,15 +51,9 @@ subgraph sg_2v1 ["sg_2v1 stratum 0"] end subgraph sg_3v1 ["sg_3v1 stratum 1"] 7v1 + 8v1 subgraph sg_3v1_var_my_join ["var my_join"] 7v1 - end -end -subgraph sg_4v1 ["sg_4v1 stratum 1"] - 8v1 - 9v1 - subgraph sg_4v1_var_my_join ["var my_join"] 8v1 - 9v1 end end diff --git a/hydroflow/tests/snapshots/surface_lattice_bimorphism__cartesian_product_1401@graphvis_dot.snap b/hydroflow/tests/snapshots/surface_lattice_bimorphism__cartesian_product_1401@graphvis_dot.snap new file mode 100644 index 000000000000..a1f6888a2b86 --- /dev/null +++ b/hydroflow/tests/snapshots/surface_lattice_bimorphism__cartesian_product_1401@graphvis_dot.snap @@ -0,0 +1,69 @@ +--- +source: hydroflow/tests/surface_lattice_bimorphism.rs +expression: "df.meta_graph().unwrap().to_dot(& Default :: default())" +--- +digraph { + node [fontname="Monaco,Menlo,Consolas,"Droid Sans Mono",Inconsolata,"Courier New",monospace", style=filled]; + edge [fontname="Monaco,Menlo,Consolas,"Droid Sans Mono",Inconsolata,"Courier New",monospace"]; + n1v1 [label="(n1v1) source_iter(0..1)", shape=invhouse, fillcolor="#88aaff"] + n2v1 [label="(n2v1) map(SetUnionSingletonSet::new_from)", shape=invhouse, fillcolor="#88aaff"] + n3v1 [label="(n3v1) state::<'static, SetUnionHashSet>()", shape=invhouse, fillcolor="#88aaff"] + n4v1 [label="(n4v1) source_iter(1..2)", shape=invhouse, fillcolor="#88aaff"] + n5v1 [label="(n5v1) map(SetUnionSingletonSet::new_from)", shape=invhouse, fillcolor="#88aaff"] + n6v1 [label="(n6v1) state::<'static, SetUnionHashSet>()", shape=invhouse, fillcolor="#88aaff"] + n7v1 [label="(n7v1) lattice_bimorphism(CartesianProductBimorphism::>::default(), lhs, rhs)", shape=invhouse, fillcolor="#88aaff"] + n8v1 [label="(n8v1) for_each(|x| out_send.send(x).unwrap())", shape=house, fillcolor="#ffff88"] + n9v1 [label="(n9v1) handoff", shape=parallelogram, fillcolor="#ddddff"] + n10v1 [label="(n10v1) handoff", shape=parallelogram, fillcolor="#ddddff"] + n2v1 -> n3v1 + n1v1 -> n2v1 + n5v1 -> n6v1 + n4v1 -> n5v1 + n3v1 -> n9v1 + n6v1 -> n10v1 + n7v1 -> n8v1 + n9v1 -> n7v1 [label="0"] + n10v1 -> n7v1 [label="1"] + n3v1 -> n7v1 [color=red] + n6v1 -> n7v1 [color=red] + subgraph "cluster n1v1" { + fillcolor="#dddddd" + style=filled + label = "sg_1v1\nstratum 0" + n1v1 + n2v1 + n3v1 + subgraph "cluster_sg_1v1_var_lhs" { + label="var lhs" + n1v1 + n2v1 + n3v1 + } + } + subgraph "cluster n2v1" { + fillcolor="#dddddd" + style=filled + label = "sg_2v1\nstratum 0" + n4v1 + n5v1 + n6v1 + subgraph "cluster_sg_2v1_var_rhs" { + label="var rhs" + n4v1 + n5v1 + n6v1 + } + } + subgraph "cluster n3v1" { + fillcolor="#dddddd" + style=filled + label = "sg_3v1\nstratum 1" + n7v1 + n8v1 + subgraph "cluster_sg_3v1_var_my_join" { + label="var my_join" + n7v1 + n8v1 + } + } +} diff --git a/hydroflow/tests/snapshots/surface_lattice_bimorphism__cartesian_product_1401@graphvis_mermaid.snap b/hydroflow/tests/snapshots/surface_lattice_bimorphism__cartesian_product_1401@graphvis_mermaid.snap new file mode 100644 index 000000000000..08e6a806fc42 --- /dev/null +++ b/hydroflow/tests/snapshots/surface_lattice_bimorphism__cartesian_product_1401@graphvis_mermaid.snap @@ -0,0 +1,59 @@ +--- +source: hydroflow/tests/surface_lattice_bimorphism.rs +expression: "df.meta_graph().unwrap().to_mermaid(& Default :: default())" +--- +%%{init:{'theme':'base','themeVariables':{'clusterBkg':'#ddd','clusterBorder':'#888'}}}%% +flowchart TD +classDef pullClass fill:#8af,stroke:#000,text-align:left,white-space:pre +classDef pushClass fill:#ff8,stroke:#000,text-align:left,white-space:pre +classDef otherClass fill:#fdc,stroke:#000,text-align:left,white-space:pre +linkStyle default stroke:#aaa +1v1[\"(1v1) source_iter(0..1)"/]:::pullClass +2v1[\"(2v1) map(SetUnionSingletonSet::new_from)"/]:::pullClass +3v1[\"(3v1) state::<'static, SetUnionHashSet<u32>>()"/]:::pullClass +4v1[\"(4v1) source_iter(1..2)"/]:::pullClass +5v1[\"(5v1) map(SetUnionSingletonSet::new_from)"/]:::pullClass +6v1[\"(6v1) state::<'static, SetUnionHashSet<u32>>()"/]:::pullClass +7v1[\"(7v1) lattice_bimorphism(CartesianProductBimorphism::<HashSet<_>>::default(), lhs, rhs)"/]:::pullClass +8v1[/"(8v1) for_each(|x| out_send.send(x).unwrap())"\]:::pushClass +9v1["(9v1) handoff"]:::otherClass +10v1["(10v1) handoff"]:::otherClass +2v1-->3v1 +1v1-->2v1 +5v1-->6v1 +4v1-->5v1 +3v1-->9v1 +6v1-->10v1 +7v1-->8v1 +9v1-->|0|7v1 +10v1-->|1|7v1 +3v1--x7v1; linkStyle 9 stroke:red +6v1--x7v1; linkStyle 10 stroke:red +subgraph sg_1v1 ["sg_1v1 stratum 0"] + 1v1 + 2v1 + 3v1 + subgraph sg_1v1_var_lhs ["var lhs"] + 1v1 + 2v1 + 3v1 + end +end +subgraph sg_2v1 ["sg_2v1 stratum 0"] + 4v1 + 5v1 + 6v1 + subgraph sg_2v1_var_rhs ["var rhs"] + 4v1 + 5v1 + 6v1 + end +end +subgraph sg_3v1 ["sg_3v1 stratum 1"] + 7v1 + 8v1 + subgraph sg_3v1_var_my_join ["var my_join"] + 7v1 + 8v1 + end +end diff --git a/hydroflow/tests/snapshots/surface_lattice_bimorphism__cartesian_product_tick_state@graphvis_dot.snap b/hydroflow/tests/snapshots/surface_lattice_bimorphism__cartesian_product_tick_state@graphvis_dot.snap index 8e00b09a5bba..239b30948c41 100644 --- a/hydroflow/tests/snapshots/surface_lattice_bimorphism__cartesian_product_tick_state@graphvis_dot.snap +++ b/hydroflow/tests/snapshots/surface_lattice_bimorphism__cartesian_product_tick_state@graphvis_dot.snap @@ -12,24 +12,20 @@ digraph { n5v1 [label="(n5v1) map(SetUnionSingletonSet::new_from)", shape=invhouse, fillcolor="#88aaff"] n6v1 [label="(n6v1) state::<'tick, SetUnionHashSet>()", shape=invhouse, fillcolor="#88aaff"] n7v1 [label="(n7v1) lattice_bimorphism(CartesianProductBimorphism::>::default(), lhs, rhs)", shape=invhouse, fillcolor="#88aaff"] - n8v1 [label="(n8v1) lattice_reduce()", shape=invhouse, fillcolor="#88aaff"] - n9v1 [label="(n9v1) inspect(|x| println!(\"{:?}: {:?}\", context.current_tick(), x))", shape=invhouse, fillcolor="#88aaff"] - n10v1 [label="(n10v1) for_each(|x| out_send.send(x).unwrap())", shape=house, fillcolor="#ffff88"] + n8v1 [label="(n8v1) inspect(|x| println!(\"{:?}: {:?}\", context.current_tick(), x))", shape=invhouse, fillcolor="#88aaff"] + n9v1 [label="(n9v1) for_each(|x| out_send.send(x).unwrap())", shape=house, fillcolor="#ffff88"] + n10v1 [label="(n10v1) handoff", shape=parallelogram, fillcolor="#ddddff"] n11v1 [label="(n11v1) handoff", shape=parallelogram, fillcolor="#ddddff"] - n12v1 [label="(n12v1) handoff", shape=parallelogram, fillcolor="#ddddff"] - n13v1 [label="(n13v1) handoff", shape=parallelogram, fillcolor="#ddddff"] n2v1 -> n3v1 n1v1 -> n2v1 n5v1 -> n6v1 n4v1 -> n5v1 - n3v1 -> n11v1 [label="items"] - n6v1 -> n12v1 [label="items"] - n9v1 -> n10v1 + n3v1 -> n10v1 [label="items"] + n6v1 -> n11v1 [label="items"] n8v1 -> n9v1 - n7v1 -> n13v1 - n11v1 -> n7v1 [label="0"] - n12v1 -> n7v1 [label="1"] - n13v1 -> n8v1 [color=red] + n7v1 -> n8v1 + n10v1 -> n7v1 [label="0"] + n11v1 -> n7v1 [label="1"] n3v1 -> n7v1 [color=red] n6v1 -> n7v1 [color=red] subgraph "cluster n1v1" { @@ -65,24 +61,13 @@ digraph { style=filled label = "sg_3v1\nstratum 1" n7v1 - subgraph "cluster_sg_3v1_var_my_join" { - label="var my_join" - n7v1 - } - } - subgraph "cluster n4v1" { - fillcolor="#dddddd" - style=filled - label = "sg_4v1\nstratum 1" n8v1 n9v1 - n10v1 - subgraph "cluster_sg_4v1_var_my_join" { + subgraph "cluster_sg_3v1_var_my_join" { label="var my_join" + n7v1 n8v1 n9v1 - n10v1 } } } - diff --git a/hydroflow/tests/snapshots/surface_lattice_bimorphism__cartesian_product_tick_state@graphvis_mermaid.snap b/hydroflow/tests/snapshots/surface_lattice_bimorphism__cartesian_product_tick_state@graphvis_mermaid.snap index 639b4d963c73..a71d84cc9f12 100644 --- a/hydroflow/tests/snapshots/surface_lattice_bimorphism__cartesian_product_tick_state@graphvis_mermaid.snap +++ b/hydroflow/tests/snapshots/surface_lattice_bimorphism__cartesian_product_tick_state@graphvis_mermaid.snap @@ -15,26 +15,22 @@ linkStyle default stroke:#aaa 5v1[\"(5v1) map(SetUnionSingletonSet::new_from)"/]:::pullClass 6v1[\"(6v1) state::<'tick, SetUnionHashSet<u32>>()"/]:::pullClass 7v1[\"(7v1) lattice_bimorphism(CartesianProductBimorphism::<HashSet<_>>::default(), lhs, rhs)"/]:::pullClass -8v1[\"(8v1) lattice_reduce()"/]:::pullClass -9v1[\"(9v1) inspect(|x| println!("{:?}: {:?}", context.current_tick(), x))"/]:::pullClass -10v1[/"(10v1) for_each(|x| out_send.send(x).unwrap())"\]:::pushClass +8v1[\"(8v1) inspect(|x| println!("{:?}: {:?}", context.current_tick(), x))"/]:::pullClass +9v1[/"(9v1) for_each(|x| out_send.send(x).unwrap())"\]:::pushClass +10v1["(10v1) handoff"]:::otherClass 11v1["(11v1) handoff"]:::otherClass -12v1["(12v1) handoff"]:::otherClass -13v1["(13v1) handoff"]:::otherClass 2v1-->3v1 1v1-->2v1 5v1-->6v1 4v1-->5v1 -3v1-->|items|11v1 -6v1-->|items|12v1 -9v1-->10v1 +3v1-->|items|10v1 +6v1-->|items|11v1 8v1-->9v1 -7v1-->13v1 -11v1-->|0|7v1 -12v1-->|1|7v1 -13v1-->8v1; linkStyle 11 stroke:#060 -3v1--x7v1; linkStyle 12 stroke:red -6v1--x7v1; linkStyle 13 stroke:red +7v1-->8v1 +10v1-->|0|7v1 +11v1-->|1|7v1 +3v1--x7v1; linkStyle 10 stroke:red +6v1--x7v1; linkStyle 11 stroke:red subgraph sg_1v1 ["sg_1v1 stratum 0"] 1v1 2v1 @@ -57,18 +53,11 @@ subgraph sg_2v1 ["sg_2v1 stratum 0"] end subgraph sg_3v1 ["sg_3v1 stratum 1"] 7v1 - subgraph sg_3v1_var_my_join ["var my_join"] - 7v1 - end -end -subgraph sg_4v1 ["sg_4v1 stratum 1"] 8v1 9v1 - 10v1 - subgraph sg_4v1_var_my_join ["var my_join"] + subgraph sg_3v1_var_my_join ["var my_join"] + 7v1 8v1 9v1 - 10v1 end end - diff --git a/hydroflow/tests/snapshots/surface_lattice_bimorphism__join@graphvis_dot.snap b/hydroflow/tests/snapshots/surface_lattice_bimorphism__join@graphvis_dot.snap index 4f4c53e737d3..11eb8a895be1 100644 --- a/hydroflow/tests/snapshots/surface_lattice_bimorphism__join@graphvis_dot.snap +++ b/hydroflow/tests/snapshots/surface_lattice_bimorphism__join@graphvis_dot.snap @@ -12,22 +12,18 @@ digraph { n5v1 [label="(n5v1) map(|(k, v)| MapUnionSingletonMap::new_from((k, SetUnionSingletonSet::new_from(v))))", shape=invhouse, fillcolor="#88aaff"] n6v1 [label="(n6v1) state::<'static, MapUnionHashMap>>()", shape=invhouse, fillcolor="#88aaff"] n7v1 [label="(n7v1) lattice_bimorphism(\l KeyedBimorphism::<\l HashMap<_, _>,\l _,\l >::new(CartesianProductBimorphism::>::default()),\l lhs,\l rhs,\l)\l", shape=invhouse, fillcolor="#88aaff"] - n8v1 [label="(n8v1) lattice_reduce()", shape=invhouse, fillcolor="#88aaff"] - n9v1 [label="(n9v1) for_each(|x| out_send.send(x).unwrap())", shape=house, fillcolor="#ffff88"] + n8v1 [label="(n8v1) for_each(|x| out_send.send(x).unwrap())", shape=house, fillcolor="#ffff88"] + n9v1 [label="(n9v1) handoff", shape=parallelogram, fillcolor="#ddddff"] n10v1 [label="(n10v1) handoff", shape=parallelogram, fillcolor="#ddddff"] - n11v1 [label="(n11v1) handoff", shape=parallelogram, fillcolor="#ddddff"] - n12v1 [label="(n12v1) handoff", shape=parallelogram, fillcolor="#ddddff"] n2v1 -> n3v1 n1v1 -> n2v1 n5v1 -> n6v1 n4v1 -> n5v1 - n3v1 -> n10v1 - n6v1 -> n11v1 - n8v1 -> n9v1 - n7v1 -> n12v1 - n10v1 -> n7v1 [label="0"] - n11v1 -> n7v1 [label="1"] - n12v1 -> n8v1 [color=red] + n3v1 -> n9v1 + n6v1 -> n10v1 + n7v1 -> n8v1 + n9v1 -> n7v1 [label="0"] + n10v1 -> n7v1 [label="1"] n3v1 -> n7v1 [color=red] n6v1 -> n7v1 [color=red] subgraph "cluster n1v1" { @@ -63,22 +59,11 @@ digraph { style=filled label = "sg_3v1\nstratum 1" n7v1 + n8v1 subgraph "cluster_sg_3v1_var_my_join" { label="var my_join" n7v1 - } - } - subgraph "cluster n4v1" { - fillcolor="#dddddd" - style=filled - label = "sg_4v1\nstratum 1" - n8v1 - n9v1 - subgraph "cluster_sg_4v1_var_my_join" { - label="var my_join" n8v1 - n9v1 } } } - diff --git a/hydroflow/tests/snapshots/surface_lattice_bimorphism__join@graphvis_mermaid.snap b/hydroflow/tests/snapshots/surface_lattice_bimorphism__join@graphvis_mermaid.snap index c271ea026819..f4a08363658f 100644 --- a/hydroflow/tests/snapshots/surface_lattice_bimorphism__join@graphvis_mermaid.snap +++ b/hydroflow/tests/snapshots/surface_lattice_bimorphism__join@graphvis_mermaid.snap @@ -15,24 +15,20 @@ linkStyle default stroke:#aaa 5v1[\"(5v1) map(|(k, v)| MapUnionSingletonMap::new_from((k, SetUnionSingletonSet::new_from(v))))"/]:::pullClass 6v1[\"(6v1) state::<'static, MapUnionHashMap<usize, SetUnionHashSet<usize>>>()"/]:::pullClass 7v1[\"
(7v1)
lattice_bimorphism(
KeyedBimorphism::<
HashMap<_, _>,
_,
>::new(CartesianProductBimorphism::<HashSet<_>>::default()),
lhs,
rhs,
)
"/]:::pullClass -8v1[\"(8v1) lattice_reduce()"/]:::pullClass -9v1[/"(9v1) for_each(|x| out_send.send(x).unwrap())"\]:::pushClass +8v1[/"(8v1) for_each(|x| out_send.send(x).unwrap())"\]:::pushClass +9v1["(9v1) handoff"]:::otherClass 10v1["(10v1) handoff"]:::otherClass -11v1["(11v1) handoff"]:::otherClass -12v1["(12v1) handoff"]:::otherClass 2v1-->3v1 1v1-->2v1 5v1-->6v1 4v1-->5v1 -3v1-->10v1 -6v1-->11v1 -8v1-->9v1 -7v1-->12v1 -10v1-->|0|7v1 -11v1-->|1|7v1 -12v1-->8v1; linkStyle 10 stroke:#060 -3v1--x7v1; linkStyle 11 stroke:red -6v1--x7v1; linkStyle 12 stroke:red +3v1-->9v1 +6v1-->10v1 +7v1-->8v1 +9v1-->|0|7v1 +10v1-->|1|7v1 +3v1--x7v1; linkStyle 9 stroke:red +6v1--x7v1; linkStyle 10 stroke:red subgraph sg_1v1 ["sg_1v1 stratum 0"] 1v1 2v1 @@ -55,16 +51,9 @@ subgraph sg_2v1 ["sg_2v1 stratum 0"] end subgraph sg_3v1 ["sg_3v1 stratum 1"] 7v1 + 8v1 subgraph sg_3v1_var_my_join ["var my_join"] 7v1 - end -end -subgraph sg_4v1 ["sg_4v1 stratum 1"] - 8v1 - 9v1 - subgraph sg_4v1_var_my_join ["var my_join"] 8v1 - 9v1 end end - diff --git a/hydroflow/tests/surface_lattice_bimorphism.rs b/hydroflow/tests/surface_lattice_bimorphism.rs index 30ff17165576..9909bc0832a5 100644 --- a/hydroflow/tests/surface_lattice_bimorphism.rs +++ b/hydroflow/tests/surface_lattice_bimorphism.rs @@ -27,7 +27,6 @@ pub fn test_cartesian_product() { rhs -> [1]my_join; my_join = lattice_bimorphism(CartesianProductBimorphism::>::default(), #lhs, #rhs) - -> lattice_reduce() -> for_each(|x| out_send.send(x).unwrap()); }; @@ -47,6 +46,33 @@ pub fn test_cartesian_product() { ); } +#[multiplatform_test(test, wasm, env_tracing)] +pub fn test_cartesian_product_1401() { + let (out_send, out_recv) = hydroflow::util::unbounded_channel::<_>(); + + let mut df = hydroflow_syntax! { + lhs = source_iter(0..1) + -> map(SetUnionSingletonSet::new_from) + -> state::<'static, SetUnionHashSet>(); + rhs = source_iter(1..2) + -> map(SetUnionSingletonSet::new_from) + -> state::<'static, SetUnionHashSet>(); + + lhs -> [0]my_join; + rhs -> [1]my_join; + + my_join = lattice_bimorphism(CartesianProductBimorphism::>::default(), #lhs, #rhs) + -> for_each(|x| out_send.send(x).unwrap()); + }; + assert_graphvis_snapshots!(df); + df.run_available(); + + assert_eq!( + &[SetUnionHashSet::new(HashSet::from_iter([(0, 1)]))], + &*collect_ready::, _>(out_recv) + ); +} + #[multiplatform_test] pub fn test_join() { let (out_send, out_recv) = hydroflow::util::unbounded_channel::<_>(); @@ -63,7 +89,6 @@ pub fn test_join() { rhs -> [1]my_join; my_join = lattice_bimorphism(KeyedBimorphism::, _>::new(CartesianProductBimorphism::>::default()), #lhs, #rhs) - -> lattice_reduce() -> for_each(|x| out_send.send(x).unwrap()); }; @@ -105,7 +130,6 @@ pub fn test_cartesian_product_tick_state() { rhs[items] -> [1]my_join; my_join = lattice_bimorphism(CartesianProductBimorphism::>::default(), #lhs, #rhs) - -> lattice_reduce() -> inspect(|x| println!("{:?}: {:?}", context.current_tick(), x)) -> for_each(|x| out_send.send(x).unwrap()); }; @@ -140,7 +164,7 @@ pub fn test_cartesian_product_tick_state() { ); } -#[test] +#[multiplatform_test] fn test_ght_join_bimorphism() { type MyGhtATrie = GhtType!(u32, u64, u16 => &'static str: VariadicHashSet); type MyGhtBTrie = GhtType!(u32, u64, u16 => &'static str: VariadicHashSet); @@ -176,13 +200,10 @@ fn test_ght_join_bimorphism() { my_join = lattice_bimorphism(MyBim::default(), #lhs, #rhs) - -> lattice_reduce() -> enumerate() -> inspect(|x| println!("{:?} {:#?}", context.current_tick(), x)) -> flat_map(|(_num, ght)| ght.recursive_iter().map(::clone_ref_var).collect::>()) -> null(); - // -> for_each(|x| println!("{:#?}\n", x)); }; - // hf.meta_graph().unwrap().open_mermaid(&Default::default()); hf.run_available(); } diff --git a/hydroflow_lang/src/graph/ops/lattice_bimorphism.rs b/hydroflow_lang/src/graph/ops/lattice_bimorphism.rs index 769af75c4fe5..a5ef7183ec7c 100644 --- a/hydroflow_lang/src/graph/ops/lattice_bimorphism.rs +++ b/hydroflow_lang/src/graph/ops/lattice_bimorphism.rs @@ -6,7 +6,40 @@ use super::{ RANGE_0, RANGE_1, }; -// TODO(mingwei): +/// An operator representing a [lattice bimorphism](https://hydro.run/docs/hydroflow/lattices_crate/lattice_math#lattice-bimorphism). +/// +/// > 2 input streams, of type `LhsItem` and `RhsItem`. +/// +/// > Three argument, one `LatticeBimorphism` function `Func`, an `LhsState` singleton reference, and an `RhsState` singleton reference. +/// +/// > 1 output stream of the output type of the `LatticeBimorphism` function. +/// +/// The function must be a lattice bimorphism for both `(LhsState, RhsItem)` and `(RhsState, LhsItem)`. +/// +/// ```hydroflow +/// use std::collections::HashSet; +/// use lattices::set_union::{CartesianProductBimorphism, SetUnionHashSet, SetUnionSingletonSet}; +/// +/// lhs = source_iter(0..3) +/// -> map(SetUnionSingletonSet::new_from) +/// -> state::<'static, SetUnionHashSet>(); +/// rhs = source_iter(3..5) +/// -> map(SetUnionSingletonSet::new_from) +/// -> state::<'static, SetUnionHashSet>(); +/// +/// lhs -> [0]my_join; +/// rhs -> [1]my_join; +/// +/// my_join = lattice_bimorphism(CartesianProductBimorphism::>::default(), #lhs, #rhs) +/// -> assert_eq([SetUnionHashSet::new(HashSet::from_iter([ +/// (0, 3), +/// (0, 4), +/// (1, 3), +/// (1, 4), +/// (2, 3), +/// (2, 4), +/// ]))]); +/// ``` pub const LATTICE_BIMORPHISM: OperatorConstraints = OperatorConstraints { name: "lattice_bimorphism", categories: &[OperatorCategory::MultiIn], @@ -53,7 +86,7 @@ pub const LATTICE_BIMORPHISM: OperatorConstraints = OperatorConstraints { lhs_state_handle: #root::scheduled::state::StateHandle<::std::cell::RefCell>, rhs_state_handle: #root::scheduled::state::StateHandle<::std::cell::RefCell>, context: &'a #root::scheduled::context::Context, - ) -> impl 'a + ::std::iter::Iterator + ) -> Option where Func: 'a + #root::lattices::LatticeBimorphism @@ -62,11 +95,12 @@ pub const LATTICE_BIMORPHISM: OperatorConstraints = OperatorConstraints { RhsIter: 'a + ::std::iter::Iterator, LhsState: 'static + ::std::clone::Clone, RhsState: 'static + ::std::clone::Clone, + Output: #root::lattices::Merge, { let lhs_state = context.state_ref(lhs_state_handle); let rhs_state = context.state_ref(rhs_state_handle); - ::std::iter::from_fn(move || { + let iter = ::std::iter::from_fn(move || { // Use `from_fn` instead of `chain` to dodge multiple ownership of `func`. if let Some(lhs_item) = lhs_iter.next() { Some(func.call(lhs_item, (*rhs_state.borrow()).clone())) @@ -74,7 +108,8 @@ pub const LATTICE_BIMORPHISM: OperatorConstraints = OperatorConstraints { let rhs_item = rhs_iter.next()?; Some(func.call((*lhs_state.borrow()).clone(), rhs_item)) } - }) + }); + iter.reduce(|a, b| #root::lattices::Merge::merge_owned(a, b)) } check_inputs( #func, @@ -83,7 +118,7 @@ pub const LATTICE_BIMORPHISM: OperatorConstraints = OperatorConstraints { #lhs_state_handle, #rhs_state_handle, &#context, - ) + ).into_iter() }; };