Esempio n. 1
0
    def accept(self, value):
        input_type = value[0]
        normal_data = value[1]
        timestamp = value[2]
        watermark = value[3]
        timer_data = value[4]

        self.advance_watermark(watermark)
        if input_type == RunnerInputType.NORMAL_RECORD.value:
            yield from self.process_element(normal_data, timestamp)
        elif input_type == RunnerInputType.TRIGGER_TIMER.value:
            timer_type = timer_data[0]
            key = timer_data[1]
            serialized_namespace = timer_data[2]
            if self._namespace_coder is not None:
                namespace = self._namespace_coder.decode(serialized_namespace)
            else:
                namespace = None
            internal_timer = InternalTimerImpl(timestamp, key, namespace)
            if timer_type == TimerType.EVENT_TIME.value:
                yield from self.on_event_time(internal_timer)
            elif timer_type == TimerType.PROCESSING_TIME.value:
                yield from self.on_processing_time(internal_timer)
            else:
                raise Exception("Unsupported timer type: %d" % timer_type)
        else:
            raise Exception("Unsupported input type: %d" % input_type)
Esempio n. 2
0
 def process_element_or_timer(self, input_data: Tuple[int, Row, int, int, Row]):
     if input_data[0] == NORMAL_RECORD:
         self.group_agg_function.process_watermark(input_data[3])
         if has_cython:
             input_row = InternalRow.from_row(input_data[1])
         else:
             input_row = input_data[1]
         result_datas = self.group_agg_function.process_element(input_row)
         for result_data in result_datas:
             yield [NORMAL_RECORD, result_data, None]
         timers = self.group_agg_function.get_timers()
         for timer in timers:
             timer_operand_type = timer[0]  # type: TimerOperandType
             internal_timer = timer[1]  # type: InternalTimer
             window = internal_timer.get_namespace()
             self._reuse_key_data._values = internal_timer.get_key()
             timestamp = internal_timer.get_timestamp()
             encoded_window = self._namespace_coder.encode(window)
             self._reuse_timer_data._values = \
                 [timer_operand_type.value, self._reuse_key_data, timestamp, encoded_window]
             yield [TRIGGER_TIMER, None, self._reuse_timer_data]
     else:
         timestamp = input_data[2]
         timer_data = input_data[4]
         key = list(timer_data[1])
         timer_type = timer_data[0]
         namespace = self._namespace_coder.decode(timer_data[2])
         timer = InternalTimerImpl(timestamp, key, namespace)
         if timer_type == REGISTER_EVENT_TIMER:
             result_datas = self.group_agg_function.on_event_time(timer)
         else:
             result_datas = self.group_agg_function.on_processing_time(timer)
         for result_data in result_datas:
             yield [NORMAL_RECORD, result_data, None]
Esempio n. 3
0
 def on_processing_time(internal_timer: InternalTimerImpl):
     keyed_state_backend.set_current_key(internal_timer.get_key())
     return window_operator.on_processing_time(internal_timer)
Esempio n. 4
0
 def on_processing_time(internal_timer: InternalTimerImpl):
     keyed_state_backend.set_current_key(internal_timer.get_key())
     return on_timer(TimeDomain.PROCESSING_TIME, internal_timer)
Esempio n. 5
0
 def on_event_time(internal_timer: InternalTimerImpl):
     keyed_state_backend.set_current_key(internal_timer.get_key())
     return on_timer(TimeDomain.EVENT_TIME, internal_timer)