def _merge_window(cur_window: TimeWindow, other: TimeWindow, merged_windows: Set[TimeWindow]): if cur_window.intersects(other): merged_windows.add(other) return cur_window.cover(other) else: return cur_window
def assign_windows(self, element: List, timestamp: int) -> Iterable[TimeWindow]: last_start = TimeWindow.get_window_start_with_offset( timestamp, self._offset, self._slide) windows = [ TimeWindow(start, start + self._size) for start in range(last_start, timestamp - self._size, -self._slide) ] return windows
def assign_windows(self, element: List, timestamp: int) -> Iterable[TimeWindow]: return [TimeWindow(timestamp, timestamp + self._session_gap)]
def split_into_panes(self, window: W) -> Iterable[TimeWindow]: start = window.start for i in range(self._num_panes_per_window): yield TimeWindow(start, start + self._pane_size) start += self._pane_size
def get_last_window(self, pane: W) -> TimeWindow: last_start = TimeWindow.get_window_start_with_offset( pane.start, self._offset, self._slide) return TimeWindow(last_start, last_start + self._size)
def assign_pane(self, element, timestamp: int) -> TimeWindow: start = TimeWindow.get_window_start_with_offset( timestamp, self._offset, self._pane_size) return TimeWindow(start, start + self._pane_size)
def assign_windows(self, element: List, timestamp: int) -> Iterable[TimeWindow]: start = TimeWindow.get_window_start_with_offset( timestamp, self._offset, self._size) return [TimeWindow(start, start + self._size)]
def test_cython_time_window_coder(self): fast_coder = coder_impl_fast.TimeWindowCoderImpl() slow_coder = coder_impl.TimeWindowCoderImpl() window = TimeWindow(100, 200) self.assertEqual(fast_coder.encode_nested(window), slow_coder.encode_nested(window))
def decode_from_stream(self, stream, nested): start = stream.read_bigendian_int64() end = stream.read_bigendian_int64() return TimeWindow(start, end)
def test_window_coder(self): coder = TimeWindowCoder() self.check_coder(coder, TimeWindow(100, 1000)) coder = CountWindowCoder() self.check_coder(coder, CountWindow(100))