Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Database.LSMTree.Internal.Lookup
Synopsis
- type LookupAcc m h = Vector (Maybe (Entry SerialisedValue (WeakBlobRef m h)))
- lookupsIOWithWriteBuffer :: forall m h. (MonadThrow m, MonadST m) => HasBlockIO m h -> ArenaManager (PrimState m) -> ResolveSerialisedValue -> WriteBuffer -> Ref (WriteBufferBlobs m h) -> Vector (Ref (Run m h)) -> Vector (Bloom SerialisedKey) -> Vector Index -> Vector (Handle h) -> Vector SerialisedKey -> m (LookupAcc m h)
- lookupsIO :: forall m h. (MonadThrow m, MonadST m) => HasBlockIO m h -> ArenaManager (PrimState m) -> ResolveSerialisedValue -> Vector (Ref (Run m h)) -> Vector (Bloom SerialisedKey) -> Vector Index -> Vector (Handle h) -> Vector SerialisedKey -> m (LookupAcc m h)
- data TableCorruptedError = ErrLookupByteCountDiscrepancy !ByteCount !ByteCount
- type RunIx = Int
- type KeyIx = Int
- data RunIxKeyIx where
- 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))
- bloomQueries :: Vector (Bloom SerialisedKey) -> Vector SerialisedKey -> Vector RunIxKeyIx
- indexSearches :: Arena s -> Vector Index -> Vector (Handle h) -> Vector SerialisedKey -> Vector RunIxKeyIx -> ST s (Vector (IOOp s h))
- 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)
- 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)
Documentation
type LookupAcc m h = Vector (Maybe (Entry SerialisedValue (WeakBlobRef m h))) Source #
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 |
-> Vector (Bloom SerialisedKey) | The bloom filters inside |
-> Vector Index | The indexes inside |
-> Vector (Handle h) | The file handles to the key/value files inside |
-> Vector SerialisedKey | |
-> m (LookupAcc m h) |
Like lookupsIO
, but takes a write buffer into account.
Arguments
:: forall m h. (MonadThrow m, MonadST m) | |
=> HasBlockIO m h | |
-> ArenaManager (PrimState m) | |
-> ResolveSerialisedValue | |
-> Vector (Ref (Run m h)) | Runs |
-> Vector (Bloom SerialisedKey) | The bloom filters inside |
-> Vector Index | The indexes inside |
-> Vector (Handle h) | The file handles to the key/value files inside |
-> 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
data TableCorruptedError Source #
The table data is corrupted.
Constructors
ErrLookupByteCountDiscrepancy | |
Instances
Exception TableCorruptedError Source # | |
Defined in Database.LSMTree.Internal.Lookup Methods toException :: TableCorruptedError -> SomeException # fromException :: SomeException -> Maybe TableCorruptedError # | |
Show TableCorruptedError Source # | |
Defined in Database.LSMTree.Internal.Lookup Methods showsPrec :: Int -> TableCorruptedError -> ShowS # show :: TableCorruptedError -> String # showList :: [TableCorruptedError] -> ShowS # | |
Eq TableCorruptedError Source # | |
Defined in Database.LSMTree.Internal.Lookup Methods (==) :: TableCorruptedError -> TableCorruptedError -> Bool # (/=) :: TableCorruptedError -> TableCorruptedError -> Bool # |
Internal: exposed for tests and benchmarks
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 |
Instances
prepLookups :: Arena s -> Vector (Bloom SerialisedKey) -> Vector Index -> Vector (Handle h) -> Vector SerialisedKey -> ST s (Vector RunIxKeyIx, Vector (IOOp s h)) Source #
bloomQueries :: Vector (Bloom SerialisedKey) -> Vector SerialisedKey -> Vector RunIxKeyIx Source #
Perform a batch of bloom queries. The result is a tuple of indexes into the vector of runs and vector of keys respectively. The order of keys and runs/filters in the input is maintained in the output. This implementation produces results in key-major order.
The result vector can be of variable length. The initial estimate is 2x the number of keys but this is grown if needed (using a doubling strategy).
Arguments
:: Arena s | |
-> Vector Index | |
-> Vector (Handle h) | |
-> Vector SerialisedKey | |
-> Vector RunIxKeyIx | Result of |
-> 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.