def inner_join_and_emit(self, key, values, window_config): for left_val in values[0]: for right_val in values[1]: result = self._join_function(left_val, right_val) keyedwindow = KeyedWindow( key, Window(window_config.start, window_config.end)) self.emit([(keyedwindow, result)], stream='output')
def processWindow(self, window_config, tuples): result = None for tup in tuples: userdata = tup.values[0] result = self.reduce_function(result, userdata) self.emit([(Window(window_config.start, window_config.end), result)], stream='output')
def processWindow(self, window_config, tuples): # our temporary map mymap = {} for tup in tuples: userdata = tup.values[0] if not isinstance(userdata, collections.Iterable) or len(userdata) != 2: raise RuntimeError("ReduceByWindow tuples must be iterable of length 2") self._add(userdata[0], userdata[1], mymap) for (key, values) in mymap.items(): result = values[0] for value in values[1:]: result = self.reduce_function(result, value) keyedwindow = KeyedWindow(key, Window(window_config.start, window_config.end)) self.emit([(keyedwindow, result)], stream='output')
def emit_join(self, key, values, window_config): result = self._join_function(values[0], values[1]) keyedwindow = KeyedWindow( key, Window(window_config.start, window_config.end)) self.emit([(keyedwindow, result)], stream='output')