Skip to content

Commit

Permalink
add flush for ChunkedStream
Browse files Browse the repository at this point in the history
  • Loading branch information
WeichenXu123 committed May 29, 2019
1 parent 829ea96 commit 4d58419
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions python/pyspark/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -869,6 +869,14 @@ def write(self, bytes):
byte_pos = new_byte_pos
self.current_pos = 0

def flush(self):
if self.current_pos > 0:
# send buffer [0, current_pos)
write_int(self.current_pos, self.wrapped)
self.wrapped.write(self.buffer[:self.current_pos])
self.wrapped.flush()
self.current_pos = 0

def close(self):
# if there is anything left in the buffer, write it out first
if self.current_pos > 0:
Expand Down

0 comments on commit 4d58419

Please sign in to comment.