Skip to content
Branch: master
Find file History
2 authors and jiangxb1987 [SPARK-30667][CORE] Add all gather method to BarrierTaskContext
Fix for #27395

### What changes were proposed in this pull request?

The `allGather` method is added to the `BarrierTaskContext`. This method contains the same functionality as the `BarrierTaskContext.barrier` method; it blocks the task until all tasks make the call, at which time they may continue execution. In addition, the `allGather` method takes an input message. Upon returning from the `allGather` the task receives a list of all the messages sent by all the tasks that made the `allGather` call.

### Why are the changes needed?

There are many situations where having the tasks communicate in a synchronized way is useful. One simple example is if each task needs to start a server to serve requests from one another; first the tasks must find a free port (the result of which is undetermined beforehand) and then start making requests, but to do so they each must know the port chosen by the other task. An `allGather` method would allow them to inform each other of the port they will run on.

### Does this PR introduce any user-facing change?

Yes, an `BarrierTaskContext.allGather` method will be available through the Scala, Java, and Python APIs.

### How was this patch tested?

Most of the code path is already covered by tests to the `barrier` method, since this PR includes a refactor so that much code is shared by the `barrier` and `allGather` methods. However, a test is added to assert that an all gather on each tasks partition ID will return a list of every partition ID.

An example through the Python API:
```python
>>> from pyspark import BarrierTaskContext
>>>
>>> def f(iterator):
...     context = BarrierTaskContext.get()
...     return [context.allGather('{}'.format(context.partitionId()))]
...
>>> sc.parallelize(range(4), 4).barrier().mapPartitions(f).collect()[0]
[u'3', u'1', u'0', u'2']
```

Closes #27640 from sarthfrey/master.

Lead-authored-by: sarthfrey-db <sarth.frey@databricks.com>
Co-authored-by: sarthfrey <sarth.frey@gmail.com>
Signed-off-by: Xingbo Jiang <xingbo.jiang@databricks.com>
Latest commit 274b328 Feb 21, 2020

Files

Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
docs [SPARK-30880][DOCS] Delete Sphinx Makefile cruft Feb 21, 2020
lib [SPARK-30884][PYSPARK] Upgrade to Py4J 0.10.9 Feb 20, 2020
pyspark [SPARK-30667][CORE] Add all gather method to BarrierTaskContext Feb 21, 2020
test_coverage [SPARK-7721][PYTHON][TESTS] Adds PySpark coverage generation script Jan 22, 2018
test_support [SPARK-23094][SPARK-23723][SPARK-23724][SQL] Support custom encoding … Apr 29, 2018
.coveragerc [SPARK-7721][PYTHON][TESTS] Adds PySpark coverage generation script Jan 22, 2018
.gitignore [SPARK-3946] gitignore in /python includes wrong directory Oct 14, 2014
MANIFEST.in [SPARK-26803][PYTHON] Add sbin subdirectory to pyspark Feb 27, 2019
README.md [SPARK-30884][PYSPARK] Upgrade to Py4J 0.10.9 Feb 20, 2020
pylintrc [SPARK-13596][BUILD] Move misc top-level build files into appropriate… Mar 7, 2016
run-tests [SPARK-29672][PYSPARK] update spark testing framework to use python3 Nov 14, 2019
run-tests-with-coverage [SPARK-26252][PYTHON] Add support to run specific unittests and/or do… Dec 5, 2018
run-tests.py [SPARK-30480][PYTHON][TESTS] Increases the memory limit being tested … Jan 13, 2020
setup.cfg [SPARK-1267][SPARK-18129] Allow PySpark to be pip installed Nov 16, 2016
setup.py [SPARK-30884][PYSPARK] Upgrade to Py4J 0.10.9 Feb 20, 2020

README.md

Apache Spark

Spark is a unified analytics engine for large-scale data processing. It provides high-level APIs in Scala, Java, Python, and R, and an optimized engine that supports general computation graphs for data analysis. It also supports a rich set of higher-level tools including Spark SQL for SQL and DataFrames, MLlib for machine learning, GraphX for graph processing, and Structured Streaming for stream processing.

https://spark.apache.org/

Online Documentation

You can find the latest Spark documentation, including a programming guide, on the project web page

Python Packaging

This README file only contains basic information related to pip installed PySpark. This packaging is currently experimental and may change in future versions (although we will do our best to keep compatibility). Using PySpark requires the Spark JARs, and if you are building this from source please see the builder instructions at "Building Spark".

The Python packaging for Spark is not intended to replace all of the other use cases. This Python packaged version of Spark is suitable for interacting with an existing cluster (be it Spark standalone, YARN, or Mesos) - but does not contain the tools required to set up your own standalone Spark cluster. You can download the full version of Spark from the Apache Spark downloads page.

NOTE: If you are using this with a Spark standalone cluster you must ensure that the version (including minor version) matches or you may experience odd errors.

Python Requirements

At its core PySpark depends on Py4J, but some additional sub-packages have their own extra requirements for some features (including numpy, pandas, and pyarrow).

You can’t perform that action at this time.