Simplify riak_kv_hanoi_backend:is_empty/1

Do range fold with limit=1, rather than throw
exception.
This commit is contained in:
Kresten Krab Thorup 2012-05-06 19:49:53 +02:00
parent 0b8d035bda
commit 5b88a71e1d

View file

@ -303,10 +303,10 @@ drop(#state{ tree=Tree, partition=Partition, config=Config }=State) ->
%% non-tombstone values; otherwise returns false.
-spec is_empty(state()) -> boolean().
is_empty(#state{tree=Tree}) ->
FoldFun = fun(_K, _V, _Acc) -> throw(ok) end,
FoldFun = fun(K, _V, Acc) -> [K|Acc] end,
try
Range = to_key_range(undefined),
[] =:= hanoi:fold_range(Tree, FoldFun, [], Range)
[] =:= hanoi:fold_range(Tree, FoldFun, [], Range#btree_range{ limit=1 })
catch
_:ok ->
false