@@ -901,10 +901,10 @@ data CursorEnv m h = CursorEnv {
901901 -- However, the reference counts to the runs only get removed when calling
902902 -- 'closeCursor', as there might still be 'BlobRef's that need the
903903 -- corresponding run to stay alive.
904- , cursorReaders :: ! (Maybe (Readers. Readers m ( Handle h ) ))
904+ , cursorReaders :: ! (Maybe (Readers. Readers m h ))
905905 -- | The runs held open by the cursor. We must remove a reference when the
906906 -- cursor gets closed.
907- , cursorRuns :: ! (V. Vector (Run m ( Handle h ) ))
907+ , cursorRuns :: ! (V. Vector (Run m h ))
908908
909909 -- | The write buffer blobs, which like the runs, we have to keep open
910910 -- untile the cursor is closed.
@@ -943,9 +943,6 @@ newCursor !offsetKey th = withOpenTable th $ \thEnv -> do
943943 let cursorTracer = TraceCursor cursorId `contramap` sessionTracer cursorSession
944944 traceWith cursorTracer $ TraceCreateCursor (tableId thEnv)
945945
946- let hfs = tableHasFS thEnv
947- let hbio = tableHasBlockIO thEnv
948-
949946 -- We acquire a read-lock on the session open-state to prevent races, see
950947 -- 'sessionOpenTables'.
951948 withOpenSession cursorSession $ \ _ -> do
@@ -954,9 +951,8 @@ newCursor !offsetKey th = withOpenTable th $ \thEnv -> do
954951 allocTableContent reg (tableContent thEnv)
955952 cursorReaders <-
956953 allocateMaybeTemp reg
957- (Readers. new hfs hbio
958- offsetKey (Just (wb, wbblobs)) cursorRuns)
959- (Readers. close hfs hbio)
954+ (Readers. new offsetKey (Just (wb, wbblobs)) cursorRuns)
955+ Readers. close
960956 let cursorWBB = wbblobs
961957 cursorState <- newMVar (CursorOpen CursorEnv {.. })
962958 let ! cursor = Cursor {cursorState, cursorTracer}
@@ -997,9 +993,6 @@ closeCursor Cursor {..} = do
997993 modifyWithTempRegistry_ (takeMVar cursorState) (putMVar cursorState) $ \ reg -> \ case
998994 CursorClosed -> return CursorClosed
999995 CursorOpen CursorEnv {.. } -> do
1000- let hfs = sessionHasFS cursorSessionEnv
1001- let hbio = sessionHasBlockIO cursorSessionEnv
1002-
1003996 -- This should be safe-ish, but it's still not ideal, because it doesn't
1004997 -- rule out sync exceptions in the cleanup operations.
1005998 -- In that case, the cursor ends up closed, but resources might not have
@@ -1008,7 +1001,7 @@ closeCursor Cursor {..} = do
10081001 modifyMVar_ (sessionOpenCursors cursorSessionEnv) $
10091002 pure . Map. delete cursorId
10101003
1011- forM_ cursorReaders $ freeTemp reg . Readers. close hfs hbio
1004+ forM_ cursorReaders $ freeTemp reg . Readers. close
10121005 V. forM_ cursorRuns $ freeTemp reg . Run. removeReference
10131006 freeTemp reg (WBB. removeReference cursorWBB)
10141007 return CursorClosed
@@ -1067,9 +1060,7 @@ readCursorWhile resolve keyIsWanted n Cursor {..} fromEntry = do
10671060 -- a drained cursor will just return an empty vector
10681061 return (state, V. empty)
10691062 Just readers -> do
1070- let hfs = sessionHasFS (cursorSessionEnv cursorEnv)
1071- let hbio = sessionHasBlockIO (cursorSessionEnv cursorEnv)
1072- (vec, hasMore) <- readCursorEntriesWhile hfs hbio resolve keyIsWanted fromEntry readers n
1063+ (vec, hasMore) <- readCursorEntriesWhile resolve keyIsWanted fromEntry readers n
10731064 -- if we drained the readers, remove them from the state
10741065 let ! state' = case hasMore of
10751066 Readers. HasMore -> state
@@ -1078,12 +1069,10 @@ readCursorWhile resolve keyIsWanted n Cursor {..} fromEntry = do
10781069
10791070{-# INLINE readCursorEntriesWhile #-}
10801071{-# SPECIALISE readCursorEntriesWhile :: forall h res.
1081- HasFS IO h
1082- -> HasBlockIO IO h
1083- -> ResolveSerialisedValue
1072+ ResolveSerialisedValue
10841073 -> (SerialisedKey -> Bool)
10851074 -> (SerialisedKey -> SerialisedValue -> Maybe (WeakBlobRef IO (Handle h)) -> res)
1086- -> Readers.Readers IO (Handle h)
1075+ -> Readers.Readers IO h
10871076 -> Int
10881077 -> IO (V.Vector res, Readers.HasMore) #-}
10891078-- | General notes on the code below:
@@ -1094,15 +1083,13 @@ readCursorWhile resolve keyIsWanted n Cursor {..} fromEntry = do
10941083-- * there is probably opportunity for optimisations
10951084readCursorEntriesWhile :: forall h m res .
10961085 (MonadFix m , MonadMask m , MonadST m , MonadSTM m )
1097- => HasFS m h
1098- -> HasBlockIO m h
1099- -> ResolveSerialisedValue
1086+ => ResolveSerialisedValue
11001087 -> (SerialisedKey -> Bool )
11011088 -> (SerialisedKey -> SerialisedValue -> Maybe (WeakBlobRef m (Handle h )) -> res )
1102- -> Readers. Readers m ( Handle h )
1089+ -> Readers. Readers m h
11031090 -> Int
11041091 -> m (V. Vector res , Readers. HasMore )
1105- readCursorEntriesWhile hfs hbio resolve keyIsWanted fromEntry readers n =
1092+ readCursorEntriesWhile resolve keyIsWanted fromEntry readers n =
11061093 flip (V. unfoldrNM' n) Readers. HasMore $ \ case
11071094 Readers. Drained -> return (Nothing , Readers. Drained )
11081095 Readers. HasMore -> readEntryIfWanted
@@ -1117,7 +1104,7 @@ readCursorEntriesWhile hfs hbio resolve keyIsWanted fromEntry readers n =
11171104
11181105 readEntry :: m (Maybe res , Readers. HasMore )
11191106 readEntry = do
1120- (key, readerEntry, hasMore) <- Readers. pop hfs hbio readers
1107+ (key, readerEntry, hasMore) <- Readers. pop readers
11211108 let ! entry = Reader. toFullEntry readerEntry
11221109 case hasMore of
11231110 Readers. Drained -> do
@@ -1134,7 +1121,7 @@ readCursorEntriesWhile hfs hbio resolve keyIsWanted fromEntry readers n =
11341121
11351122 dropRemaining :: SerialisedKey -> m Readers. HasMore
11361123 dropRemaining key = do
1137- (_, hasMore) <- Readers. dropWhileKey hfs hbio readers key
1124+ (_, hasMore) <- Readers. dropWhileKey readers key
11381125 return hasMore
11391126
11401127 -- Resolve a 'Mupsert' value with the other entries of the same key.
@@ -1148,7 +1135,7 @@ readCursorEntriesWhile hfs hbio resolve keyIsWanted fromEntry readers n =
11481135 -- No more entries for same key, done.
11491136 handleResolved key (Entry. Mupdate v) Readers. HasMore
11501137 else do
1151- (_, nextEntry, hasMore) <- Readers. pop hfs hbio readers
1138+ (_, nextEntry, hasMore) <- Readers. pop readers
11521139 let resolved = Entry. combine resolve (Entry. Mupdate v)
11531140 (Reader. toFullEntry nextEntry)
11541141 case hasMore of
0 commit comments