File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
src/Database/LSMTree/Internal/Index Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -80,7 +80,17 @@ toLastKeys (IndexOrdinary lastKeys) = lastKeys
8080 type-agnostic version]('Database.LSMTree.Internal.Index.search').
8181-}
8282search :: SerialisedKey -> IndexOrdinary -> PageSpan
83- search key (IndexOrdinary lastKeys) = assert (pageCount > 0 ) result where
83+ search key (IndexOrdinary lastKeys)
84+ -- TODO: ideally, we could assert that an index is never empty, but
85+ -- unfortunately we can not currently do this. Runs (and thefeore indexes)
86+ -- /can/ be empty if they were created by a last-level merge where all input
87+ -- entries were deletes. Other parts of the @lsm-tree@ code won't fail as long
88+ -- as we return @PageSpan 0 0@ when we search an empty ordinary index. The
89+ -- ideal fix would be to remove empty runs from the levels entirely, but this
90+ -- requires more involved changes to the merge schedule and until then we'll
91+ -- just hack the @pageCount <= 0@ case in.
92+ | pageCount <= 0 = PageSpan (PageNo 0 ) (PageNo 0 )
93+ | otherwise = assert (pageCount > 0 ) result where
8494
8595 protoStart :: Int
8696 ! protoStart = binarySearchL lastKeys key
You can’t perform that action at this time.
0 commit comments