@@ -178,25 +178,35 @@ def __init__(
178178 start_timestamp = Timestamp .now (),
179179 stop_timestamp = MAX_TIMESTAMP ,
180180 fire_interval = 360.0 ,
181- apply_windowing = False ):
181+ apply_windowing = False ,
182+ is_bounded = None ):
182183 '''
183184 :param start_timestamp: Timestamp for first element.
184185 :param stop_timestamp: Timestamp after which no elements will be output.
185186 :param fire_interval: Interval in seconds at which to output elements.
186187 :param apply_windowing: Whether each element should be assigned to
187188 individual window. If false, all elements will reside in global window.
189+ :param is_bounded: whether to treat the output PCollection as bounded.
190+ Defaults to True for small timestamp ranges and False for large ones.
188191 '''
189192 self .start_ts = start_timestamp
190193 self .stop_ts = stop_timestamp
191194 self .interval = fire_interval
192195 self .apply_windowing = apply_windowing
196+ self .is_bounded = (
197+ stop_timestamp - start_timestamp < 60
198+ if is_bounded is None else is_bounded )
193199
194200 def expand (self , pbegin ):
195- result = (
201+ sequence = (
196202 pbegin
197203 | 'ImpulseElement' >> beam .Create (
198204 [(self .start_ts , self .stop_ts , self .interval )])
199- | 'GenSequence' >> beam .ParDo (ImpulseSeqGenDoFn ())
205+ | 'GenSequence' >> beam .ParDo (ImpulseSeqGenDoFn ()))
206+ if self .is_bounded :
207+ sequence .is_bounded = True
208+ result = (
209+ sequence
200210 | 'MapToTimestamped' >> beam .Map (lambda tt : TimestampedValue (tt , tt )))
201211 if self .apply_windowing :
202212 result = result | 'ApplyWindowing' >> beam .WindowInto (
0 commit comments