From 310f44a4748ed15023670a0d7da26d5a4174fd71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Attab?= Date: Thu, 14 Mar 2024 11:57:07 -0400 Subject: [PATCH 1/2] Add support for small and tiny ints in response decoder --- src/marina_body.erl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/marina_body.erl b/src/marina_body.erl index 1456ad5..82f5187 100644 --- a/src/marina_body.erl +++ b/src/marina_body.erl @@ -207,6 +207,10 @@ decode_type(<<16#F:16, Rest/binary>>) -> {timeuuid, Rest}; decode_type(<<16#10:16, Rest/binary>>) -> {inet, Rest}; +decode_type(<<16#13:16, Rest/binary>>) -> + {smallint, Rest}; +decode_type(<<16#14:16, Rest/binary>>) -> + {tinyint, Rest}; decode_type(<<16#20:16, Rest/binary>>) -> {Type, Rest2} = decode_type(Rest), {{list, Type}, Rest2}; From 934e0fda64747a603a7a7302855be20291e433a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Attab?= Date: Tue, 12 Mar 2024 14:37:50 -0400 Subject: [PATCH 2/2] Add encode_list and encode_tinyint to marina_types --- src/marina_types.erl | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/marina_types.erl b/src/marina_types.erl index 2415718..8dcdfeb 100644 --- a/src/marina_types.erl +++ b/src/marina_types.erl @@ -16,10 +16,12 @@ decode_string_list/1, decode_string_map/1, decode_string_multimap/1, + decode_tinyint/1, decode_uuid/1, encode_boolean/1, encode_bytes/1, encode_int/1, + encode_list/1, encode_long/1, encode_long_string/1, encode_short/1, @@ -27,7 +29,8 @@ encode_string/1, encode_string_list/1, encode_string_map/1, - encode_string_multimap/1 + encode_string_multimap/1, + encode_tinyint/1 ]). %% public @@ -90,6 +93,11 @@ decode_string_map(<>) -> decode_string_multimap(<>) -> decode_string_multimap(Rest, Length, []). +-spec decode_tinyint(binary()) -> {integer(), binary()}. + +decode_tinyint(<>) -> + {Value, Rest}. + -spec decode_uuid(binary()) -> {binary(), binary()}. decode_uuid(<>) -> @@ -112,6 +120,11 @@ encode_bytes(Value) -> encode_int(Value) -> <>. +-spec encode_list([binary()]) -> binary(). + +encode_list(Values) -> + iolist_to_binary([encode_short(length(Values)), Values]). + -spec encode_long(integer()) -> binary(). encode_long(Value) -> @@ -154,6 +167,9 @@ encode_string_map(KeyValues) -> encode_string_multimap(KeyValues) -> encode_string_multimap(KeyValues, []). +encode_tinyint(Value) -> + <>. + %% private decode_long_string_set(Bin, 0, Acc) -> {lists:reverse(Acc), Bin};