예제 #1
0
 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
예제 #2
0
 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
예제 #3
0
 def assign_windows(self, element: List,
                    timestamp: int) -> Iterable[TimeWindow]:
     return [TimeWindow(timestamp, timestamp + self._session_gap)]
예제 #4
0
 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
예제 #5
0
 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)
예제 #6
0
 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)
예제 #7
0
 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)]
예제 #8
0
 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))
예제 #9
0
 def decode_from_stream(self, stream, nested):
     start = stream.read_bigendian_int64()
     end = stream.read_bigendian_int64()
     return TimeWindow(start, end)
예제 #10
0
파일: test_coders.py 프로젝트: zzzppi/flink
 def test_window_coder(self):
     coder = TimeWindowCoder()
     self.check_coder(coder, TimeWindow(100, 1000))
     coder = CountWindowCoder()
     self.check_coder(coder, CountWindow(100))