From 61d360550e1cf9f41da6aa65525126a2943a723b Mon Sep 17 00:00:00 2001 From: Gregory Burd Date: Sun, 15 Apr 2012 15:34:42 -0400 Subject: [PATCH] Use not_found uniformly (rather than notfound). --- src/basho_bench_driver_lsm_btree.erl | 2 +- src/lsm_btree.erl | 2 +- src/lsm_btree_level.erl | 10 +++++----- src/lsm_btree_reader.erl | 13 +++++++------ src/riak_kv_lsm_btree_backend.erl | 2 +- 5 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/basho_bench_driver_lsm_btree.erl b/src/basho_bench_driver_lsm_btree.erl index 0777ce0..9481ed3 100644 --- a/src/basho_bench_driver_lsm_btree.erl +++ b/src/basho_bench_driver_lsm_btree.erl @@ -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} diff --git a/src/lsm_btree.erl b/src/lsm_btree.erl index af19767..67a53f0 100644 --- a/src/lsm_btree.erl +++ b/src/lsm_btree.erl @@ -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) -> diff --git a/src/lsm_btree_level.erl b/src/lsm_btree_level.erl index 8d0ae39..5c4642e 100644 --- a/src/lsm_btree_level.erl +++ b/src/lsm_btree_level.erl @@ -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; diff --git a/src/lsm_btree_reader.erl b/src/lsm_btree_reader.erl index bf18492..8426c4e 100644 --- a/src/lsm_btree_reader.erl +++ b/src/lsm_btree_reader.erl @@ -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); diff --git a/src/riak_kv_lsm_btree_backend.erl b/src/riak_kv_lsm_btree_backend.erl index 6cc9024..49689bd 100644 --- a/src/riak_kv_lsm_btree_backend.erl +++ b/src/riak_kv_lsm_btree_backend.erl @@ -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} ->