Esempio n. 1
0
    def reduce(self, operator):
        """
        Applies a Reduce transformation on a non-grouped DataSet.

        The transformation consecutively calls a ReduceFunction until only a single element remains which is the result
        of the transformation. A ReduceFunction combines two elements into one new element of the same type.

        :param operator:The ReduceFunction that is applied on the DataSet.
        :return:A ReduceOperator that represents the reduced DataSet.
        """
        self._finalize()
        if isinstance(operator, TYPES.FunctionType):
            f = operator
            operator = ReduceFunction()
            operator.reduce = f
        child = OperationInfo()
        child_set = OperatorSet(self._env, child)
        child.identifier = _Identifier.REDUCE
        child.parent = self._info
        child.operator = operator
        child.name = "PythonReduce"
        child.types = _createArrayTypeInfo()
        child.key1 = self._child_chain[0].keys
        self._info.parallelism = child.parallelism
        self._info.children.append(child)
        self._env._sets.append(child)

        return child_set
Esempio n. 2
0
    def reduce(self, operator):
        """
        Applies a Reduce transformation on a non-grouped DataSet.

        The transformation consecutively calls a ReduceFunction until only a single element remains which is the result
        of the transformation. A ReduceFunction combines two elements into one new element of the same type.

        :param operator:The ReduceFunction that is applied on the DataSet.
        :return:A ReduceOperator that represents the reduced DataSet.
        """
        self._finalize()
        if isinstance(operator, TYPES.FunctionType):
            f = operator
            operator = ReduceFunction()
            operator.reduce = f
        child = OperationInfo()
        child_set = OperatorSet(self._env, child)
        child.identifier = _Identifier.REDUCE
        child.parent = self._info
        child.operator = operator
        child.name = "PythonReduce"
        child.types = _createArrayTypeInfo()
        child.key1 = self._child_chain[0].keys
        self._info.parallelism = child.parallelism
        self._info.children.append(child)
        self._env._sets.append(child)

        return child_set
Esempio n. 3
0
    def reduce(self, operator):
        """
        Applies a Reduce transformation on a non-grouped DataSet.

        The transformation consecutively calls a ReduceFunction until only a single element remains which is the result
        of the transformation. A ReduceFunction combines two elements into one new element of the same type.

        :param operator:The ReduceFunction that is applied on the DataSet.
        :return:A ReduceOperator that represents the reduced DataSet.
        """
        if isinstance(operator, TYPES.FunctionType):
            f = operator
            operator = ReduceFunction()
            operator.reduce = f
        child = dict()
        child_set = OperatorSet(self._env, child)
        child[_Fields.IDENTIFIER] = _Identifier.REDUCE
        child[_Fields.PARENT] = self._info
        child[_Fields.OPERATOR] = operator
        child[_Fields.COMBINEOP] = operator
        child[_Fields.COMBINE] = False
        child[_Fields.META] = str(inspect.getmodule(operator)) + "|" + str(operator.__class__.__name__)
        child[_Fields.NAME] = "PythonReduce"
        child[_Fields.TYPES] = deduct_output_type(self._info)
        self._info[_Fields.CHILDREN].append(child)
        self._env._sets.append(child)
        return child_set
Esempio n. 4
0
    def reduce(self, operator):
        """
        Applies a Reduce transformation on a non-grouped DataSet.

        The transformation consecutively calls a ReduceFunction until only a single element remains which is the result
        of the transformation. A ReduceFunction combines two elements into one new element of the same type.

        :param operator:The ReduceFunction that is applied on the DataSet.
        :return:A ReduceOperator that represents the reduced DataSet.
        """
        if isinstance(operator, TYPES.FunctionType):
            f = operator
            operator = ReduceFunction()
            operator.reduce = f
        child = OperationInfo()
        child_set = OperatorSet(self._env, child)
        child.identifier = _Identifier.REDUCE
        child.parent = self._info
        child.operator = operator
        child.combineop = operator
        child.combine = False
        child.meta = str(inspect.getmodule(operator)) + "|" + str(
            operator.__class__.__name__)
        child.name = "PythonReduce"
        child.types = deduct_output_type(self._info)
        self._info.children.append(child)
        self._env._sets.append(child)
        return child_set
Esempio n. 5
0
    def reduce(self, operator):
        """
        Applies a Reduce transformation on a non-grouped DataSet.

        The transformation consecutively calls a ReduceFunction until only a single element remains which is the result
        of the transformation. A ReduceFunction combines two elements into one new element of the same type.

        :param operator:The ReduceFunction that is applied on the DataSet.
        :return:A ReduceOperator that represents the reduced DataSet.
        """
        if isinstance(operator, TYPES.FunctionType):
            f = operator
            operator = ReduceFunction()
            operator.reduce = f
        child = dict()
        child_set = OperatorSet(self._env, child)
        child[_Fields.IDENTIFIER] = _Identifier.REDUCE
        child[_Fields.PARENT] = self._info
        child[_Fields.OPERATOR] = operator
        child[_Fields.COMBINEOP] = operator
        child[_Fields.COMBINE] = False
        child[_Fields.META] = str(inspect.getmodule(operator)) + "|" + str(
            operator.__class__.__name__)
        child[_Fields.NAME] = "PythonReduce"
        child[_Fields.TYPES] = deduct_output_type(self._info)
        self._info[_Fields.CHILDREN].append(child)
        self._env._sets.append(child)
        return child_set
Esempio n. 6
0
    def reduce(self, operator):
        """
        Applies a Reduce transformation on a non-grouped DataSet.

        The transformation consecutively calls a ReduceFunction until only a single element remains which is the result
        of the transformation. A ReduceFunction combines two elements into one new element of the same type.

        :param operator:The ReduceFunction that is applied on the DataSet.
        :return:A ReduceOperator that represents the reduced DataSet.
        """
        if isinstance(operator, TYPES.FunctionType):
            f = operator
            operator = ReduceFunction()
            operator.reduce = f
        child = OperationInfo()
        child_set = OperatorSet(self._env, child)
        child.identifier = _Identifier.REDUCE
        child.parent = self._info
        child.operator = operator
        child.combineop = operator
        child.combine = False
        child.meta = str(inspect.getmodule(operator)) + "|" + str(operator.__class__.__name__)
        child.name = "PythonReduce"
        child.types = deduct_output_type(self._info)
        self._info.children.append(child)
        self._env._sets.append(child)
        return child_set