Exemple #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
Exemple #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
Exemple #3
0
 def assign_windows(self, element: List,
                    timestamp: int) -> Iterable[TimeWindow]:
     return [TimeWindow(timestamp, timestamp + self._session_gap)]
Exemple #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
Exemple #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)
Exemple #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)
Exemple #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)]
Exemple #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))
Exemple #9
0
 def decode_from_stream(self, stream, nested):
     start = stream.read_bigendian_int64()
     end = stream.read_bigendian_int64()
     return TimeWindow(start, end)
Exemple #10
0
 def test_window_coder(self):
     coder = TimeWindowCoder()
     self.check_coder(coder, TimeWindow(100, 1000))
     coder = CountWindowCoder()
     self.check_coder(coder, CountWindow(100))