GitHub user HyukjinKwon opened a pull request:
https://github.com/apache/spark/pull/17282
[SPARK-19872][PYTHON] Only reseralize BatchedSerializers when repartitioning
## What changes were proposed in this pull request?
This PR proposes to avoid serialization for non-batched ones. It seems
`UTF8Deserializer` can't be replaced with `BatchedSerializer`.
with the file, `text.txt` below:
```
a
b
d
e
f
g
h
i
j
k
l
```
- Before
```python
>>> sc.textFile('text.txt').repartition(1).collect()
```
```
UTF8Deserializer(True)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File ".../spark/python/pyspark/rdd.py", line 811, in collect
return list(_load_from_socket(port, self._jrdd_deserializer))
File ".../spark/python/pyspark/serializers.py", line 549, in load_stream
yield self.loads(stream)
File ".../spark/python/pyspark/serializers.py", line 544, in loads
return s.decode("utf-8") if self.use_unicode else s
File
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/encodings/utf_8.py",
line 16, in decode
return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode byte 0x80 in position 0:
invalid start byte
```
- After
```python
>>> sc.textFile('text.txt').repartition(1).collect()
```
```
[u'a', u'b', u'', u'd', u'e', u'f', u'g', u'h', u'i', u'j', u'k', u'l', u'']
```
## How was this patch tested?
Unit test in `python/pyspark/tests.py`.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/HyukjinKwon/spark SPARK-19872
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/spark/pull/17282.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #17282
----
commit 30688db6520846ac561d117a3af31c947b33a498
Author: hyukjinkwon <[email protected]>
Date: 2017-03-13T18:27:06Z
Do not use batch when it is not needed
----
---
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]