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

Database.LSMTree.Internal.RunReaders

Contents

Synopsis

Documentation

data Readers m h Source #

A collection of runs and write buffers being read from, yielding elements in order. More precisely, that means first ordered by their key, then by the input run they came from. This is important for resolving multiple entries with the same key into one.

Construct with new, then keep calling pop. If aborting early, remember to call close!

Creating a Readers does not retain a reference to the input Runs or the WriteBufferBlobs, but does retain an independent reference on their blob files. It is not necessary to separately retain the Runs or the WriteBufferBlobs for correct use of the Readers. There is one important caveat however: to preserve the validity of BlobRefs then it is necessary to separately retain a reference to the Run or its BlobFile to preserve the validity of BlobRefs.

TODO: do this more nicely by changing Reader to preserve the BlobFile ref until it is explicitly closed, and also retain the BlobFile from the WBB and release all of these BlobFiles once the Readers is itself closed.

Constructors

Readers 

Fields

new :: forall m h. (MonadMask m, MonadST m, MonadSTM m) => OffsetKey -> Maybe (WriteBuffer, Ref (WriteBufferBlobs m h)) -> Vector (Ref (Run m h)) -> m (Maybe (Readers m h)) Source #

close :: (MonadMask m, MonadSTM m, PrimMonad m) => Readers m h -> m () Source #

Only call when aborting before all readers have been drained.

data HasMore Source #

Once a function returned Drained, do not use the Readers any more!

Constructors

HasMore 
Drained 

Instances

Instances details
Show HasMore Source # 
Instance details

Defined in Database.LSMTree.Internal.RunReaders

Eq HasMore Source # 
Instance details

Defined in Database.LSMTree.Internal.RunReaders

Methods

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

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

dropWhileKey Source #

Arguments

:: (MonadMask m, MonadSTM m, MonadST m) 
=> Readers m h 
-> SerialisedKey 
-> m (Int, HasMore)

How many were dropped?

Internals

data Reader m h Source #

Constructors

ReadRun !(RunReader m h) 
ReadBuffer !(MutVar (PrimState m) [KOp m h]) 

data ReadCtx m h Source #

Each heap element needs some more context than just the reader. E.g. the Eq instance we need to be able to access the first key to be read in a pure way.

TODO(optimisation): We allocate this record for each k/op. This might be avoidable, see ideas below.

Instances

Instances details
Eq (ReadCtx m h) Source # 
Instance details

Defined in Database.LSMTree.Internal.RunReaders

Methods

(==) :: ReadCtx m h -> ReadCtx m h -> Bool #

(/=) :: ReadCtx m h -> ReadCtx m h -> Bool #

Ord (ReadCtx m h) Source #

Makes sure we resolve entries in the right order.

Instance details

Defined in Database.LSMTree.Internal.RunReaders

Methods

compare :: ReadCtx m h -> ReadCtx m h -> Ordering #

(<) :: ReadCtx m h -> ReadCtx m h -> Bool #

(<=) :: ReadCtx m h -> ReadCtx m h -> Bool #

(>) :: ReadCtx m h -> ReadCtx m h -> Bool #

(>=) :: ReadCtx m h -> ReadCtx m h -> Bool #

max :: ReadCtx m h -> ReadCtx m h -> ReadCtx m h #

min :: ReadCtx m h -> ReadCtx m h -> ReadCtx m h #