Github user srowen commented on a diff in the pull request:

    https://github.com/apache/spark/pull/12233#discussion_r58833142
  
    --- 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 --
    
    So this reads the data into memory and parallelize-s it straight away -- 
seems right to delete the file then, yes. LGTM


---
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]

Reply via email to