Skip to content

Commit

Permalink
[BEAM-1251] Upgrade from buffer to memoryview for Python 3
Browse files Browse the repository at this point in the history
  • Loading branch information
cclauss committed Mar 19, 2018
1 parent c707bc2 commit 4e5e1bf
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions sdks/python/apache_beam/io/avroio.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@
from avro import datafile
from avro import schema

from six import binary_type

import apache_beam as beam
from apache_beam.io import filebasedsink
from apache_beam.io import filebasedsource
Expand Down Expand Up @@ -309,8 +311,8 @@ def _decompress_bytes(data, codec):

# Compressed data includes a 4-byte CRC32 checksum which we verify.
# We take care to avoid extra copies of data while slicing large objects
# by use of a buffer.
result = snappy.decompress(buffer(data)[:-4])
# by use of a memoryview.
result = snappy.decompress(binary_type(memoryview(data)[:-4]))
avroio.BinaryDecoder(cStringIO.StringIO(data[-4:])).check_crc32(result)
return result
else:
Expand Down

0 comments on commit 4e5e1bf

Please sign in to comment.