[ Web Proxy ]
URL:
Viewing: https://spark.apache.org/docs/latest/api/python/reference/api/../api/pyspark.RDD.treeReduce.html [Back]  [Original]

pyspark.RDD.treeReduce — PySpark 4.2.0 documentation Skip to main content
Search the docs ...:

pyspark.RDD.treeReduce#

RDD.treeReduce(f, depth=2)[source]#

Reduces the elements of this RDD in a multi-level tree pattern.

New in version 1.3.0.

Parameters
ffunction

the reduce function

depthint, optional, default 2

suggested depth of the tree (default: 2)

Returns
T

the aggregated result

Examples

>>> add = lambda x, y: x + y
>>> rdd = sc.parallelize([-5, -4, -3, -2, -1, 1, 2, 3, 4], 10)
>>> rdd.treeReduce(add)
-5
>>> rdd.treeReduce(add, 1)
-5
>>> rdd.treeReduce(add, 2)
-5
>>> rdd.treeReduce(add, 5)
-5
>>> rdd.treeReduce(add, 10)
-5

Web Proxy Viewer  |  New URL  |  Original Page