This commit is contained in:
Gregory Burd 2012-06-25 07:27:00 +05:30
parent ba068a3175
commit 7ab09f5983
2 changed files with 4 additions and 7 deletions

View file

@ -246,8 +246,8 @@ add(Key, Value, Expiry, Nursery, Top) ->
case do_add(Nursery, Key, Value, Expiry, Top) of case do_add(Nursery, Key, Value, Expiry, Top) of
{ok, Nursery0} -> {ok, Nursery0} ->
{ok, Nursery0}; {ok, Nursery0};
{full, Nursery1} -> {full, Nursery0} ->
flush(Nursery1, Top) flush(Nursery0, Top)
end. end.
flush(Nursery=#nursery{ dir=Dir, max_level=MaxLevel, config=Config }, Top) -> flush(Nursery=#nursery{ dir=Dir, max_level=MaxLevel, config=Config }, Top) ->

View file

@ -186,15 +186,12 @@ do_open(Name, Options, OpenOpts) ->
%% @doc flush pending nodes and write trailer %% @doc flush pending nodes and write trailer
flush_nodes(State=#state{ nodes=[#node{level=N, members=[{_,{Pos,_Len}}]}], last_node_pos=Pos }) when N>0 ->
%% stack consists of one node with one {pos,len} member. Just ignore this node.
flush_nodes(State#state{ nodes=[] });
flush_nodes(#state{ nodes=[], last_node_pos=LastNodePos, last_node_size=_LastNodeSize, bloom=Bloom }=State) -> flush_nodes(#state{ nodes=[], last_node_pos=LastNodePos, last_node_size=_LastNodeSize, bloom=Bloom }=State) ->
IdxFile = State#state.index_file, IdxFile = State#state.index_file,
RootPos = RootPos =
case LastNodePos of case LastNodePos =:= undefined of
undefined -> true ->
%% store contains no entries %% store contains no entries
ok = file:write(IdxFile, <<0:32,0:16>>), ok = file:write(IdxFile, <<0:32,0:16>>),
?FIRST_BLOCK_POS; ?FIRST_BLOCK_POS;