Bloom filter: Handle hibernate situation in dense_bitmap.
This commit is contained in:
parent
12148a7af9
commit
1c6e0df15c
2 changed files with 10 additions and 3 deletions
|
@ -196,7 +196,10 @@ bitmask_new(LogN) ->
|
||||||
bitmask_set(I, BM) ->
|
bitmask_set(I, BM) ->
|
||||||
case element(1,BM) of
|
case element(1,BM) of
|
||||||
array -> bitarray_set(I, BM);
|
array -> bitarray_set(I, BM);
|
||||||
dense_bitmap_ets -> hanoidb_dense_bitmap:set(I, BM)
|
dense_bitmap_ets -> hanoidb_dense_bitmap:set(I, BM);
|
||||||
|
dense_bitmap ->
|
||||||
|
%% Surprise - we need to mutate a built representation:
|
||||||
|
hanoidb_dense_bitmap:set(I, hanoidb_dense_bitmap:unbuild(BM))
|
||||||
end.
|
end.
|
||||||
|
|
||||||
%%% Convert to external form.
|
%%% Convert to external form.
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
-module(hanoidb_dense_bitmap).
|
-module(hanoidb_dense_bitmap).
|
||||||
|
|
||||||
-export([new/1, set/2, build/1, member/2]).
|
-export([new/1, set/2, build/1, unbuild/1, member/2]).
|
||||||
-define(BITS_PER_CELL, 32).
|
-define(BITS_PER_CELL, 32).
|
||||||
|
|
||||||
-define(REPR_NAME, dense_bitmap).
|
-define(REPR_NAME, dense_bitmap).
|
||||||
|
@ -10,7 +10,6 @@ new(N) ->
|
||||||
Width = 1 + (N-1) div ?BITS_PER_CELL,
|
Width = 1 + (N-1) div ?BITS_PER_CELL,
|
||||||
Value = erlang:make_tuple(Width+1, 0, [{1,?REPR_NAME}]),
|
Value = erlang:make_tuple(Width+1, 0, [{1,?REPR_NAME}]),
|
||||||
ets:insert(Tab, Value),
|
ets:insert(Tab, Value),
|
||||||
%io:format("DB| create(): ~p of width ~p\n", [Tab, Width]),
|
|
||||||
{dense_bitmap_ets, N, Width, Tab}.
|
{dense_bitmap_ets, N, Width, Tab}.
|
||||||
|
|
||||||
%% Set a bit.
|
%% Set a bit.
|
||||||
|
@ -27,6 +26,11 @@ build({dense_bitmap_ets, _, _, Tab}) ->
|
||||||
ets:delete(Tab),
|
ets:delete(Tab),
|
||||||
Row.
|
Row.
|
||||||
|
|
||||||
|
unbuild(Row) when element(1,Row)==?REPR_NAME ->
|
||||||
|
Tab = ets:new(dense_bitmap, [private, set]),
|
||||||
|
ets:insert(Tab, Row),
|
||||||
|
{dense_bitmap_ets, undefined, undefined, Tab}.
|
||||||
|
|
||||||
member(I, Row) when element(1,Row)==?REPR_NAME ->
|
member(I, Row) when element(1,Row)==?REPR_NAME ->
|
||||||
Cell = 2 + I div ?BITS_PER_CELL,
|
Cell = 2 + I div ?BITS_PER_CELL,
|
||||||
BitInCell = I rem ?BITS_PER_CELL,
|
BitInCell = I rem ?BITS_PER_CELL,
|
||||||
|
|
Loading…
Reference in a new issue