Github user holdenk commented on a diff in the pull request:
https://github.com/apache/spark/pull/12233#discussion_r58922550
--- Diff: python/pyspark/context.py ---
@@ -428,15 +428,19 @@ def f(split, iterator):
# because it sends O(n) Py4J commands. As an alternative,
serialized
# objects are written to a file and loaded through textFile().
tempFile = NamedTemporaryFile(delete=False, dir=self._temp_dir)
- # Make sure we distribute data evenly if it's smaller than
self.batchSize
- if "__len__" not in dir(c):
- c = list(c) # Make it a list so we can compute its length
- batchSize = max(1, min(len(c) // numSlices, self._batchSize or
1024))
- serializer = BatchedSerializer(self._unbatched_serializer,
batchSize)
- serializer.dump_stream(c, tempFile)
- tempFile.close()
- readRDDFromFile = self._jvm.PythonRDD.readRDDFromFile
- jrdd = readRDDFromFile(self._jsc, tempFile.name, numSlices)
+ try:
+ # Make sure we distribute data evenly if it's smaller than
self.batchSize
+ if "__len__" not in dir(c):
+ c = list(c) # Make it a list so we can compute its
length
+ batchSize = max(1, min(len(c) // numSlices, self._batchSize or
1024))
+ serializer = BatchedSerializer(self._unbatched_serializer,
batchSize)
+ serializer.dump_stream(c, tempFile)
+ tempFile.close()
+ readRDDFromFile = self._jvm.PythonRDD.readRDDFromFile
+ jrdd = readRDDFromFile(self._jsc, tempFile.name, numSlices)
--- End diff --
Right on the Java side it is read immediately into memory and parallelized
right away.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]