Skip to content

Commit 6761b20

Browse files
committed
Factor out helper function newEmptyTableContent
We'll reuse it in the next patch.
1 parent dd67907 commit 6761b20

File tree

1 file changed

+29
-16
lines changed

1 file changed

+29
-16
lines changed

src/Database/LSMTree/Internal.hs

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -694,24 +694,37 @@ new sesh conf = do
694694
withOpenSession sesh $ \seshEnv ->
695695
withActionRegistry $ \reg -> do
696696
am <- newArenaManager
697-
blobpath <- Paths.tableBlobPath (sessionRoot seshEnv) <$>
698-
incrUniqCounter (sessionUniqCounter seshEnv)
699-
tableWriteBufferBlobs
700-
<- withRollback reg
701-
(WBB.new (sessionHasFS seshEnv) blobpath)
702-
releaseRef
703-
let tableWriteBuffer = WB.empty
704-
tableLevels = V.empty
705-
tableCache <- mkLevelsCache reg tableLevels
706-
let tc = TableContent {
707-
tableWriteBuffer
708-
, tableWriteBufferBlobs
709-
, tableLevels
710-
, tableCache
711-
, tableUnionLevel = NoUnion
712-
}
697+
tc <- newEmptyTableContent seshEnv reg
713698
newWith reg sesh seshEnv conf am tc
714699

700+
{-# SPECIALISE newEmptyTableContent ::
701+
SessionEnv IO h
702+
-> ActionRegistry IO
703+
-> IO (TableContent IO h) #-}
704+
newEmptyTableContent ::
705+
(PrimMonad m, MonadMask m, MonadMVar m)
706+
=> SessionEnv m h
707+
-> ActionRegistry m
708+
-> m (TableContent m h)
709+
newEmptyTableContent seshEnv reg = do
710+
blobpath <- Paths.tableBlobPath (sessionRoot seshEnv) <$>
711+
incrUniqCounter (sessionUniqCounter seshEnv)
712+
let tableWriteBuffer = WB.empty
713+
tableWriteBufferBlobs
714+
<- withRollback reg
715+
(WBB.new (sessionHasFS seshEnv) blobpath)
716+
releaseRef
717+
let tableLevels = V.empty
718+
tableCache <- mkLevelsCache reg tableLevels
719+
pure TableContent {
720+
tableWriteBuffer
721+
, tableWriteBufferBlobs
722+
, tableLevels
723+
, tableCache
724+
, tableUnionLevel = NoUnion
725+
}
726+
727+
715728
{-# SPECIALISE newWith ::
716729
ActionRegistry IO
717730
-> Session IO h

0 commit comments

Comments
 (0)