1717//! let mut builder = Builder::<usize>::new();
1818//!
1919//! // Each node with one input connected to one output.
20- //! builder.add_node(0, 1, 1, vec![vec![Antichain::from_elem(0)]]);
21- //! builder.add_node(1, 1, 1, vec![vec![Antichain::from_elem(0)]]);
22- //! builder.add_node(2, 1, 1, vec![vec![Antichain::from_elem(1)]]);
20+ //! builder.add_node(0, 1, 1, vec![vec![Antichain::from_elem(0)].into() ]);
21+ //! builder.add_node(1, 1, 1, vec![vec![Antichain::from_elem(0)].into() ]);
22+ //! builder.add_node(2, 1, 1, vec![vec![Antichain::from_elem(1)].into() ]);
2323//!
2424//! // Connect nodes in sequence, looping around to the first from the last.
2525//! builder.add_edge(Source::new(0, 0), Target::new(1, 0));
@@ -80,7 +80,7 @@ use crate::progress::{Source, Target};
8080use crate :: progress:: ChangeBatch ;
8181use crate :: progress:: { Location , Port } ;
8282use crate :: progress:: operate:: { Connectivity , PortConnectivity } ;
83- use crate :: progress:: frontier:: { Antichain , MutableAntichain } ;
83+ use crate :: progress:: frontier:: MutableAntichain ;
8484use crate :: progress:: timestamp:: PathSummary ;
8585
8686
@@ -113,9 +113,9 @@ use crate::progress::timestamp::PathSummary;
113113/// let mut builder = Builder::<usize>::new();
114114///
115115/// // Each node with one input connected to one output.
116- /// builder.add_node(0, 1, 1, vec![vec![Antichain::from_elem(0)]]);
117- /// builder.add_node(1, 1, 1, vec![vec![Antichain::from_elem(0)]]);
118- /// builder.add_node(2, 1, 1, vec![vec![Antichain::from_elem(1)]]);
116+ /// builder.add_node(0, 1, 1, vec![vec![Antichain::from_elem(0)].into() ]);
117+ /// builder.add_node(1, 1, 1, vec![vec![Antichain::from_elem(0)].into() ]);
118+ /// builder.add_node(2, 1, 1, vec![vec![Antichain::from_elem(1)].into() ]);
119119///
120120/// // Connect nodes in sequence, looping around to the first from the last.
121121/// builder.add_edge(Source::new(0, 0), Target::new(1, 0));
@@ -160,7 +160,7 @@ impl<T: Timestamp> Builder<T> {
160160
161161 // Assert that all summaries exist.
162162 debug_assert_eq ! ( inputs, summary. len( ) ) ;
163- for x in summary. iter ( ) { debug_assert_eq ! ( outputs, x. len ( ) ) ; }
163+ for x in summary. iter ( ) { debug_assert_eq ! ( outputs, x. next_port ( ) ) ; }
164164
165165 while self . nodes . len ( ) <= index {
166166 self . nodes . push ( Vec :: new ( ) ) ;
@@ -224,9 +224,9 @@ impl<T: Timestamp> Builder<T> {
224224 /// let mut builder = Builder::<usize>::new();
225225 ///
226226 /// // Each node with one input connected to one output.
227- /// builder.add_node(0, 1, 1, vec![vec![Antichain::from_elem(0)]]);
228- /// builder.add_node(1, 1, 1, vec![vec![Antichain::from_elem(0)]]);
229- /// builder.add_node(2, 1, 1, vec![vec![Antichain::from_elem(0)]]);
227+ /// builder.add_node(0, 1, 1, vec![vec![Antichain::from_elem(0)].into() ]);
228+ /// builder.add_node(1, 1, 1, vec![vec![Antichain::from_elem(0)].into() ]);
229+ /// builder.add_node(2, 1, 1, vec![vec![Antichain::from_elem(0)].into() ]);
230230 ///
231231 /// // Connect nodes in sequence, looping around to the first from the last.
232232 /// builder.add_edge(Source::new(0, 0), Target::new(1, 0));
@@ -253,8 +253,8 @@ impl<T: Timestamp> Builder<T> {
253253 ///
254254 /// // Two inputs and outputs, only one of which advances.
255255 /// builder.add_node(0, 2, 2, vec![
256- /// vec![Antichain::from_elem(0),Antichain::new(),],
257- /// vec![Antichain::new(),Antichain::from_elem(1),],
256+ /// vec![Antichain::from_elem(0),Antichain::new(),].into() ,
257+ /// vec![Antichain::new(),Antichain::from_elem(1),].into() ,
258258 /// ]);
259259 ///
260260 /// // Connect each output to the opposite input.
@@ -285,7 +285,7 @@ impl<T: Timestamp> Builder<T> {
285285 for ( input, outputs) in summary. iter ( ) . enumerate ( ) {
286286 let target = Location :: new_target ( index, input) ;
287287 in_degree. entry ( target) . or_insert ( 0 ) ;
288- for ( output, summaries) in outputs. iter ( ) . enumerate ( ) {
288+ for ( output, summaries) in outputs. iter_ports ( ) {
289289 let source = Location :: new_source ( index, output) ;
290290 for summary in summaries. elements ( ) . iter ( ) {
291291 if summary == & Default :: default ( ) {
@@ -322,7 +322,7 @@ impl<T: Timestamp> Builder<T> {
322322 }
323323 } ,
324324 Port :: Target ( port) => {
325- for ( output, summaries) in self . nodes [ node] [ port] . iter ( ) . enumerate ( ) {
325+ for ( output, summaries) in self . nodes [ node] [ port] . iter_ports ( ) {
326326 let source = Location :: new_source ( node, output) ;
327327 for summary in summaries. elements ( ) . iter ( ) {
328328 if summary == & Default :: default ( ) {
@@ -442,7 +442,7 @@ impl<T: Timestamp> PortInformation<T> {
442442 PortInformation {
443443 pointstamps : MutableAntichain :: new ( ) ,
444444 implications : MutableAntichain :: new ( ) ,
445- output_summaries : Vec :: new ( ) ,
445+ output_summaries : PortConnectivity :: default ( ) ,
446446 }
447447 }
448448
@@ -514,7 +514,7 @@ impl<T:Timestamp> Tracker<T> {
514514 . collect :: < Vec < _ > > ( ) ;
515515
516516 // Summary of scope inputs to scope outputs.
517- let mut builder_summary = vec ! [ vec! [ ] ; builder. shape[ 0 ] . 1 ] ;
517+ let mut builder_summary = vec ! [ PortConnectivity :: default ( ) ; builder. shape[ 0 ] . 1 ] ;
518518
519519 // Compile summaries from each location to each scope output.
520520 let output_summaries = summarize_outputs :: < T > ( & builder. nodes , & builder. edges ) ;
@@ -598,7 +598,7 @@ impl<T:Timestamp> Tracker<T> {
598598
599599 for ( time, diff) in changes {
600600 self . total_counts += diff;
601- for ( output, summaries) in operator. output_summaries . iter ( ) . enumerate ( ) {
601+ for ( output, summaries) in operator. output_summaries . iter_ports ( ) {
602602 let output_changes = & mut self . output_changes [ output] ;
603603 summaries
604604 . elements ( )
@@ -617,7 +617,7 @@ impl<T:Timestamp> Tracker<T> {
617617
618618 for ( time, diff) in changes {
619619 self . total_counts += diff;
620- for ( output, summaries) in operator. output_summaries . iter ( ) . enumerate ( ) {
620+ for ( output, summaries) in operator. output_summaries . iter_ports ( ) {
621621 let output_changes = & mut self . output_changes [ output] ;
622622 summaries
623623 . elements ( )
@@ -658,7 +658,7 @@ impl<T:Timestamp> Tracker<T> {
658658
659659 for ( time, diff) in changes {
660660 let nodes = & self . nodes [ location. node ] [ port_index] ;
661- for ( output_port, summaries) in nodes. iter ( ) . enumerate ( ) {
661+ for ( output_port, summaries) in nodes. iter_ports ( ) {
662662 let source = Location { node : location. node , port : Port :: Source ( output_port) } ;
663663 for summary in summaries. elements ( ) . iter ( ) {
664664 if let Some ( new_time) = summary. results_in ( & time) {
@@ -778,17 +778,14 @@ fn summarize_outputs<T: Timestamp>(
778778
779779 // Determine the current path summaries from the input port.
780780 let location = Location { node : location. node , port : Port :: Target ( input_port) } ;
781- let antichains = results
782- . entry ( location)
783- . and_modify ( |antichains| antichains. reserve ( output) )
784- . or_insert_with ( || Vec :: with_capacity ( output) ) ;
785-
786- while antichains. len ( ) <= output { antichains. push ( Antichain :: new ( ) ) ; }
781+ let antichains = results. entry ( location) . or_default ( ) ;
782+ // TODO: This is redundant with `insert_ref` below.
783+ antichains. ensure ( output) ;
787784
788785 // Combine each operator-internal summary to the output with `summary`.
789786 for operator_summary in summaries[ output_port] . elements ( ) . iter ( ) {
790787 if let Some ( combined) = operator_summary. followed_by ( & summary) {
791- if antichains[ output ] . insert ( combined. clone ( ) ) {
788+ if antichains. insert_ref ( output , & combined) {
792789 worklist. push_back ( ( location, output, combined) ) ;
793790 }
794791 }
@@ -803,14 +800,11 @@ fn summarize_outputs<T: Timestamp>(
803800
804801 // Each target should have (at most) one source.
805802 if let Some ( & source) = reverse. get ( & location) {
806- let antichains = results
807- . entry ( source)
808- . and_modify ( |antichains| antichains. reserve ( output) )
809- . or_insert_with ( || Vec :: with_capacity ( output) ) ;
810-
811- while antichains. len ( ) <= output { antichains. push ( Antichain :: new ( ) ) ; }
803+ let antichains = results. entry ( source) . or_default ( ) ;
804+ // TODO: This is redundant with `insert_ref` below.
805+ antichains. ensure ( output) ;
812806
813- if antichains[ output ] . insert ( summary. clone ( ) ) {
807+ if antichains. insert_ref ( output , & summary) {
814808 worklist. push_back ( ( source, output, summary. clone ( ) ) ) ;
815809 }
816810 }
0 commit comments