Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Database.LSMTree.Internal.RunBuilder
Description
A mutable run (RunBuilder
) that is under construction.
Synopsis
- data RunBuilder m h = RunBuilder {
- runBuilderParams :: !RunParams
- runBuilderFsPaths :: !RunFsPaths
- runBuilderAcc :: !(RunAcc (PrimState m))
- runBuilderBlobOffset :: !(PrimVar (PrimState m) Word64)
- runBuilderHandles :: !(ForRunFiles (ChecksumHandle (PrimState m) h))
- runBuilderHasFS :: !(HasFS m h)
- runBuilderHasBlockIO :: !(HasBlockIO m h)
- data RunParams = RunParams {}
- data RunDataCaching
- data RunBloomFilterAlloc
- data IndexType
- new :: (MonadST m, MonadSTM m) => HasFS m h -> HasBlockIO m h -> RunParams -> RunFsPaths -> NumEntries -> m (RunBuilder m h)
- addKeyOp :: (MonadST m, MonadSTM m, MonadThrow m) => RunBuilder m h -> SerialisedKey -> Entry SerialisedValue (RawBlobRef m h) -> m ()
- addLargeSerialisedKeyOp :: (MonadST m, MonadSTM m) => RunBuilder m h -> SerialisedKey -> RawPage -> [RawOverflowPage] -> m ()
- unsafeFinalise :: (MonadST m, MonadSTM m, MonadThrow m) => RunBuilder m h -> m (HasFS m h, HasBlockIO m h, RunFsPaths, Bloom SerialisedKey, Index, RunParams, NumEntries)
- close :: MonadSTM m => RunBuilder m h -> m ()
Documentation
data RunBuilder m h Source #
The in-memory representation of an LSM run that is under construction. (The "M" stands for mutable.) This is the output sink for two key algorithms: 1. writing out the write buffer, and 2. incrementally merging two or more runs.
It contains open file handles for all four files used in the disk representation of a run. Each file handle is opened write-only and should be written to using normal buffered I/O.
Not suitable for concurrent construction from multiple threads!
Constructors
RunBuilder | |
Fields
|
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 # | |
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 # |
data RunBloomFilterAlloc Source #
See BloomFilterAlloc
Constructors
RunAllocFixed !Word64 | Bits per element in a filter |
RunAllocRequestFPR !Double |
Instances
Show RunBloomFilterAlloc Source # | |
Defined in Database.LSMTree.Internal.RunAcc Methods showsPrec :: Int -> RunBloomFilterAlloc -> ShowS # show :: RunBloomFilterAlloc -> String # showList :: [RunBloomFilterAlloc] -> ShowS # | |
NFData RunBloomFilterAlloc Source # | |
Defined in Database.LSMTree.Internal.RunAcc Methods rnf :: RunBloomFilterAlloc -> () # | |
Eq RunBloomFilterAlloc Source # | |
Defined in Database.LSMTree.Internal.RunAcc Methods (==) :: RunBloomFilterAlloc -> RunBloomFilterAlloc -> Bool # (/=) :: RunBloomFilterAlloc -> RunBloomFilterAlloc -> Bool # | |
DecodeVersioned RunBloomFilterAlloc Source # | |
Defined in Database.LSMTree.Internal.Snapshot.Codec Methods decodeVersioned :: SnapshotVersion -> Decoder s RunBloomFilterAlloc Source # | |
Encode RunBloomFilterAlloc Source # | |
Defined in Database.LSMTree.Internal.Snapshot.Codec Methods encode :: RunBloomFilterAlloc -> 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 # | |
Arguments
:: (MonadST m, MonadSTM m) | |
=> HasFS m h | |
-> HasBlockIO m h | |
-> RunParams | |
-> RunFsPaths | |
-> NumEntries | an upper bound of the number of entries to be added |
-> m (RunBuilder m h) |
Create an RunBuilder
to start building a run.
NOTE: new
assumes that runDir
that the run is created in exists.
addKeyOp :: (MonadST m, MonadSTM m, MonadThrow m) => RunBuilder m h -> SerialisedKey -> Entry SerialisedValue (RawBlobRef m h) -> m () Source #
Add a key/op pair.
In the InsertWithBlob
case, the RawBlobRef
identifies where the blob can be
found (which is either from a write buffer or another run). The blobs will
be copied from their existing blob file into the new run's blob file.
Use only for entries that are fully in-memory (other than any blob).
To handle larger-than-page values in a chunked style during run merging,
use addLargeSerialisedKeyOp
.
The k/ops and the primary array of the index get written incrementally,
everything else only at the end when unsafeFinalise
is called.
addLargeSerialisedKeyOp :: (MonadST m, MonadSTM m) => RunBuilder m h -> SerialisedKey -> RawPage -> [RawOverflowPage] -> m () Source #
See addLargeSerialisedKeyOp
for details.
unsafeFinalise :: (MonadST m, MonadSTM m, MonadThrow m) => RunBuilder m h -> m (HasFS m h, HasBlockIO m h, RunFsPaths, Bloom SerialisedKey, Index, RunParams, NumEntries) Source #
Finish construction of the run. Writes the filter and index to file and leaves all written files on disk.
Do not use the RunBuilder
after calling this function!
TODO: Ensure proper cleanup even in presence of exceptions.
close :: MonadSTM m => RunBuilder m h -> m () Source #
Close a run that is being constructed (has not been finalised yet), removing all files associated with it from disk. After calling this operation, the run must not be used anymore.
TODO: Ensure proper cleanup even in presence of exceptions.