def run_trigger(self, window_fn, trigger_fn, accumulation_mode, bundles, late_bundles, expected_panes): actual_panes = collections.defaultdict(list) driver = GeneralTriggerDriver( Windowing(window_fn, trigger_fn, accumulation_mode)) state = InMemoryUnmergedState() for bundle in bundles: for wvalue in driver.process_elements(state, bundle, MIN_TIMESTAMP): window, = wvalue.windows actual_panes[window].append(set(wvalue.value)) while state.timers: for timer_window, (name, time_domain, timestamp) in ( state.get_and_clear_timers()): for wvalue in driver.process_timer( timer_window, name, time_domain, timestamp, state): window, = wvalue.windows actual_panes[window].append(set(wvalue.value)) for bundle in late_bundles: for wvalue in driver.process_elements(state, bundle, MIN_TIMESTAMP): window, = wvalue.windows actual_panes[window].append(set(wvalue.value)) while state.timers: for timer_window, (name, time_domain, timestamp) in ( state.get_and_clear_timers()): for wvalue in driver.process_timer( timer_window, name, time_domain, timestamp, state): window, = wvalue.windows actual_panes[window].append(set(wvalue.value)) self.assertEqual(expected_panes, actual_panes)
def run_trigger(self, window_fn, trigger_fn, accumulation_mode, bundles, late_bundles, expected_panes): actual_panes = collections.defaultdict(list) driver = GeneralTriggerDriver( Windowing(window_fn, trigger_fn, accumulation_mode)) state = InMemoryUnmergedState() for bundle in bundles: for wvalue in driver.process_elements(state, bundle, MIN_TIMESTAMP): window, = wvalue.windows actual_panes[window].append(set(wvalue.value)) while state.timers: for timer_window, (name, time_domain, timestamp) in ( state.get_and_clear_timers()): for wvalue in driver.process_timer( timer_window, name, time_domain, timestamp, state): window, = wvalue.windows actual_panes[window].append(set(wvalue.value)) for bundle in late_bundles: for wvalue in driver.process_elements(state, bundle, MIN_TIMESTAMP): window, = wvalue.windows actual_panes[window].append(set(wvalue.value)) while state.timers: for timer_window, (name, time_domain, timestamp) in ( state.get_and_clear_timers()): for wvalue in driver.process_timer( timer_window, name, time_domain, timestamp, state): window, = wvalue.windows actual_panes[window].append(set(wvalue.value)) self.assertEqual(expected_panes, actual_panes)
def run_trigger(self, window_fn, trigger_fn, accumulation_mode, bundles, late_bundles, expected_panes): actual_panes = collections.defaultdict(list) allowed_lateness = Duration( micros=int(common_urns.constants.MAX_TIMESTAMP_MILLIS.constant) * 1000) driver = GeneralTriggerDriver( Windowing(window_fn, trigger_fn, accumulation_mode, allowed_lateness=allowed_lateness), TestClock()) state = InMemoryUnmergedState() for bundle in bundles: for wvalue in driver.process_elements(state, bundle, MIN_TIMESTAMP, MIN_TIMESTAMP): window, = wvalue.windows self.assertEqual(window.max_timestamp(), wvalue.timestamp) actual_panes[window].append(set(wvalue.value)) while state.timers: for timer_window, (name, time_domain, timestamp) in (state.get_and_clear_timers()): for wvalue in driver.process_timer(timer_window, name, time_domain, timestamp, state, MIN_TIMESTAMP): window, = wvalue.windows self.assertEqual(window.max_timestamp(), wvalue.timestamp) actual_panes[window].append(set(wvalue.value)) for bundle in late_bundles: for wvalue in driver.process_elements(state, bundle, MAX_TIMESTAMP, MAX_TIMESTAMP): window, = wvalue.windows self.assertEqual(window.max_timestamp(), wvalue.timestamp) actual_panes[window].append(set(wvalue.value)) while state.timers: for timer_window, (name, time_domain, timestamp) in ( state.get_and_clear_timers()): for wvalue in driver.process_timer(timer_window, name, time_domain, timestamp, state, MAX_TIMESTAMP): window, = wvalue.windows self.assertEqual(window.max_timestamp(), wvalue.timestamp) actual_panes[window].append(set(wvalue.value)) self.assertEqual(expected_panes, actual_panes)