def test_timer_coder(self): self.check_coder(coders._TimerCoder(coders.BytesCoder()), *[{'timestamp': timestamp.Timestamp(micros=x), 'payload': b'xyz'} for x in range(-3, 3)]) self.check_coder( coders.TupleCoder((coders._TimerCoder(coders.VarIntCoder()),)), ({'timestamp': timestamp.Timestamp.of(37), 'payload': 389},))
def test_timer_coder(self): self.check_coder(coders._TimerCoder(coders.BytesCoder()), *[{'timestamp': timestamp.Timestamp(micros=x), 'payload': b'xyz'} for x in (-3000, 0, 3000)]) self.check_coder( coders.TupleCoder((coders._TimerCoder(coders.VarIntCoder()),)), ({'timestamp': timestamp.Timestamp.of(37000), 'payload': 389},))
def to_runner_api(self, context): # type: (PipelineContext) -> beam_runner_api_pb2.TimerFamilySpec return beam_runner_api_pb2.TimerFamilySpec( time_domain=TimeDomain.to_runner_api(self.time_domain), timer_family_coder_id=context.coders.get_id( coders._TimerCoder(coders.StrUtf8Coder(), coders.GlobalWindowCoder())))
def test_timer_coder(self): self.check_coder( coders._TimerCoder(coders.StrUtf8Coder(), coders.GlobalWindowCoder()), *[ userstate.Timer(user_key="key", dynamic_timer_tag="tag", windows=(GlobalWindow(), ), clear_bit=True, fire_timestamp=None, hold_timestamp=None, paneinfo=None), userstate.Timer(user_key="key", dynamic_timer_tag="tag", windows=(GlobalWindow(), ), clear_bit=False, fire_timestamp=timestamp.Timestamp.of(123), hold_timestamp=timestamp.Timestamp.of(456), paneinfo=windowed_value.PANE_INFO_UNKNOWN) ])
def to_runner_api(self, context): # type: (PipelineContext) -> beam_runner_api_pb2.TimerSpec return beam_runner_api_pb2.TimerSpec( time_domain=TimeDomain.to_runner_api(self.time_domain), timer_coder_id=context.coders.get_id( coders._TimerCoder(coders.SingletonCoder(None))))
def to_runner_api(self, context, key_coder, window_coder): return beam_runner_api_pb2.TimerFamilySpec( time_domain=TimeDomain.to_runner_api(self.time_domain), timer_family_coder_id=context.coders.get_id( coders._TimerCoder(key_coder, window_coder)))
def to_runner_api(self, context): return beam_runner_api_pb2.TimerFamilySpec( time_domain=TimeDomain.to_runner_api(self.time_domain), timer_family_coder_id=context.coders.get_id( coders._TimerCoder(coders.SingletonCoder(None))))
def to_runner_api(self, context): return beam_runner_api_pb2.TimerSpec( time_domain=TimeDomain.to_runner_api(self.time_domain), timer_coder_id=context.coders.get_id( coders._TimerCoder(coders.SingletonCoder(None))))