| Safe Haskell | Safe-Inferred | 
|---|---|
| Language | GHC2021 | 
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
- withRun :: HasFS IO h -> HasBlockIO IO h -> RefCtx -> Salt -> RunParams -> FsPath -> UniqCounter IO -> SerialisedRunData -> (Ref (Run IO h) -> IO a) -> IO a
 - withRunAt :: HasFS IO h -> HasBlockIO IO h -> RefCtx -> Salt -> RunParams -> RunFsPaths -> SerialisedRunData -> (Ref (Run IO h) -> IO a) -> IO a
 - withRuns :: HasFS IO h -> HasBlockIO IO h -> RefCtx -> Salt -> RunParams -> FsPath -> UniqCounter IO -> [SerialisedRunData] -> ([Ref (Run IO h)] -> IO a) -> IO a
 - unsafeCreateRun :: HasFS IO h -> HasBlockIO IO h -> RefCtx -> Salt -> RunParams -> FsPath -> UniqCounter IO -> SerialisedRunData -> IO (Ref (Run IO h))
 - unsafeCreateRunAt :: HasFS IO h -> HasBlockIO IO h -> RefCtx -> Salt -> RunParams -> RunFsPaths -> SerialisedRunData -> IO (Ref (Run IO h))
 - simplePath :: Int -> RunFsPaths
 - simplePaths :: [Int] -> [RunFsPaths]
 - withRunDataAsWriteBuffer :: HasFS IO h -> RefCtx -> ResolveSerialisedValue -> WriteBufferFsPaths -> SerialisedRunData -> (WriteBuffer -> Ref (WriteBufferBlobs IO h) -> IO a) -> IO a
 - withSerialisedWriteBuffer :: HasFS IO h -> HasBlockIO IO h -> WriteBufferFsPaths -> WriteBuffer -> Ref (WriteBufferBlobs IO h) -> IO a -> IO a
 - newtype RunData k v b = RunData {}
 - mapRunData :: Ord k' => (k -> k') -> (v -> v') -> (b -> b') -> RunData k v b -> RunData k' v' b'
 - type SerialisedRunData = RunData SerialisedKey SerialisedValue SerialisedBlob
 - serialiseRunData :: (SerialiseKey k, SerialiseValue v, SerialiseValue b) => RunData k v b -> SerialisedRunData
 - newtype NonEmptyRunData k v b = NonEmptyRunData {
- unNonEmptyRunData :: NEMap k (Entry v b)
 
 - nonEmptyRunData :: RunData k v b -> Maybe (NonEmptyRunData k v b)
 - toRunData :: NonEmptyRunData k v b -> RunData k v b
 - mapNonEmptyRunData :: Ord k' => (k -> k') -> (v -> v') -> (b -> b') -> NonEmptyRunData k v b -> NonEmptyRunData k' v' b'
 - type SerialisedNonEmptyRunData = NonEmptyRunData SerialisedKey SerialisedValue SerialisedBlob
 - labelRunData :: SerialisedRunData -> Property -> Property
 - labelNonEmptyRunData :: SerialisedNonEmptyRunData -> Property -> Property
 - genRunData :: Ord k => Gen k -> Gen v -> Gen b -> Gen (RunData k v b)
 - shrinkRunData :: Ord k => (k -> [k]) -> (v -> [v]) -> (b -> [b]) -> RunData k v b -> [RunData k v b]
 - genNonEmptyRunData :: Ord k => Gen k -> Gen v -> Gen b -> Gen (NonEmptyRunData k v b)
 - shrinkNonEmptyRunData :: Ord k => (k -> [k]) -> (v -> [v]) -> (b -> [b]) -> NonEmptyRunData k v b -> [NonEmptyRunData k v b]
 - liftArbitrary2Map :: Ord k => Gen k -> Gen v -> Gen (Map k v)
 - liftShrink2Map :: Ord k => (k -> [k]) -> (v -> [v]) -> Map k v -> [Map k v]
 
Create runs
withRun :: HasFS IO h -> HasBlockIO IO h -> RefCtx -> Salt -> 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 -> RefCtx -> Salt -> 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 -> RefCtx -> Salt -> 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 -> RefCtx -> Salt -> 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 -> RefCtx -> Salt -> 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
withRunDataAsWriteBuffer :: HasFS IO h -> RefCtx -> ResolveSerialisedValue -> WriteBufferFsPaths -> SerialisedRunData -> (WriteBuffer -> Ref (WriteBufferBlobs IO h) -> IO a) -> IO a Source #
Use SerialisedRunData to WriteBuffer and WriteBufferBlobs.
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.
mapRunData :: Ord k' => (k -> k') -> (v -> v') -> (b -> b') -> RunData k v b -> RunData k' v' b' Source #
serialiseRunData :: (SerialiseKey k, SerialiseValue v, SerialiseValue b) => RunData k v b -> SerialisedRunData 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
| (Ord k, Arbitrary k, Arbitrary v, Arbitrary b) => Arbitrary (NonEmptyRunData k v b) Source # | |
Defined in Database.LSMTree.Extras.RunData Methods arbitrary :: Gen (NonEmptyRunData k v b) Source # shrink :: NonEmptyRunData k v b -> [NonEmptyRunData k v b] Source #  | |
| (Show k, Show b, Show v) => Show (NonEmptyRunData k v b) Source # | |
Defined in Database.LSMTree.Extras.RunData Methods showsPrec :: Int -> NonEmptyRunData k v b -> ShowS # show :: NonEmptyRunData k v b -> String # showList :: [NonEmptyRunData k v b] -> ShowS #  | |
| (Eq k, Eq b, Eq v) => Eq (NonEmptyRunData k v b) Source # | |
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 #  | |
nonEmptyRunData :: RunData k v b -> Maybe (NonEmptyRunData k v b) Source #
toRunData :: NonEmptyRunData k v b -> RunData k v b Source #
mapNonEmptyRunData :: Ord k' => (k -> k') -> (v -> v') -> (b -> b') -> NonEmptyRunData k v b -> NonEmptyRunData k' v' b' Source #
type SerialisedNonEmptyRunData = NonEmptyRunData SerialisedKey SerialisedValue SerialisedBlob Source #
QuickCheck
labelRunData :: SerialisedRunData -> Property -> Property 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.