sarthfrey opened a new pull request #27395: [SPARK-30667][CORE] Add allGather 
method to BarrierTaskContext
URL: https://github.com/apache/spark/pull/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']
   ```
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to