Beispiel #1
0
 def test_window_observing_split_on_middle_window(self):
     restriction_tracker = OffsetRestrictionTracker(self.restriction)
     restriction_tracker.try_claim(30)
     (primaries, residuals, stop_index) = PerWindowInvoker._try_split(
         0.2, 1, 3, self.windowed_value, self.restriction,
         self.watermark_estimator_state, self.restriction_provider,
         restriction_tracker, self.watermark_estimator)
     # 20% of 1.7 windows = 20% of 170 offset left = 34 offset
     # 30 + 34 = 64 split offset
     expected_primary_split, expected_residual_split = (
         self.create_split_in_window(64, (self.window2, )))
     expected_primary_windows, expected_residual_windows = (
         self.create_split_across_windows((self.window1, ),
                                          (self.window3, )))
     hc.assert_that(
         primaries,
         hc.contains_inanyorder(
             expected_primary_split,
             expected_primary_windows,
         ))
     hc.assert_that(
         residuals,
         hc.contains_inanyorder(
             expected_residual_split,
             expected_residual_windows,
         ))
     self.assertEqual(stop_index, 2)
Beispiel #2
0
 def test_window_observing_checkpoint_on_first_window_after_prior_split(
         self):
     restriction_tracker = OffsetRestrictionTracker(self.restriction)
     restriction_tracker.try_claim(30)
     (primaries, residuals, stop_index) = PerWindowInvoker._try_split(
         0.0,
         0,
         2,  # stop index < len(windows) representing a prior split had occurred
         self.windowed_value,
         self.restriction,
         self.watermark_estimator_state,
         self.restriction_provider,
         restriction_tracker,
         self.watermark_estimator)
     expected_primary_split, expected_residual_split = (
         self.create_split_in_window(31, (self.window1, )))
     _, expected_residual_windows = (self.create_split_across_windows(
         None, (self.window2, )))
     hc.assert_that(primaries,
                    hc.contains_inanyorder(expected_primary_split))
     hc.assert_that(
         residuals,
         hc.contains_inanyorder(
             expected_residual_split,
             expected_residual_windows,
         ))
     self.assertEqual(stop_index, 1)
Beispiel #3
0
 def test_non_window_observing_split_when_restriction_is_done(self):
     restriction_tracker = OffsetRestrictionTracker(self.restriction)
     restriction_tracker.try_claim(100)
     self.assertIsNone(
         PerWindowInvoker._try_split(0.1, None, None, self.windowed_value,
                                     self.restriction,
                                     self.watermark_estimator_state,
                                     self.restriction_provider,
                                     restriction_tracker,
                                     self.watermark_estimator))
Beispiel #4
0
 def test_window_observing_split_on_last_window_when_split_not_possible(
         self):
     restriction_tracker = OffsetRestrictionTracker(self.restriction)
     restriction_tracker.try_claim(100)
     # We assume that we can't split this fully claimed restriction
     self.assertIsNone(restriction_tracker.try_split(0))
     self.assertIsNone(
         PerWindowInvoker._try_split(0.0, 2, 3, self.windowed_value,
                                     self.restriction,
                                     self.watermark_estimator_state,
                                     self.restriction_provider,
                                     restriction_tracker,
                                     self.watermark_estimator))
Beispiel #5
0
 def test_non_window_observing_split(self):
     restriction_tracker = OffsetRestrictionTracker(self.restriction)
     restriction_tracker.try_claim(30)
     (primaries, residuals, stop_index) = PerWindowInvoker._try_split(
         0.1, None, None, self.windowed_value, self.restriction,
         self.watermark_estimator_state, self.restriction_provider,
         restriction_tracker, self.watermark_estimator)
     expected_primary_split, expected_residual_split = (
         self.create_split_in_window(37, self.windowed_value.windows))
     self.assertEqual([expected_primary_split], primaries)
     self.assertEqual([expected_residual_split], residuals)
     # We don't expect the stop index to be set for non window observing splits
     self.assertIsNone(stop_index)
Beispiel #6
0
 def test_window_observing_split_on_window_boundary_round_down(self):
     restriction_tracker = OffsetRestrictionTracker(self.restriction)
     restriction_tracker.try_claim(30)
     (primaries, residuals, stop_index) = PerWindowInvoker._try_split(
         0.3, 0, 3, self.windowed_value, self.restriction,
         self.watermark_estimator_state, self.restriction_provider,
         restriction_tracker, self.watermark_estimator)
     # 30% of 2.7 windows = 30% of 270 offset left = 81 offset
     # 30 + 81 = 111 offset --> round to end of window 1
     expected_primary_windows, expected_residual_windows = (
         self.create_split_across_windows((self.window1, ), (
             self.window2,
             self.window3,
         )))
     hc.assert_that(primaries,
                    hc.contains_inanyorder(expected_primary_windows, ))
     hc.assert_that(residuals,
                    hc.contains_inanyorder(expected_residual_windows, ))
     self.assertEqual(stop_index, 1)
Beispiel #7
0
 def test_window_observing_split_on_middle_window_fallback(self):
     restriction_tracker = OffsetRestrictionTracker(self.restriction)
     restriction_tracker.try_claim(100)
     # We assume that we can't split this fully claimed restriction
     self.assertIsNone(restriction_tracker.try_split(0))
     (primaries, residuals, stop_index) = PerWindowInvoker._try_split(
         0.0, 1, 3, self.windowed_value, self.restriction,
         self.watermark_estimator_state, self.restriction_provider,
         restriction_tracker, self.watermark_estimator)
     expected_primary_windows, expected_residual_windows = (
         self.create_split_across_windows((
             self.window1,
             self.window2,
         ), (self.window3, )))
     hc.assert_that(primaries,
                    hc.contains_inanyorder(expected_primary_windows, ))
     hc.assert_that(residuals,
                    hc.contains_inanyorder(expected_residual_windows, ))
     self.assertEqual(stop_index, 2)
Beispiel #8
0
 def test_window_observing_split_on_window_boundary_round_down_on_last_window(
         self):
     restriction_tracker = OffsetRestrictionTracker(self.restriction)
     restriction_tracker.try_claim(30)
     (primaries, residuals, stop_index) = PerWindowInvoker._try_split(
         0.9, 0, 3, self.windowed_value, self.restriction,
         self.watermark_estimator_state, self.restriction_provider,
         restriction_tracker, self.watermark_estimator)
     # 90% of 2.7 windows = 90% of 270 offset left = 243 offset
     # 30 + 243 = 273 offset --> prefer a split so round to end of window 2
     # instead of no split
     expected_primary_windows, expected_residual_windows = (
         self.create_split_across_windows((
             self.window1,
             self.window2,
         ), (self.window3, )))
     hc.assert_that(primaries,
                    hc.contains_inanyorder(expected_primary_windows, ))
     hc.assert_that(residuals,
                    hc.contains_inanyorder(expected_residual_windows, ))
     self.assertEqual(stop_index, 2)