We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 85246e5 commit a286f2fCopy full SHA for a286f2f
python/pyspark/serializers.py
@@ -412,15 +412,15 @@ class UTF8Deserializer(Serializer):
412
def __init__(self, use_unicode=False):
413
self.use_unicode = use_unicode
414
415
+ def loads(self, stream):
416
+ length = read_int(stream)
417
+ s = stream.read(length)
418
+ return s.decode("utf-8") if self.use_unicode else s
419
+
420
def load_stream(self, stream):
421
try:
- _read_int = read_int # faster than global lookup
- if self.use_unicode:
- while True:
- yield stream.read(_read_int(stream)).decode("utf-8")
- else:
422
423
- yield stream.read(_read_int(stream))
+ while True:
+ yield self.loads(stream)
424
except struct.error:
425
return
426
except EOFError:
0 commit comments