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

Database.LSMTree.Extras.RunData

Description

Utilities for generating collections of key/value pairs, and creating runs from them. Tests and benchmarks should preferably use these utilities instead of (re-)defining their own.

Synopsis

Create runs

withRun :: HasFS IO h -> HasBlockIO IO h -> RunParams -> FsPath -> UniqCounter IO -> SerialisedRunData -> (Ref (Run IO h) -> IO a) -> IO a Source #

Create a temporary Run using unsafeCreateRun.

withRunAt :: HasFS IO h -> HasBlockIO IO h -> RunParams -> RunFsPaths -> SerialisedRunData -> (Ref (Run IO h) -> IO a) -> IO a Source #

Create a temporary Run using unsafeCreateRunAt.

withRuns :: HasFS IO h -> HasBlockIO IO h -> RunParams -> FsPath -> UniqCounter IO -> [SerialisedRunData] -> ([Ref (Run IO h)] -> IO a) -> IO a Source #

Create temporary Runs using unsafeCreateRun.

unsafeCreateRun :: HasFS IO h -> HasBlockIO IO h -> RunParams -> FsPath -> UniqCounter IO -> SerialisedRunData -> IO (Ref (Run IO h)) Source #

Like unsafeCreateRunAt, but uses a UniqCounter to determine the RunFsPaths, at a base file path.

unsafeCreateRunAt :: HasFS IO h -> HasBlockIO IO h -> RunParams -> RunFsPaths -> SerialisedRunData -> IO (Ref (Run IO h)) Source #

Flush serialised run data to disk as if it were a write buffer.

This might leak resources if not run with asynchronous exceptions masked. Use helper functions like withRun or withRuns instead.

Use of this function should be paired with a releaseRef.

simplePath :: Int -> RunFsPaths Source #

Create a RunFsPaths using an empty FsPath. The empty path corresponds to the "root" or "mount point" of a HasFS instance.

simplePaths :: [Int] -> [RunFsPaths] Source #

Like simplePath, but for a list.

Serialise write buffers

withSerialisedWriteBuffer :: HasFS IO h -> HasBlockIO IO h -> WriteBufferFsPaths -> WriteBuffer -> Ref (WriteBufferBlobs IO h) -> IO a -> IO a Source #

Serialise a WriteBuffer and WriteBufferBlobs to disk and perform an IO action.

RunData

newtype RunData k v b Source #

A collection of arbitrary key/value pairs that are suitable for creating Runs.

Note: 'b ~ Void' should rule out blobs.

Constructors

RunData 

Fields

Instances

Instances details
(Ord k, Arbitrary k, Arbitrary v, Arbitrary b) => Arbitrary (RunData k v b) Source # 
Instance details

Defined in Database.LSMTree.Extras.RunData

Methods

arbitrary :: Gen (RunData k v b) Source #

shrink :: RunData k v b -> [RunData k v b] Source #

(Show k, Show b, Show v) => Show (RunData k v b) Source # 
Instance details

Defined in Database.LSMTree.Extras.RunData

Methods

showsPrec :: Int -> RunData k v b -> ShowS #

show :: RunData k v b -> String #

showList :: [RunData k v b] -> ShowS #

(Eq k, Eq b, Eq v) => Eq (RunData k v b) Source # 
Instance details

Defined in Database.LSMTree.Extras.RunData

Methods

(==) :: RunData k v b -> RunData k v b -> Bool #

(/=) :: RunData k v b -> RunData k v b -> Bool #

mapRunData :: Ord k' => (k -> k') -> (v -> v') -> (b -> b') -> RunData k v b -> RunData k' v' b' Source #

NonEmptyRunData

newtype NonEmptyRunData k v b Source #

A collection of arbitrary key/value pairs that are suitable for creating Runs.

Note: 'b ~ Void' should rule out blobs.

Constructors

NonEmptyRunData 

Fields

Instances

Instances details
(Ord k, Arbitrary k, Arbitrary v, Arbitrary b) => Arbitrary (NonEmptyRunData k v b) Source # 
Instance details

Defined in Database.LSMTree.Extras.RunData

(Show k, Show b, Show v) => Show (NonEmptyRunData k v b) Source # 
Instance details

Defined in Database.LSMTree.Extras.RunData

(Eq k, Eq b, Eq v) => Eq (NonEmptyRunData k v b) Source # 
Instance details

Defined in Database.LSMTree.Extras.RunData

Methods

(==) :: NonEmptyRunData k v b -> NonEmptyRunData k v b -> Bool #

(/=) :: NonEmptyRunData k v b -> NonEmptyRunData k v b -> Bool #

mapNonEmptyRunData :: Ord k' => (k -> k') -> (v -> v') -> (b -> b') -> NonEmptyRunData k v b -> NonEmptyRunData k' v' b' Source #

QuickCheck

genRunData :: Ord k => Gen k -> Gen v -> Gen b -> Gen (RunData k v b) Source #

shrinkRunData :: Ord k => (k -> [k]) -> (v -> [v]) -> (b -> [b]) -> RunData k v b -> [RunData k v b] Source #

genNonEmptyRunData :: Ord k => Gen k -> Gen v -> Gen b -> Gen (NonEmptyRunData k v b) Source #

shrinkNonEmptyRunData :: Ord k => (k -> [k]) -> (v -> [v]) -> (b -> [b]) -> NonEmptyRunData k v b -> [NonEmptyRunData k v b] Source #

liftArbitrary2Map :: Ord k => Gen k -> Gen v -> Gen (Map k v) Source #

We cannot implement Arbitrary2 since we have constraints on k.

liftShrink2Map :: Ord k => (k -> [k]) -> (v -> [v]) -> Map k v -> [Map k v] Source #

We cannot implement Arbitrary2 since we have constraints k.