lsm-tree-0.1.0.0: Log-structured merge-trees
Safe HaskellSafe-Inferred
LanguageGHC2021

Database.LSMTree.Internal.Chunk

Contents

Description

Chunks of bytes, typically output during incremental index serialisation.

Synopsis

Chunks

newtype Chunk Source #

A chunk of bytes, typically output during incremental index serialisation.

Constructors

Chunk (Vector Word8) 

Instances

Instances details
Show Chunk Source # 
Instance details

Defined in Database.LSMTree.Internal.Chunk

Methods

showsPrec :: Int -> Chunk -> ShowS #

show :: Chunk -> String #

showList :: [Chunk] -> ShowS #

Eq Chunk Source # 
Instance details

Defined in Database.LSMTree.Internal.Chunk

Methods

(==) :: Chunk -> Chunk -> Bool #

(/=) :: Chunk -> Chunk -> Bool #

toByteVector :: Chunk -> Vector Word8 Source #

Yields the contents of a chunk as a byte vector.

toByteString :: Chunk -> ByteString Source #

Yields the contents of a chunk as a (strict) byte string.

Balers

data Baler s Source #

An object that receives blocks of bytes and repackages them into chunks such that all chunks except for a possible remnant chunk at the end are of at least a given minimum size.

Constructors

Baler !(MVector s Word8) !(PrimVar s Int) 

createBaler Source #

Arguments

:: Int

Minimum chunk size in bytes

-> ST s (Baler s)

Creation of the baler

Creates a new baler.

feedBaler :: forall s. [Vector Word8] -> Baler s -> ST s (Maybe Chunk) Source #

Feeds a baler blocks of bytes.

Bytes received by a baler are generally queued for later output, but if feeding new bytes makes the accumulated content exceed the minimum chunk size then a chunk containing all the accumulated content is output.

unsafeEndBaler :: forall s. Baler s -> ST s (Maybe Chunk) Source #

Returns the bytes still queued in a baler, if any, thereby invalidating the baler. Executing unsafeEndBaler baler is only safe when baler is not used afterwards.