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

Database.LSMTree.Internal.Run

Description

Runs of sorted key/value data.

Synopsis

Run

data Run m h Source #

The in-memory representation of a completed LSM run.

Instances

Instances details
RefCounted m (Run m h) Source # 
Instance details

Defined in Database.LSMTree.Internal.Run

Methods

getRefCounter :: Run m h -> RefCounter m Source #

Show (Run m h) Source #

Shows only the runRunFsPaths field.

Instance details

Defined in Database.LSMTree.Internal.Run

Methods

showsPrec :: Int -> Run m h -> ShowS #

show :: Run m h -> String #

showList :: [Run m h] -> ShowS #

NFData h => NFData (Run m h) Source # 
Instance details

Defined in Database.LSMTree.Internal.Run

Methods

rnf :: Run m h -> () #

data RunFsPaths Source #

The (relative) file path locations of all the files used by the run:

The following files exist for a run:

  1. ${n}.keyops: the sorted run of key/operation pairs
  2. ${n}.blobs: the blob values associated with the key/operations
  3. ${n}.filter: a Bloom filter of all the keys in the run
  4. ${n}.index: an index from keys to disk page numbers
  5. ${n}.checksums: a file listing the crc32c checksums of the other files

The representation doesn't store the full, name, just the number n. Use the accessor functions to get the actual names.

Instances

Instances details
Show RunFsPaths Source # 
Instance details

Defined in Database.LSMTree.Internal.Paths

NFData RunFsPaths Source # 
Instance details

Defined in Database.LSMTree.Internal.Paths

Methods

rnf :: RunFsPaths -> () #

mkRawBlobRef :: Run m h -> BlobSpan -> RawBlobRef m h Source #

Helper function to make a WeakBlobRef that points into a Run.

mkWeakBlobRef :: Ref (Run m h) -> BlobSpan -> WeakBlobRef m h Source #

Helper function to make a WeakBlobRef that points into a Run.

Run creation

newEmpty :: (MonadST m, MonadSTM m, MonadMask m) => HasFS m h -> HasBlockIO m h -> RunParams -> RunFsPaths -> m (Ref (Run m h)) Source #

This function should be run with asynchronous exceptions masked to prevent failing after internal resources have already been created.

fromBuilder :: (MonadST m, MonadSTM m, MonadMask m) => RunBuilder m h -> m (Ref (Run m h)) Source #

fromWriteBuffer :: (MonadST m, MonadSTM m, MonadMask m) => HasFS m h -> HasBlockIO m h -> RunParams -> RunFsPaths -> WriteBuffer -> Ref (WriteBufferBlobs m h) -> m (Ref (Run m h)) Source #

Write a write buffer to disk, including the blobs it contains.

This creates a new Run which must eventually be released with releaseRef.

TODO: As a possible optimisation, blobs could be written to a blob file immediately when they are added to the write buffer, avoiding the need to do it here.

This function should be run with asynchronous exceptions masked to prevent failing after internal resources have already been created.

Snapshot

openFromDisk :: forall m h. (MonadSTM m, MonadMask m, PrimMonad m) => HasFS m h -> HasBlockIO m h -> RunDataCaching -> IndexType -> RunFsPaths -> m (Ref (Run m h)) Source #

Load a previously written run from disk, checking each file's checksum against the checksum file.

This creates a new Run which must eventually be released with releaseRef.

Exceptions will be raised when any of the file's contents don't match their checksum (ChecksumError) or can't be parsed (FileFormatError).

The RunDataCaching and IndexType parameters need to be saved and restored separately because these are not stored in the on-disk representation. Use runDataCaching and runIndexType to obtain these parameters from the open run before persisting to disk.

TODO: it may make more sense to persist these parameters with the run's on-disk representation.

data IndexType Source #

The type of supported index types.

Constructors

Compact 
Ordinary