Use not_found uniformly (rather than notfound).

This commit is contained in:
Gregory Burd 2012-04-15 15:34:42 -04:00
parent 5338a07c54
commit 61d360550e
5 changed files with 15 additions and 14 deletions

View file

@ -53,7 +53,7 @@ run(get, KeyGen, _ValueGen, State) ->
case lsm_btree:lookup(State#state.tree, KeyGen()) of
{ok, _Value} ->
{ok, State};
notfound ->
not_found ->
{ok, State};
{error, Reason} ->
{error, Reason}

View file

@ -51,7 +51,7 @@
open(Dir) ->
open(Dir, []).
open(Dir, Config) -> %TODO Config is currently ignored.
open(Dir, _Config) -> %TODO Config is currently ignored.
gen_server:start(?MODULE, [Dir], []).
close(Ref) ->

View file

@ -180,8 +180,8 @@ main_loop(State = #state{ next=Next }) ->
receive
?REQ(From, {lookup, Key})=Req ->
case do_lookup(Key, [State#state.b, State#state.a, Next]) of
notfound ->
reply(From, notfound);
not_found ->
reply(From, not_found);
{found, Result} ->
reply(From, {ok, Result});
{delegate, DelegatePid} ->
@ -355,16 +355,16 @@ main_loop(State = #state{ next=Next }) ->
end.
do_lookup(_Key, []) ->
notfound;
not_found;
do_lookup(_Key, [Pid]) when is_pid(Pid) ->
{delegate, Pid};
do_lookup(Key, [undefined|Rest]) ->
do_lookup(Key, Rest);
do_lookup(Key, [BT|Rest]) ->
case lsm_btree_reader:lookup(BT, Key) of
{ok, ?TOMBSTONE} -> notfound;
{ok, ?TOMBSTONE} -> not_found;
{ok, Result} -> {found, Result};
notfound -> do_lookup(Key, Rest)
not_found -> do_lookup(Key, Rest)
end.
close_if_defined(undefined) -> ok;

View file

@ -130,7 +130,7 @@ lookup_node(File,FromKey,#node{members=Members,level=N},_) ->
eof ->
none
end;
notfound ->
not_found ->
none
end.
@ -161,13 +161,13 @@ lookup(#index{file=File, root=Node, bloom=Bloom}, Key) ->
true ->
lookup_in_node(File,Node,Key);
false ->
notfound
not_found
end.
lookup_in_node(_File,#node{level=0,members=Members},Key) ->
case lists:keyfind(Key,1,Members) of
false ->
notfound;
not_found;
{_,Value} ->
{ok, Value}
end;
@ -177,8 +177,8 @@ lookup_in_node(File,#node{members=Members},Key) ->
{ok, {Pos,Size}} ->
{ok, Node} = read_node(File, {Pos,Size}),
lookup_in_node(File, Node, Key);
notfound ->
notfound
not_found ->
not_found
end.
@ -189,10 +189,11 @@ find(K, [{K1,V}]) when K >= K1 ->
find(K, [_|T]) ->
find(K,T);
find(_, _) ->
notfound.
not_found.
read_node(File,{Pos,Size}) ->
% error_logger:info_msg("read_node ~p ~p ~p~n", [File, Pos, Size]),
{ok, <<_:32, Level:16/unsigned, Data/binary>>} = file:pread(File, Pos, Size),
lsm_btree_util:decode_index_node(Level, Data);

View file

@ -96,7 +96,7 @@ start(Partition, Config) ->
end,
case AppStart of
ok ->
ok = filelib:ensure_dir(filename:join(DataRoot, "x")),
ok = filelib:ensure_dir(filename:join([DataRoot, "x"])),
DbName = filename:join(DataRoot, integer_to_list(Partition)),
case lsm_btree:open(DbName) of
{ok, Tree} ->