Skip to content

Commit

Permalink
Add support for v0 object in parallel-mode AAE (#11)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>

---------

Co-authored-by: Thomas Arts <[email protected]>
  • Loading branch information
martinsumner and ThomasArts committed Nov 14, 2023
1 parent b02f24e commit 2ac2c80
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/riak_object.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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(<<?MAGIC, _Rest/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)
Expand Down

0 comments on commit 2ac2c80

Please sign in to comment.