Skip to content

Support alternative lz4framed #1395

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 9, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions kafka/codec.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@
except ImportError:
lz4f = None

try:
import lz4framed
except ImportError:
lz4framed = None

try:
import xxhash
except ImportError:
Expand All @@ -46,6 +51,8 @@ def has_lz4():
return True
if lz4f is not None:
return True
if lz4framed is not None:
return True
return False


Expand Down Expand Up @@ -198,6 +205,8 @@ def snappy_decode(payload):
lz4_encode = lz4.compress # pylint: disable-msg=no-member
elif lz4f:
lz4_encode = lz4f.compressFrame # pylint: disable-msg=no-member
elif lz4framed:
lz4_encode = lz4framed.compress # pylint: disable-msg=no-member
else:
lz4_encode = None

Expand All @@ -220,6 +229,8 @@ def lz4f_decode(payload):
lz4_decode = lz4.decompress # pylint: disable-msg=no-member
elif lz4f:
lz4_decode = lz4f_decode
elif lz4framed:
lz4_decode = lz4framed.decompress # pylint: disable-msg=no-member
else:
lz4_decode = None

Expand Down