@@ -4,6 +4,7 @@ use crate::dataflow::channels::pact::Pipeline;
44use crate :: dataflow:: operators:: generic:: builder_rc:: OperatorBuilder ;
55use crate :: dataflow:: { Scope , Stream , StreamCore } ;
66use crate :: { Container , Data } ;
7+ use crate :: dataflow:: stream:: { OwnedStream , StreamLike } ;
78
89/// Extension trait for `Stream`.
910pub trait Branch < S : Scope , D : Data > {
@@ -31,14 +32,14 @@ pub trait Branch<S: Scope, D: Data> {
3132 fn branch (
3233 self ,
3334 condition : impl Fn ( & S :: Timestamp , & D ) -> bool + ' static ,
34- ) -> ( Stream < S , D > , Stream < S , D > ) ;
35+ ) -> ( OwnedStream < S , Vec < D > > , OwnedStream < S , Vec < D > > ) ;
3536}
3637
3738impl < S : Scope , D : Data > Branch < S , D > for Stream < S , D > {
3839 fn branch (
3940 self ,
4041 condition : impl Fn ( & S :: Timestamp , & D ) -> bool + ' static ,
41- ) -> ( Stream < S , D > , Stream < S , D > ) {
42+ ) -> ( OwnedStream < S , Vec < D > > , OwnedStream < S , Vec < D > > ) {
4243 let mut builder = OperatorBuilder :: new ( "Branch" . to_owned ( ) , self . scope ( ) ) ;
4344
4445 let mut input = builder. new_input ( self , Pipeline ) ;
@@ -71,7 +72,7 @@ impl<S: Scope, D: Data> Branch<S, D> for Stream<S, D> {
7172}
7273
7374/// Extension trait for `Stream`.
74- pub trait BranchWhen < T > : Sized {
75+ pub trait BranchWhen < G : Scope , C : Container > : Sized {
7576 /// Takes one input stream and splits it into two output streams.
7677 /// For each time, the supplied closure is called. If it returns true,
7778 /// the records for that will be sent to the second returned stream, otherwise
@@ -91,11 +92,11 @@ pub trait BranchWhen<T>: Sized {
9192 /// after_five.inspect(|x| println!("Times 5 and later: {:?}", x));
9293 /// });
9394 /// ```
94- fn branch_when ( self , condition : impl Fn ( & T ) -> bool + ' static ) -> ( Self , Self ) ;
95+ fn branch_when ( self , condition : impl Fn ( & G :: Timestamp ) -> bool + ' static ) -> ( OwnedStream < G , C > , OwnedStream < G , C > ) ;
9596}
9697
97- impl < S : Scope , C : Container > BranchWhen < S :: Timestamp > for StreamCore < S , C > {
98- fn branch_when ( self , condition : impl Fn ( & S :: Timestamp ) -> bool + ' static ) -> ( Self , Self ) {
98+ impl < G : Scope , C : Container , S : StreamLike < G , C > > BranchWhen < G , C > for S {
99+ fn branch_when ( self , condition : impl Fn ( & G :: Timestamp ) -> bool + ' static ) -> ( OwnedStream < G , C > , OwnedStream < G , C > ) {
99100 let mut builder = OperatorBuilder :: new ( "Branch" . to_owned ( ) , self . scope ( ) ) ;
100101
101102 let mut input = builder. new_input ( self , Pipeline ) ;
0 commit comments