Пример #1
0
 def test_param_construction(self):
     with self.assertRaises(ValueError):
         DoFn.StateParam(TimerSpec('timer', TimeDomain.WATERMARK))
     with self.assertRaises(ValueError):
         DoFn.TimerParam(BagStateSpec('elements', BytesCoder()))
Пример #2
0
 def expiry_callback(self,
                     buffer=DoFn.StateParam(BUFFER_STATE),
                     timer=DoFn.TimerParam(EXPIRY_TIMER)):
     yield ''.join(str(x) for x in sorted(buffer.read()))
Пример #3
0
 def on_expiry_3(self,
                 buffer_1=DoFn.StateParam(BUFFER_STATE_1),
                 buffer_2=DoFn.StateParam(BUFFER_STATE_2),
                 timer_3=DoFn.TimerParam(EXPIRY_TIMER_3)):
     yield 'expired3'
Пример #4
0
 def process(self,
             element,
             last_element=DoFn.StateParam(VALUE_STATE)):
     last_element.write('%s:%s' % element)
     yield last_element.read()
Пример #5
0
 def expiry_callback(self, buffer=DoFn.StateParam(BUFFER_STATE)):
     yield sorted(buffer.read())
Пример #6
0
 def expiry_callback(self,
                     element,
                     b1=DoFn.StateParam(BUFFER_STATE),
                     b2=DoFn.StateParam(BUFFER_STATE)):
     yield element
Пример #7
0
 def on_expiry_2(self, buffer_state=DoFn.StateParam(BUFFER_STATE)):
     yield 'expired2'
Пример #8
0
 def process(self,
             element,
             buffer=DoFn.StateParam(BUFFER_STATE),
             timer1=DoFn.TimerParam(EXPIRY_TIMER),
             dynamic_timer=DoFn.TimerParam(EXPIRY_TIMER_FAMILY)):
     yield element
Пример #9
0
 def process(self,
             element,
             b1=DoFn.StateParam(BUFFER_STATE),
             b2=DoFn.StateParam(BUFFER_STATE)):
     yield element
Пример #10
0
 def process(self, element, state=DoFn.StateParam(INDEX_STATE)):
     unused_key, value = element
     current_index = state.read()
     yield (value, current_index)
     state.add(1)
Пример #11
0
 def expiry_callback(self, state=DoFn.StateParam(BUFFER_STATE)):
     buffered = list(state.read())
     assert len(buffered) == 1, buffered
     state.clear()
     yield b'Unmatched<%s>' % (buffered[0], )
Пример #12
0
 def on_window_timer(self,
                     element_state=DoFn.StateParam(ELEMENT_STATE),
                     count_state=DoFn.StateParam(COUNT_STATE),
                     buffering_timer=DoFn.TimerParam(BUFFERING_TIMER)):
     return self.flush_batch(element_state, count_state,
                             buffering_timer)
Пример #13
0
 def on_expiry_1(self, buffer_state=DoFn.StateParam(BUFFER_STATE)):  # pylint: disable=function-redefined
     yield 'expired2'
Пример #14
0
 def process(self, element, state=DoFn.StateParam(INDEX_STATE)):
   unused_key, value = element
   next_index, = list(state.read()) or [0]
   yield (value, next_index)
   state.clear()
   state.add(next_index + 1)
Пример #15
0
 def process(self, element, t=DoFn.TimestampParam,
             buffer_1=DoFn.StateParam(BUFFER_STATE_1),
             buffer_2=DoFn.StateParam(BUFFER_STATE_2),
             timer_1=DoFn.TimerParam(EXPIRY_TIMER_1),
             timer_2=DoFn.TimerParam(EXPIRY_TIMER_2)):
   yield element
Пример #16
0
 def process(self, element, buffer=DoFn.StateParam(BUFFER_STATE),
             timer1=DoFn.TimerParam(EXPIRY_TIMER)):
   unused_key, value = element
   buffer.add(value)
   timer1.set(20)