When opening a level, enforce just enough merge
When re-opening a Hanoi data store, we need to reestablish the invariant that there is always room to inject a data file at the top level. In a worst case scenario, every level has all of A, B, and C; and thus needs to merge A+B -> X fully in order to accommodate what the parent will inject. 2*BTREE_SIZE(Level) >= sizeof(A+B)
This commit is contained in:
parent
8694cc118f
commit
99fb1bee74
2 changed files with 2 additions and 1 deletions
|
@ -222,6 +222,8 @@ open_levels(Dir) ->
|
|||
undefined,
|
||||
lists:seq(MaxLevel, MinLevel, -1)),
|
||||
|
||||
ok = hanoi_level:incremental_merge(TopLevel, 2*?BTREE_SIZE(MaxLevel)),
|
||||
|
||||
{ok, TopLevel}.
|
||||
|
||||
parse_level(FileName) ->
|
||||
|
|
|
@ -59,7 +59,6 @@ open(Dir,Level,Next) when Level>0 ->
|
|||
process_flag(trap_exit,true),
|
||||
initialize(#state{dir=Dir,level=Level,next=Next})
|
||||
end),
|
||||
incremental_merge(PID, 2*?BTREE_SIZE(?TOP_LEVEL)),
|
||||
{ok, PID}.
|
||||
|
||||
lookup(Ref, Key) ->
|
||||
|
|
Loading…
Reference in a new issue