From 2ac2c808d9ce7f5ec56c1459e92b3ff4d64924b4 Mon Sep 17 00:00:00 2001 From: Martin Sumner Date: Mon, 13 Nov 2023 19:14:15 +0000 Subject: [PATCH] Add support for v0 object in parallel-mode AAE (#11) * Add support for v0 object in parallel-mode AAE Cannot assume that v0 objects will not happen - capability negotiation down to v0 on 3.0 Riak during failure scenarios * Update following review As ?MAGIC is distinctive constant, then it should be the one on the pattern match - with everything else assume to be convertible by term_to_binary. * Update src/riak_object.erl Co-authored-by: Thomas Arts --------- Co-authored-by: Thomas Arts --- src/riak_object.erl | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/riak_object.erl b/src/riak_object.erl index 9cc4820d5..1a795f2ef 100644 --- a/src/riak_object.erl +++ b/src/riak_object.erl @@ -1262,23 +1262,21 @@ from_binary(_B, _K, Obj = #r_object{}) -> Obj. --spec summary_from_binary(binary()) -> +-spec summary_from_binary(binary()|riak_object()) -> {vclock:vclock(), integer(), integer(), list(erlang:timestamp())|undefined, binary()}. %% @doc -%% Extract only sumarry infromation from the binary - the vector, the object +%% Extract only summary information from the binary - the vector, the object %% size and the sibling count -summary_from_binary(<<131, _Rest/binary>>=ObjBin) -> - case binary_to_term(ObjBin) of +summary_from_binary(<>=ObjBin) -> + summary_from_binary(ObjBin, byte_size(ObjBin)); +summary_from_binary(TermToBin) when is_binary(TermToBin) -> + case binary_to_term(TermToBin) of {proxy_object, HeadBin, ObjSize, _Fetcher} -> summary_from_binary(HeadBin, ObjSize); - T -> - {vclock(T), byte_size(ObjBin), value_count(T), - undefined, <<>>} - % Legacy object version will end up with dummy details + Objv0 -> + summary_from_binary(Objv0) end; -summary_from_binary(ObjBin) when is_binary(ObjBin) -> - summary_from_binary(ObjBin, byte_size(ObjBin)); summary_from_binary(Object = #r_object{}) -> % Unexpected scenario but included for parity with from_binary % Calculating object size is expensive (relatively to other branches)