Remove knowledge of tuple length from ledger value

Nothing should now care about the current tuple length - and hence the tuple length may be increased (for example to add a max_mod_date)
This commit is contained in:
Martin Sumner 2018-10-29 20:24:54 +00:00
parent 671b6e7f99
commit baa4466923
3 changed files with 19 additions and 20 deletions

View file

@ -1116,7 +1116,7 @@ handle_call({get, Bucket, Key, Tag}, _From, State)
not_found; not_found;
Head -> Head ->
{Seqn, Status, _MH, _MD} = {Seqn, Status, _MH, _MD} =
leveled_codec:striphead_to_details(Head), leveled_codec:striphead_to_v1details(Head),
case Status of case Status of
tomb -> tomb ->
not_found; not_found;
@ -1165,7 +1165,7 @@ handle_call({head, Bucket, Key, Tag}, _From, State)
not_present -> not_present ->
{not_found, State#state.ink_checking}; {not_found, State#state.ink_checking};
Head -> Head ->
case leveled_codec:striphead_to_details(Head) of case leveled_codec:striphead_to_v1details(Head) of
{_SeqN, tomb, _MH, _MD} -> {_SeqN, tomb, _MH, _MD} ->
{not_found, State#state.ink_checking}; {not_found, State#state.ink_checking};
{SeqN, {active, TS}, _MH, MD} -> {SeqN, {active, TS}, _MH, MD} ->

View file

@ -38,7 +38,7 @@
strip_to_statusonly/1, strip_to_statusonly/1,
strip_to_keyseqonly/1, strip_to_keyseqonly/1,
strip_to_seqnhashonly/1, strip_to_seqnhashonly/1,
striphead_to_details/1, striphead_to_v1details/1,
is_active/3, is_active/3,
endkey_passed/2, endkey_passed/2,
key_dominates/2, key_dominates/2,
@ -167,36 +167,35 @@ to_lookup(Key) ->
%% Some helper functions to get a sub_components of the key/value %% Some helper functions to get a sub_components of the key/value
-spec strip_to_statusonly(ledger_kv()) -> ledger_status(). -spec strip_to_statusonly(ledger_kv()) -> ledger_status().
strip_to_statusonly({_, {_, St, _, _}}) -> St. strip_to_statusonly({_, V}) -> element(2, V).
-spec strip_to_seqonly(ledger_kv()) -> non_neg_integer(). -spec strip_to_seqonly(ledger_kv()) -> non_neg_integer().
strip_to_seqonly({_, {SeqN, _, _, _}}) -> SeqN. strip_to_seqonly({_, V}) -> element(1, V).
-spec strip_to_keyseqonly(ledger_kv()) -> {ledger_key(), integer()}. -spec strip_to_keyseqonly(ledger_kv()) -> {ledger_key(), integer()}.
strip_to_keyseqonly({LK, {SeqN, _, _, _}}) -> {LK, SeqN}. strip_to_keyseqonly({LK, V}) -> {LK, element(1, V)}.
-spec strip_to_seqnhashonly(ledger_kv()) -> {integer(), segment_hash()}. -spec strip_to_seqnhashonly(ledger_kv()) -> {integer(), segment_hash()}.
strip_to_seqnhashonly({_, {SeqN, _, MH, _}}) -> {SeqN, MH}. strip_to_seqnhashonly({_, V}) -> {element(1, V), element(3, V)}.
-spec striphead_to_details(ledger_value()) -> ledger_value(). -spec striphead_to_v1details(ledger_value()) -> ledger_value().
striphead_to_details({SeqN, St, MH, MD}) -> {SeqN, St, MH, MD}. striphead_to_v1details(V) ->
{element(1, V), element(2, V), element(3, V), element(4, V)}.
-spec key_dominates(ledger_kv(), ledger_kv()) -> -spec key_dominates(ledger_kv(), ledger_kv()) ->
left_hand_first|right_hand_first|left_hand_dominant|right_hand_dominant. left_hand_first|right_hand_first|left_hand_dominant|right_hand_dominant.
%% @doc %% @doc
%% When comparing two keys in the ledger need to find if one key comes before %% When comparing two keys in the ledger need to find if one key comes before
%% the other, or if the match, which key is "better" and should be the winner %% the other, or if the match, which key is "better" and should be the winner
key_dominates(LeftKey, RightKey) -> key_dominates({LK, _LVAL}, {RK, _RVAL}) when LK < RK ->
case {LeftKey, RightKey} of left_hand_first;
{{LK, _LVAL}, {RK, _RVAL}} when LK < RK -> key_dominates({LK, _LVAL}, {RK, _RVAL}) when RK < LK ->
left_hand_first; right_hand_first;
{{LK, _LVAL}, {RK, _RVAL}} when RK < LK -> key_dominates(LObj, RObj) ->
right_hand_first; case strip_to_seqonly(LObj) >= strip_to_seqonly(RObj) of
{{LK, {LSN, _LST, _LMH, _LMD}}, {RK, {RSN, _RST, _RMH, _RMD}}} true ->
when LK == RK, LSN >= RSN ->
left_hand_dominant; left_hand_dominant;
{{LK, {LSN, _LST, _LMH, _LMD}}, {RK, {RSN, _RST, _RMH, _RMD}}} false ->
when LK == RK, LSN < RSN ->
right_hand_dominant right_hand_dominant
end. end.

View file

@ -612,7 +612,7 @@ accumulate_objects(FoldObjectsFun, InkerClone, Tag, DeferredFetch) ->
case leveled_codec:is_active(LK, V, Now) of case leveled_codec:is_active(LK, V, Now) of
true -> true ->
{SQN, _St, _MH, MD} = {SQN, _St, _MH, MD} =
leveled_codec:striphead_to_details(V), leveled_codec:striphead_to_v1details(V),
{B, K} = {B, K} =
case leveled_codec:from_ledgerkey(LK) of case leveled_codec:from_ledgerkey(LK) of
{B0, K0} -> {B0, K0} ->