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

Database.LSMTree.Internal.Lookup

Synopsis

Documentation

type ResolveSerialisedValue = SerialisedValue -> SerialisedValue -> SerialisedValue Source #

Value resolve function: what to do when resolving two Mupdates

lookupsIOWithWriteBuffer Source #

Arguments

:: forall m h. (MonadThrow m, MonadST m) 
=> HasBlockIO m h 
-> ArenaManager (PrimState m) 
-> ResolveSerialisedValue 
-> WriteBuffer 
-> Ref (WriteBufferBlobs m h) 
-> Vector (Ref (Run m h))

Runs rs

-> Vector (Bloom SerialisedKey)

The bloom filters inside rs

-> Vector Index

The indexes inside rs

-> Vector (Handle h)

The file handles to the key/value files inside rs

-> Vector SerialisedKey 
-> m (LookupAcc m h) 

Like lookupsIO, but takes a write buffer into account.

lookupsIO Source #

Arguments

:: forall m h. (MonadThrow m, MonadST m) 
=> HasBlockIO m h 
-> ArenaManager (PrimState m) 
-> ResolveSerialisedValue 
-> Vector (Ref (Run m h))

Runs rs

-> Vector (Bloom SerialisedKey)

The bloom filters inside rs

-> Vector Index

The indexes inside rs

-> Vector (Handle h)

The file handles to the key/value files inside rs

-> Vector SerialisedKey 
-> m (LookupAcc m h) 

Batched lookups in I/O.

PRECONDITION: the vectors of bloom filters, indexes and file handles should pointwise match with the vectors of runs.

Errors

Internal: exposed for tests and benchmarks

type RunIx = Int Source #

type KeyIx = Int Source #

data RunIxKeyIx where Source #

A RunIxKeyIx is a (compact) pair of a RunIx and a KeyIx.

We represent it as a 32bit word, using:

  • 16 bits for the run/filter index (MSB)
  • 16 bits for the key index (LSB)

Bundled Patterns

pattern RunIxKeyIx :: RunIx -> KeyIx -> RunIxKeyIx 

prepLookups :: Arena s -> Vector (Bloom SerialisedKey) -> Vector Index -> Vector (Handle h) -> Vector SerialisedKey -> ST s (Vector RunIxKeyIx, Vector (IOOp s h)) Source #

Prepare disk lookups by doing bloom filter queries, index searches and creating IOOps. The result is a vector of IOOps and a vector of indexes, both of which are the same length. The indexes record the run and key associated with each IOOp.

indexSearches Source #

Arguments

:: Arena s 
-> Vector Index 
-> Vector (Handle h) 
-> Vector SerialisedKey 
-> Vector RunIxKeyIx

Result of bloomQueries

-> ST s (Vector (IOOp s h)) 

Perform a batch of fence pointer index searches, and create an IOOp for each search result. The resulting vector has the same length as the VP.Vector RunIxKeyIx argument, because index searching always returns a positive search result.

intraPageLookupsWithWriteBuffer :: forall m h. (PrimMonad m, MonadThrow m) => ResolveSerialisedValue -> WriteBuffer -> Ref (WriteBufferBlobs m h) -> Vector (Ref (Run m h)) -> Vector SerialisedKey -> Vector RunIxKeyIx -> Vector (IOOp (PrimState m) h) -> Vector IOResult -> m (LookupAcc m h) Source #

Like intraPageLookupsOn, but uses the write buffer as the initial accumulator.

intraPageLookupsOn :: forall m h. (PrimMonad m, MonadThrow m) => ResolveSerialisedValue -> LookupAcc m h -> Vector (Ref (Run m h)) -> Vector SerialisedKey -> Vector RunIxKeyIx -> Vector (IOOp (PrimState m) h) -> Vector IOResult -> m (LookupAcc m h) Source #

Intra-page lookups, and combining lookup results from multiple runs and a potential initial accumulator (e.g. from the write buffer).

This function assumes that rkixs is ordered such that newer runs are handled first. The order matters for resolving cases where we find the same key in multiple runs.