WIP: sitll fixing things.
This commit is contained in:
parent
246e891d01
commit
b67d1f8449
2 changed files with 31 additions and 16 deletions
|
@ -261,7 +261,7 @@ close(#index{file=File}) ->
|
||||||
|
|
||||||
|
|
||||||
lookup(#index{file=File, root=Node, bloom=Bloom}, Key) ->
|
lookup(#index{file=File, root=Node, bloom=Bloom}, Key) ->
|
||||||
case bloom:is_element(Bloom, Key) orelse Key =:= <<>> of
|
case bloom:is_element(Bloom, Key) of
|
||||||
true ->
|
true ->
|
||||||
case lookup_in_node(File, Node, Key) of
|
case lookup_in_node(File, Node, Key) of
|
||||||
not_found ->
|
not_found ->
|
||||||
|
|
|
@ -111,16 +111,30 @@ init([Name, Options]) ->
|
||||||
|
|
||||||
handle_cast({add, Key, {?TOMBSTONE, TStamp}}, State)
|
handle_cast({add, Key, {?TOMBSTONE, TStamp}}, State)
|
||||||
when is_binary(Key) ->
|
when is_binary(Key) ->
|
||||||
{ok, State2} = add_record(0, Key, {?TOMBSTONE, TStamp}, State),
|
NewState =
|
||||||
{noreply, State2};
|
case hanoidb_util:has_expired(TStamp) of
|
||||||
|
true ->
|
||||||
|
State;
|
||||||
|
false ->
|
||||||
|
{ok, State2} = add_record(0, Key, {?TOMBSTONE, TStamp}, State),
|
||||||
|
State2
|
||||||
|
end,
|
||||||
|
{noreply, NewState};
|
||||||
handle_cast({add, Key, ?TOMBSTONE}, State)
|
handle_cast({add, Key, ?TOMBSTONE}, State)
|
||||||
when is_binary(Key) ->
|
when is_binary(Key) ->
|
||||||
{ok, State2} = add_record(0, Key, ?TOMBSTONE, State),
|
{ok, NewState} = add_record(0, Key, ?TOMBSTONE, State),
|
||||||
{noreply, State2};
|
{noreply, NewState};
|
||||||
handle_cast({add, Key, {Value, TStamp}}, State)
|
handle_cast({add, Key, {Value, TStamp}}, State)
|
||||||
when is_binary(Key), is_binary(Value) ->
|
when is_binary(Key), is_binary(Value) ->
|
||||||
{ok, State2} = add_record(0, Key, {Value, TStamp}, State),
|
NewState =
|
||||||
{noreply, State2};
|
case hanoidb_util:has_expired(TStamp) of
|
||||||
|
true ->
|
||||||
|
State;
|
||||||
|
false ->
|
||||||
|
{ok, State2} = add_record(0, Key, {Value, TStamp}, State),
|
||||||
|
State2
|
||||||
|
end,
|
||||||
|
{noreply, NewState};
|
||||||
handle_cast({add, Key, Value}, State)
|
handle_cast({add, Key, Value}, State)
|
||||||
when is_binary(Key), is_binary(Value) ->
|
when is_binary(Key), is_binary(Value) ->
|
||||||
{ok, State2} = add_record(0, Key, Value, State),
|
{ok, State2} = add_record(0, Key, Value, State),
|
||||||
|
@ -182,13 +196,13 @@ flush_nodes(#state{ nodes=[], last_node_pos=LastNodePos, last_node_size=_LastNod
|
||||||
IdxFile = State#state.index_file,
|
IdxFile = State#state.index_file,
|
||||||
|
|
||||||
RootPos =
|
RootPos =
|
||||||
case LastNodePos =:= undefined of
|
case LastNodePos of
|
||||||
true ->
|
undefined ->
|
||||||
LastNodePos;
|
|
||||||
false ->
|
|
||||||
%% 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;
|
||||||
|
_ ->
|
||||||
|
LastNodePos
|
||||||
end,
|
end,
|
||||||
|
|
||||||
BloomBin = hanoidb_util:encode_bloom(Bloom),
|
BloomBin = hanoidb_util:encode_bloom(Bloom),
|
||||||
|
@ -228,10 +242,11 @@ add_record(Level, Key, Value, #state{ nodes=[ #node{level=Level, members=List, s
|
||||||
|
|
||||||
NewSize = NodeSize + hanoidb_util:estimate_node_size_increment(List, Key, Value),
|
NewSize = NodeSize + hanoidb_util:estimate_node_size_increment(List, Key, Value),
|
||||||
|
|
||||||
Bloom = case Key of
|
Bloom = bloom:add_element(Key, State#state.bloom),
|
||||||
<<>> -> State#state.bloom;
|
%% Bloom = case Key of
|
||||||
_ -> bloom:add_element(Key, State#state.bloom)
|
%% <<>> -> State#state.bloom;
|
||||||
end,
|
%% _ -> bloom:add_element(Key, State#state.bloom)
|
||||||
|
%% end,
|
||||||
|
|
||||||
{TC1, VC1} =
|
{TC1, VC1} =
|
||||||
case Level of
|
case Level of
|
||||||
|
|
Loading…
Reference in a new issue