@@ -4,6 +4,7 @@ use crate::dataflow::channels::pact::Pipeline;
4
4
use crate :: dataflow:: operators:: generic:: builder_rc:: OperatorBuilder ;
5
5
use crate :: dataflow:: { Scope , Stream , StreamCore } ;
6
6
use crate :: { Container , Data } ;
7
+ use crate :: dataflow:: stream:: { OwnedStream , StreamLike } ;
7
8
8
9
/// Extension trait for `Stream`.
9
10
pub trait Branch < S : Scope , D : Data > {
@@ -31,14 +32,14 @@ pub trait Branch<S: Scope, D: Data> {
31
32
fn branch (
32
33
self ,
33
34
condition : impl Fn ( & S :: Timestamp , & D ) -> bool + ' static ,
34
- ) -> ( Stream < S , D > , Stream < S , D > ) ;
35
+ ) -> ( OwnedStream < S , Vec < D > > , OwnedStream < S , Vec < D > > ) ;
35
36
}
36
37
37
38
impl < S : Scope , D : Data > Branch < S , D > for Stream < S , D > {
38
39
fn branch (
39
40
self ,
40
41
condition : impl Fn ( & S :: Timestamp , & D ) -> bool + ' static ,
41
- ) -> ( Stream < S , D > , Stream < S , D > ) {
42
+ ) -> ( OwnedStream < S , Vec < D > > , OwnedStream < S , Vec < D > > ) {
42
43
let mut builder = OperatorBuilder :: new ( "Branch" . to_owned ( ) , self . scope ( ) ) ;
43
44
44
45
let mut input = builder. new_input ( self , Pipeline ) ;
@@ -71,7 +72,7 @@ impl<S: Scope, D: Data> Branch<S, D> for Stream<S, D> {
71
72
}
72
73
73
74
/// Extension trait for `Stream`.
74
- pub trait BranchWhen < T > : Sized {
75
+ pub trait BranchWhen < G : Scope , C : Container > : Sized {
75
76
/// Takes one input stream and splits it into two output streams.
76
77
/// For each time, the supplied closure is called. If it returns true,
77
78
/// the records for that will be sent to the second returned stream, otherwise
@@ -91,11 +92,11 @@ pub trait BranchWhen<T>: Sized {
91
92
/// after_five.inspect(|x| println!("Times 5 and later: {:?}", x));
92
93
/// });
93
94
/// ```
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 > ) ;
95
96
}
96
97
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 > ) {
99
100
let mut builder = OperatorBuilder :: new ( "Branch" . to_owned ( ) , self . scope ( ) ) ;
100
101
101
102
let mut input = builder. new_input ( self , Pipeline ) ;
0 commit comments