Esempio n. 1
0
    def using(self, operator):
        """
        Finalizes a CoGroup transformation.

        Applies a CoGroupFunction to groups of elements with identical keys.
        Each CoGroupFunction call returns an arbitrary number of keys.

        :param operator: The CoGroupFunction that is called for all groups of elements with identical keys.
        :return:An CoGroupOperator that represents the co-grouped result DataSet.
        """
        if isinstance(operator, TYPES.FunctionType):
            f = operator
            operator = CoGroupFunction()
            operator.co_group = f
        new_set = OperatorSet(self._env, self._info)
        self._info.key1 = tuple([x for x in range(len(self._info.key1))])
        self._info.key2 = tuple([x for x in range(len(self._info.key2))])
        operator._keys1 = self._info.key1
        operator._keys2 = self._info.key2
        self._info.parent.parallelism = self._info.parallelism
        self._info.other.parallelism = self._info.parallelism
        self._info.operator = operator
        self._info.types = _createArrayTypeInfo()
        self._info.name = "PythonCoGroup"
        self._env._sets.append(self._info)
        return new_set
Esempio n. 2
0
    def using(self, operator, types):
        """
        Finalizes a CoGroup transformation.

        Applies a CoGroupFunction to groups of elements with identical keys.
        Each CoGroupFunction call returns an arbitrary number of keys.

        :param operator: The CoGroupFunction that is called for all groups of elements with identical keys.
        :param types: The type of the resulting DataSet.
        :return:An CoGroupOperator that represents the co-grouped result DataSet.
        """
        if isinstance(operator, TYPES.FunctionType):
            f = operator
            operator = CoGroupFunction()
            operator.co_group = f
        new_set = OperatorSet(self._env, self._info)
        operator._keys1 = self._info.key1
        operator._keys2 = self._info.key2
        self._info.operator = operator
        self._info.meta = str(inspect.getmodule(operator)) + "|" + str(
            operator.__class__.__name__)
        self._info.types = types
        self._info.name = "PythonCoGroup"
        self._env._sets.append(self._info)
        return new_set