Fix problem in merge hibernation
The merge state includes an bloom reference, which needed to be properly serialized.
This commit is contained in:
parent
f0833de3fc
commit
77a81499f9
2 changed files with 20 additions and 6 deletions
|
@ -75,8 +75,8 @@ hibernate_scan(Keep) ->
|
||||||
receive
|
receive
|
||||||
{step, From, HowMany} ->
|
{step, From, HowMany} ->
|
||||||
error_logger:info_msg("waking up ~p~n", [self()]),
|
error_logger:info_msg("waking up ~p~n", [self()]),
|
||||||
{BT1, BT2, Out, IsLastLevel, AKVs, BKVs, Count} = erlang:binary_to_term( zlib:gunzip( Keep ) ),
|
{BT1, BT2, OutBin, IsLastLevel, AKVs, BKVs, Count} = erlang:binary_to_term( zlib:gunzip( Keep ) ),
|
||||||
scan(BT1, BT2, Out, IsLastLevel, AKVs, BKVs, Count, {HowMany, From})
|
scan(BT1, BT2, hanoi_writer:deserialize(OutBin), IsLastLevel, AKVs, BKVs, Count, {HowMany, From})
|
||||||
end.
|
end.
|
||||||
|
|
||||||
scan(BT1, BT2, Out, IsLastLevel, AKVs, BKVs, Count, {0, FromPID}) ->
|
scan(BT1, BT2, Out, IsLastLevel, AKVs, BKVs, Count, {0, FromPID}) ->
|
||||||
|
@ -91,9 +91,14 @@ scan(BT1, BT2, Out, IsLastLevel, AKVs, BKVs, Count, {0, FromPID}) ->
|
||||||
{step, From, HowMany} ->
|
{step, From, HowMany} ->
|
||||||
scan(BT1, BT2, Out, IsLastLevel, AKVs, BKVs, Count, {HowMany, From})
|
scan(BT1, BT2, Out, IsLastLevel, AKVs, BKVs, Count, {HowMany, From})
|
||||||
after 10000 ->
|
after 10000 ->
|
||||||
Args = {BT1, BT2, Out, IsLastLevel, AKVs, BKVs, Count},
|
case ?LOCAL_WRITER of
|
||||||
Keep = zlib:gzip ( erlang:term_to_binary( Args ) ),
|
true ->
|
||||||
hibernate_scan(Keep)
|
Args = {BT1, BT2, hanoi_writer:serialize(Out), IsLastLevel, AKVs, BKVs, Count},
|
||||||
|
Keep = zlib:gzip ( erlang:term_to_binary( Args ) ),
|
||||||
|
hibernate_scan(Keep);
|
||||||
|
false ->
|
||||||
|
scan(BT1, BT2, Out, IsLastLevel, AKVs, BKVs, Count, {0, none})
|
||||||
|
end
|
||||||
end;
|
end;
|
||||||
|
|
||||||
scan(BT1, BT2, Out, IsLastLevel, [], BKVs, Count, Step) ->
|
scan(BT1, BT2, Out, IsLastLevel, [], BKVs, Count, Step) ->
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
|
|
||||||
%% gen_server callbacks
|
%% gen_server callbacks
|
||||||
-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
|
-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
|
||||||
terminate/2, code_change/3]).
|
terminate/2, code_change/3, serialize/1, deserialize/1]).
|
||||||
|
|
||||||
-export([open/1, open/2, add/3,close/1]).
|
-export([open/1, open/2, add/3,close/1]).
|
||||||
|
|
||||||
|
@ -126,6 +126,15 @@ code_change(_OldVsn, State, _Extra) ->
|
||||||
|
|
||||||
%%%%% INTERNAL FUNCTIONS
|
%%%%% INTERNAL FUNCTIONS
|
||||||
|
|
||||||
|
serialize(#state{ bloom=Bloom }=State) ->
|
||||||
|
erlang:term_to_binary( { State, ebloom:serialize(Bloom) } ).
|
||||||
|
|
||||||
|
deserialize(Binary) ->
|
||||||
|
{ State, BinBloom } = erlang:binary_to_term( Binary ),
|
||||||
|
{ok, Bloom } = ebloom:deserialize(BinBloom),
|
||||||
|
State#state{ bloom = Bloom }.
|
||||||
|
|
||||||
|
|
||||||
% @doc flush pending nodes and write trailer
|
% @doc flush pending nodes and write trailer
|
||||||
|
|
||||||
flush_nodes(#state{ nodes=[], last_node_pos=LastNodePos, last_node_size=_LastNodeSize, bloom=Ref }=State) ->
|
flush_nodes(#state{ nodes=[], last_node_pos=LastNodePos, last_node_size=_LastNodeSize, bloom=Ref }=State) ->
|
||||||
|
|
Loading…
Reference in a new issue