diff options
author | Taras <voyn1991@gmail.com> | 2017-10-11 15:34:00 +0300 |
---|---|---|
committer | Taras <voyn1991@gmail.com> | 2017-10-12 11:10:16 +0300 |
commit | a12ca527a4b8ac77e21e63db7d47b4a68015b780 (patch) | |
tree | 6b958df8f428f55ee8249f751ffd0d8d56fb0511 | |
parent | fbea5f04bccd28f3aa15a1711548b131504591ac (diff) | |
download | kafka-python-a12ca527a4b8ac77e21e63db7d47b4a68015b780.tar.gz |
Fix snappy compression on PyPy
-rw-r--r-- | kafka/record/legacy_records.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/kafka/record/legacy_records.py b/kafka/record/legacy_records.py index 3d9822d..98c8e30 100644 --- a/kafka/record/legacy_records.py +++ b/kafka/record/legacy_records.py @@ -412,15 +412,16 @@ class LegacyRecordBatchBuilder(ABCRecordBatchBuilder, LegacyRecordBase): def _maybe_compress(self): if self._compression_type: + data = bytes(self._buffer) if self._compression_type == self.CODEC_GZIP: - compressed = gzip_encode(bytes(self._buffer)) + compressed = gzip_encode(data) elif self._compression_type == self.CODEC_SNAPPY: - compressed = snappy_encode(self._buffer) + compressed = snappy_encode(data) elif self._compression_type == self.CODEC_LZ4: if self._magic == 0: - compressed = lz4_encode_old_kafka(bytes(self._buffer)) + compressed = lz4_encode_old_kafka(data) else: - compressed = lz4_encode(bytes(self._buffer)) + compressed = lz4_encode(data) size = self.size_in_bytes( 0, timestamp=0, key=None, value=compressed) # We will try to reuse the same buffer if we have enough space |