Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Changed get_counter to return 0 on missing rather than undefined.

Only consumer I could find was in riak_kv_vnode - and that was
wrapping vclock:get_counter with a function to do the conversion.
  • Loading branch information...
commit c5c6710e63bd0f2029d034075511b368e83c378a 1 parent 6af5ab5
@jonmeredith jonmeredith authored
Showing with 3 additions and 3 deletions.
  1. +3 −3 src/vclock.erl
View
6 src/vclock.erl
@@ -100,11 +100,11 @@ merge(V=[{Node1,{Ctr1,TS1}=CT1}=NCT1|VClock],
end.
% @doc Get the counter value in VClock set from Node.
--spec get_counter(Node :: vclock_node(), VClock :: vclock()) -> counter() | undefined.
+-spec get_counter(Node :: vclock_node(), VClock :: vclock()) -> counter().
get_counter(Node, VClock) ->
case lists:keyfind(Node, 1, VClock) of
{_, {Ctr, _TS}} -> Ctr;
- false -> undefined
+ false -> 0
end.
% @doc Get the timestamp value in a VClock set from Node.
@@ -279,7 +279,7 @@ accessor_test() ->
?assertEqual(1, get_timestamp(<<"1">>, VC)),
?assertEqual(2, get_counter(<<"2">>, VC)),
?assertEqual(2, get_timestamp(<<"2">>, VC)),
- ?assertEqual(undefined, get_counter(<<"3">>, VC)),
+ ?assertEqual(0, get_counter(<<"3">>, VC)),
?assertEqual(undefined, get_timestamp(<<"3">>, VC)),
?assertEqual([<<"1">>, <<"2">>], all_nodes(VC)).
Please sign in to comment.
Something went wrong with that request. Please try again.