Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Database.LSMTree.Internal.Run
Contents
Description
Runs of sorted key/value data.
Synopsis
- data Run m h = Run !NumEntries !(RefCounter m) !RunFsPaths !(Bloom SerialisedKey) !Index !(Handle h) !(Ref (BlobFile m h)) !RunDataCaching !(HasFS m h) !(HasBlockIO m h)
- data RunFsPaths
- size :: Ref (Run m h) -> NumEntries
- sizeInPages :: Ref (Run m h) -> NumPages
- runFsPaths :: Ref (Run m h) -> RunFsPaths
- runFsPathsNumber :: Ref (Run m h) -> RunNumber
- runDataCaching :: Ref (Run m h) -> RunDataCaching
- runIndexType :: Ref (Run m h) -> IndexType
- mkRawBlobRef :: Run m h -> BlobSpan -> RawBlobRef m h
- mkWeakBlobRef :: Ref (Run m h) -> BlobSpan -> WeakBlobRef m h
- newEmpty :: (MonadST m, MonadSTM m, MonadMask m) => HasFS m h -> HasBlockIO m h -> RunParams -> RunFsPaths -> m (Ref (Run m h))
- fromBuilder :: (MonadST m, MonadSTM m, MonadMask m) => RunBuilder m h -> m (Ref (Run m h))
- 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))
- data RunParams = RunParams {}
- openFromDisk :: forall m h. (MonadSTM m, MonadMask m, PrimMonad m) => HasFS m h -> HasBlockIO m h -> RunDataCaching -> IndexType -> RunFsPaths -> m (Ref (Run m h))
- data RunDataCaching
- data IndexType
Run
The in-memory representation of a completed LSM run.
Constructors
Run !NumEntries !(RefCounter m) !RunFsPaths !(Bloom SerialisedKey) !Index !(Handle h) !(Ref (BlobFile m h)) !RunDataCaching !(HasFS m h) !(HasBlockIO m h) |
Instances
RefCounted m (Run m h) Source # | |
Defined in Database.LSMTree.Internal.Run Methods getRefCounter :: Run m h -> RefCounter m Source # | |
Show (Run m h) Source # | Shows only the |
NFData h => NFData (Run m h) Source # | |
Defined in Database.LSMTree.Internal.Run |
data RunFsPaths Source #
The (relative) file path locations of all the files used by the run:
The following files exist for a run:
${n}.keyops
: the sorted run of key/operation pairs${n}.blobs
: the blob values associated with the key/operations${n}.filter
: a Bloom filter of all the keys in the run${n}.index
: an index from keys to disk page numbers${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
Show RunFsPaths Source # | |
Defined in Database.LSMTree.Internal.Paths Methods showsPrec :: Int -> RunFsPaths -> ShowS # show :: RunFsPaths -> String # showList :: [RunFsPaths] -> ShowS # | |
NFData RunFsPaths Source # | |
Defined in Database.LSMTree.Internal.Paths Methods rnf :: RunFsPaths -> () # |
runFsPaths :: Ref (Run m h) -> RunFsPaths Source #
runDataCaching :: Ref (Run m h) -> RunDataCaching Source #
See openFromDisk
runIndexType :: Ref (Run m h) -> IndexType Source #
See openFromDisk
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.
Constructors
RunParams | |
Fields |
Instances
Show RunParams Source # | |
NFData RunParams Source # | |
Defined in Database.LSMTree.Internal.RunBuilder | |
Eq RunParams Source # | |
DecodeVersioned RunParams Source # | |
Defined in Database.LSMTree.Internal.Snapshot.Codec Methods decodeVersioned :: SnapshotVersion -> Decoder s RunParams Source # | |
Encode RunParams Source # | |
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 RunDataCaching Source #
Should this run cache key/ops data in memory?
Constructors
CacheRunData | |
NoCacheRunData |
Instances
Show RunDataCaching Source # | |
Defined in Database.LSMTree.Internal.RunBuilder Methods showsPrec :: Int -> RunDataCaching -> ShowS # show :: RunDataCaching -> String # showList :: [RunDataCaching] -> ShowS # | |
NFData RunDataCaching Source # | |
Defined in Database.LSMTree.Internal.RunBuilder Methods rnf :: RunDataCaching -> () # | |
Eq RunDataCaching Source # | |
Defined in Database.LSMTree.Internal.RunBuilder Methods (==) :: RunDataCaching -> RunDataCaching -> Bool # (/=) :: RunDataCaching -> RunDataCaching -> Bool # | |
DecodeVersioned RunDataCaching Source # | |
Defined in Database.LSMTree.Internal.Snapshot.Codec Methods decodeVersioned :: SnapshotVersion -> Decoder s RunDataCaching Source # | |
Encode RunDataCaching Source # | |
Defined in Database.LSMTree.Internal.Snapshot.Codec Methods encode :: RunDataCaching -> Encoding Source # |
The type of supported index types.
Instances
Show IndexType Source # | |
NFData IndexType Source # | |
Defined in Database.LSMTree.Internal.Index | |
Eq IndexType Source # | |
DecodeVersioned IndexType Source # | |
Defined in Database.LSMTree.Internal.Snapshot.Codec Methods decodeVersioned :: SnapshotVersion -> Decoder s IndexType Source # | |
Encode IndexType Source # | |