@@ -14,18 +14,19 @@ pub type TimelyProgressLogger = crate::logging_core::Logger<TimelyProgressEventB
1414use std:: time:: Duration ;
1515use columnar:: Columnar ;
1616use serde:: { Deserialize , Serialize } ;
17+
18+ use crate :: Container ;
1719use crate :: container:: CapacityContainerBuilder ;
1820use crate :: dataflow:: operators:: capture:: { Event , EventPusher } ;
1921
2022/// Logs events as a timely stream, with progress statements.
21- pub struct BatchLogger < T , P > where P : EventPusher < Duration , Vec < ( Duration , T ) > > {
22- // None when the logging stream is closed
23+ pub struct BatchLogger < P , C > where P : EventPusher < Duration , C > {
2324 time : Duration ,
2425 event_pusher : P ,
25- _phantom : :: std:: marker:: PhantomData < T > ,
26+ _phantom : :: std:: marker:: PhantomData < C > ,
2627}
2728
28- impl < T , P > BatchLogger < T , P > where P : EventPusher < Duration , Vec < ( Duration , T ) > > {
29+ impl < P , C > BatchLogger < P , C > where P : EventPusher < Duration , C > , C : Container {
2930 /// Creates a new batch logger.
3031 pub fn new ( event_pusher : P ) -> Self {
3132 BatchLogger {
@@ -35,8 +36,8 @@ impl<T, P> BatchLogger<T, P> where P: EventPusher<Duration, Vec<(Duration, T)>>
3536 }
3637 }
3738 /// Publishes a batch of logged events and advances the capability.
38- pub fn publish_batch ( & mut self , & time: & Duration , data : & mut Vec < ( Duration , T ) > ) {
39- if !data . is_empty ( ) {
39+ pub fn publish_batch ( & mut self , & time: & Duration , data : & mut Option < C > ) {
40+ if let Some ( data ) = data {
4041 self . event_pusher . push ( Event :: Messages ( self . time , std:: mem:: take ( data) ) ) ;
4142 }
4243 if self . time < time {
@@ -47,7 +48,7 @@ impl<T, P> BatchLogger<T, P> where P: EventPusher<Duration, Vec<(Duration, T)>>
4748 self . time = time;
4849 }
4950}
50- impl < T , P > Drop for BatchLogger < T , P > where P : EventPusher < Duration , Vec < ( Duration , T ) > > {
51+ impl < P , C > Drop for BatchLogger < P , C > where P : EventPusher < Duration , C > {
5152 fn drop ( & mut self ) {
5253 self . event_pusher . push ( Event :: Progress ( vec ! [ ( self . time, -1 ) ] ) ) ;
5354 }
0 commit comments