diff --git a/src/journal/src/Journal.hs b/src/journal/src/Journal.hs index 2df13ed8..49d359d3 100644 --- a/src/journal/src/Journal.hs +++ b/src/journal/src/Journal.hs @@ -44,6 +44,7 @@ defaultOptions = Options 1024 (64 * 1024) allocateJournal :: FilePath -> Options -> IO () allocateJournal = undefined + -- System.Posix.Fcntl.fileAllocate startJournal' :: FilePath -> Options -> IO Journal' startJournal' fp (Options _ termLength) = do diff --git a/src/journal/src/Journal/Internal.hs b/src/journal/src/Journal/Internal.hs index 18d52c8f..5ac7508d 100644 --- a/src/journal/src/Journal/Internal.hs +++ b/src/journal/src/Journal/Internal.hs @@ -113,6 +113,7 @@ tryClaim jour len = do return (backPressureStatus position len) calculatePositionLimit = undefined +backPressureStatus = undefined newPosition :: Metadata -> Maybe TermOffset -> IO (Maybe Int64) newPosition meta mResultingOffset = @@ -139,8 +140,6 @@ newPosition meta mResultingOffset = rotateTerm meta return Nothing -- ADMIN_ACTION -backPressureStatus = undefined - fRAME_ALIGNMENT :: Int fRAME_ALIGNMENT = 32 @@ -223,7 +222,6 @@ commit = undefined abort = undefined - ------------------------------------------------------------------------ claim :: Journal -> Int -> IO Int diff --git a/src/journal/src/Journal/Internal/ByteBuffer.hs b/src/journal/src/Journal/Internal/ByteBuffer.hs index cb45aa1e..e72179c9 100644 --- a/src/journal/src/Journal/Internal/ByteBuffer.hs +++ b/src/journal/src/Journal/Internal/ByteBuffer.hs @@ -283,9 +283,14 @@ putLazyByteString bb lbs = do s' -> (# s', () #) getByteString :: ByteBuffer -> Int -> IO BS.ByteString -getByteString bb len = do - bytes <- replicateM len (getByte bb) - return (BS.packBytes bytes) +getByteString bb len@(I# len#) = do + boundCheck bb (len - 1) + Position (I# offset#) <- readPosition bb + bs <- BS.create len $ \(Ptr addr#) -> IO $ \s -> + case copyMutableByteArrayToAddr# (bbData bb) offset# addr# len# s of + s' -> (# s', () #) + incrPosition bb len + return bs getLazyByteString :: ByteBuffer -> Int -> IO LBS.ByteString getLazyByteString bb len = do