Esempio n. 1
0
    def open(self, runtime_context: RuntimeContext,
             internal_timer_service: InternalTimerService):
        self.window_function.open(runtime_context)

        self.num_late_records_dropped = runtime_context.get_metrics_group(
        ).counter(self.LATE_ELEMENTS_DROPPED_METRIC_NAME)
        self.internal_timer_service = internal_timer_service
        self.trigger_context = Context(runtime_context, internal_timer_service,
                                       self.trigger)
        self.process_context = WindowContext(self.window_assigner,
                                             runtime_context,
                                             self.window_function,
                                             self.internal_timer_service)
        self.window_assigner_context = WindowAssignerContext(
            self.internal_timer_service, runtime_context)

        # create (or restore) the state that hold the actual window contents
        # NOTE - the state may be null in the case of the overriding evicting window operator
        if self.window_state_descriptor is not None:
            self.window_state = get_or_create_keyed_state(
                runtime_context, self.window_state_descriptor)

        if isinstance(self.window_assigner, MergingWindowAssigner):
            if isinstance(self.window_state, InternalMergingState):
                self.window_merging_state = self.window_state

            window_coder = self.keyed_state_backend.namespace_coder
            self.merging_sets_state = self.keyed_state_backend.get_map_state(
                "merging-window-set", window_coder, window_coder)

        self.merge_function = WindowMergeFunction(self)
Esempio n. 2
0
    def open(self, runtime_context: RuntimeContext,
             internal_timer_service: InternalTimerService):
        self.window_function.open(runtime_context)

        self.num_late_records_dropped = runtime_context.get_metrics_group(
        ).counter(self.LATE_ELEMENTS_DROPPED_METRIC_NAME)
        self.internal_timer_service = internal_timer_service
        self.trigger_context = Context(runtime_context, internal_timer_service,
                                       self.trigger)
        self.process_context = WindowContext(self.window_assigner,
                                             runtime_context,
                                             self.window_function,
                                             self.internal_timer_service)
        self.window_assigner_context = WindowAssignerContext(
            self.internal_timer_service, runtime_context)

        # create (or restore) the state that hold the actual window contents
        # NOTE - the state may be null in the case of the overriding evicting window operator
        if self.window_state_descriptor is not None:
            self.window_state = get_or_create_keyed_state(
                runtime_context, self.window_state_descriptor)

        if isinstance(self.window_assigner, MergingWindowAssigner):
            if isinstance(self.window_state, InternalMergingState):
                self.window_merging_state = self.window_state

            # TODO: the type info is just a placeholder currently.
            # it should be the real type serializer after supporting the user-defined state type
            # serializer
            merging_sets_state_descriptor = ListStateDescriptor(
                "merging-window-set", Types.PICKLED_BYTE_ARRAY())

            self.merging_sets_state = get_or_create_keyed_state(
                runtime_context, merging_sets_state_descriptor)

        self.merge_function = WindowMergeFunction(self)