Skip to content

Commit

Permalink
Merge pull request #129 from ShapovalovaIrina/fix-input-data-for-ezst…
Browse files Browse the repository at this point in the history
…d-compression

fix: convert iolist to binary for ezstd compression
  • Loading branch information
zmstone authored Feb 6, 2025
2 parents fe32235 + 0349619 commit 69fb3c0
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/kpro_compress.erl
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ java_snappy_unpack_chunks(Chunks, Acc) ->

do_compress(Name, IoData) ->
Module = get_module(Name),
iodata(Module:compress(IoData)).
Data = maybe_convert_iodata_to_binary(Module, IoData),
iodata(Module:compress(Data)).

do_decompress(Name, Bin) ->
Module = get_module(Name),
Expand All @@ -104,6 +105,9 @@ get_module(?zstd) ->
get_module(Name, Default) ->
persistent_term:get({?MODULE, Name}, Default).

maybe_convert_iodata_to_binary(ezstd, IoData) -> iolist_to_binary(IoData);
maybe_convert_iodata_to_binary(_Module, IoData) -> IoData.

iodata({ok, IoData}) -> IoData;
iodata({error, Reason}) -> error(Reason);
iodata(IoData) when is_list(IoData) orelse is_binary(IoData) -> IoData.
Expand Down

0 comments on commit 69fb3c0

Please sign in to comment.