Example #1
0
 def assign_windows(self, element: List, timestamp: int) -> Iterable[CountWindow]:
     count_value = self._count.value()
     if count_value is None:
         current_count = 0
     else:
         current_count = count_value
     id = current_count // self._size
     self._count.update(current_count + 1)
     return [CountWindow(id)]
Example #2
0
 def assign_windows(self, element: List, timestamp: int) -> Iterable[W]:
     count_value = self._count.value()
     if count_value is None:
         current_count = 0
     else:
         current_count = count_value
     self._count.update(current_count + 1)
     last_id = current_count // self._slide
     last_start = last_id * self._slide
     last_end = last_start + self._size - 1
     windows = []
     while last_id >= 0 and last_start <= current_count <= last_end:
         if last_start <= current_count <= last_end:
             windows.append(CountWindow(last_id))
         last_id -= 1
         last_start -= self._slide
         last_end -= self._slide
     return windows
Example #3
0
 def test_window_coder(self):
     coder = TimeWindowCoder()
     self.check_coder(coder, TimeWindow(100, 1000))
     coder = CountWindowCoder()
     self.check_coder(coder, CountWindow(100))
Example #4
0
 def decode_from_stream(self, in_stream: InputStream, length=0):
     return CountWindow(in_stream.read_int64())
Example #5
0
 def test_cython_count_window_coder(self):
     fast_coder = coder_impl_fast.CountWindowCoderImpl()
     slow_coder = coder_impl.CountWindowCoderImpl()
     window = CountWindow(100)
     self.assertEqual(fast_coder.encode_nested(window),
                      slow_coder.encode_nested(window))
Example #6
0
 def decode_from_stream(self, stream, nested):
     id = stream.read_bigendian_int64()
     return CountWindow(id)