Modulelsm-tree-1.1.1.0
Database.LSMTree
Synopsis
- value defaultTableConfig
- value noTableConfigOverride
- value isValidSnapshotName
- value toSnapshotName
- value packSlice
- value serialiseKeyIdentity
- value serialiseKeyIdentityUpToSlicing
- value serialiseKeyPreservesOrdering
- value serialiseValueIdentity
- value serialiseValueIdentityUpToSlicing
- value resolveAssociativity
- value resolveCompatibility
- value resolveValidOutput
- value closeCursor
- value closeSession
- value closeTable
- value delete
- value deleteSnapshot
- value deletes
- value doesSnapshotExist
- value duplicate
- value exportSnapshot
- value getBlob
- value getEntryBlob
- value getEntryKey
- value getEntryValue
- value getValue
- value importSnapshot
- value incrementalUnion
- value incrementalUnions
- value insert
- value inserts
- value listSnapshots
- value lookup
- value lookups
- value member
- value members
- value newCursor
- value newCursorAtOffset
- value newSession
- value newTable
- value newTableWith
- value next
- value openSession
- value openTableFromSnapshot
- value openTableFromSnapshotWith
- value rangeLookup
- value remainingUnionDebt
- value restoreSession
- value retrieveBlob
- value retrieveBlobs
- value saveSnapshot
- value supplyUnionCredits
- value take
- value takeWhile
- value union
- value unions
- value update
- value updates
- value upsert
- value upserts
- value withCursor
- value withCursorAtOffset
- value withDuplicate
- value withIncrementalUnion
- value withIncrementalUnions
- value withNewSession
- value withOpenMountedSessionIO
- value withOpenSession
- value withOpenSessionIO
- value withRestoreSession
- value withTable
- value withTableFromSnapshot
- value withTableFromSnapshotWith
- value withTableWith
- value withUnion
- value withUnions
- newtype Tracer
- data BloomFilterAlloc
- data DiskCachePolicy
- data FencePointerIndexType
- newtype MergeBatchSize
- data MergePolicy
- data MergeSchedule
- data SizeRatio
- data TableConfig
- value confBloomFilterAlloc
- value confDiskCachePolicy
- value confFencePointerIndex
- value confMergeBatchSize
- value confMergePolicy
- value confMergeSchedule
- value confSizeRatio
- value confWriteBufferAlloc
- data WriteBufferAlloc
- data TableConfigOverride
- data TableCorruptedError
- data TableTooLargeError
- data InvalidSnapshotNameError
- newtype SnapshotName
- data Range
- newtype RawBytes
- newtype CursorId
- newtype TableId
- class SerialiseKey
- class SerialiseKeyOrderPreserving
- class SerialiseValue
- newtype SnapshotLabel
- data BlobRef
- data Cursor
- newtype ResolveAsFirst
- class ResolveValue
- newtype ResolveViaSemigroup
- type Salt
- data Session
- data Table
- data BlobRefInvalidError
- data CursorClosedError
- data CursorTrace
- data LSMTreeTrace
- data SessionClosedError
- data SessionDirCorruptedError
- data SessionDirDoesNotExistError
- data SessionDirLockedError
- newtype SessionId
- data SessionTrace
- data SnapshotCorruptedError
- data SnapshotDoesNotExistError
- data SnapshotExistsError
- data SnapshotExportDirExistsError
- data SnapshotImportDirDoesNotExistError
- data SnapshotNotCompatibleError
- data TableClosedError
- data TableTrace
- data TableUnionNotCompatibleError
- newtype UnionCredits
- newtype UnionDebt
- data Entry
- type IOLike
- data LookupResult
- data Update
- Packagelsm-tree-1.1.1.0
- Exports141
- LicenceApache-2.0
- SourceTracer.hs
Deprecated. withOpenSessionIO is not compatible with importSnapshot and exportSnapshot. Use withOpenMountedSessionIO instead.
This type describes some effect in m which depends upon some value of
type a, for which the output value is not of interest (only the effects).
The motivating use case is to describe tracing, logging, monitoring, and similar features, in which the programmer wishes to provide some values to some other program which will do some real world side effect, such as writing to a log file or bumping a counter in some monitoring system.
The actual implementation of such a program will probably work on rather
large, domain-agnostic types like Text, ByteString, JSON values for
structured logs, etc.
But the call sites which ultimately invoke these implementations will deal with smaller, domain-specific types that concisely describe events, metrics, debug information, etc.
This difference is reconciled by the Contravariant instance for Tracer. contramap is used to change the input type of a tracer. This allows for a more general tracer to be used where a more specific one is expected.
Intuitively: if you can map your domain-specific type Event to a Text
representation, then any Tracer m Text can stand in where a
Tracer m Event is required.
eventToText :: Event -> Text
traceTextToLogFile :: Tracer m Text
traceEventToLogFile :: Tracer m Event
traceEventToLogFile = contramap eventToText traceTextToLogFileEffectful tracers that actually do interesting stuff can be defined
using emit, and composed via contramap.
The nullTracer can be used as a stand-in for any tracer, doing no side-effects and producing no interesting value.
To deal with branching, the arrow interface on the underlying Tracer should be used. Arrow notation can be helpful here.
For example, a common pattern is to trace only some variants of a sum type.
data Event = This Int | That Bool
traceOnlyThat :: Tracer m Int -> Tracer m Bool
traceOnlyThat tr = Tracer $ proc event -> do
case event of
This i -> use tr -< i
That _ -> squelch -< ()The key point of using the arrow representation we have here is that this
tracer will not necessarily need to force event: if the input tracer tr
does not force its value, then event will not be forced. To elaborate,
suppose tr is nullTracer. Then this expression becomes
classify (This i) = Left i
classify (That _) = Right ()
traceOnlyThat tr
= Tracer $ Pure classify >>> (squelch ||| squelch) >>> Pure (either id id)
= Tracer $ Pure classify >>> Pure (either (const (Left ())) (const (Right ()))) >>> Pure (either id id)
= Tracer $ Pure (classify >>> either (const (Left ())) (const (Right ())) >>> either id id)So that when this tracer is run by traceWith we get
traceWith (traceOnlyThat tr) x
= traceWith (Pure _)
= pure ()It is _essential_ that the computation of the tracing effects cannot itself have side-effects, as this would ruin the ability to short-circuit when it is known that no tracing will be done: the side-effects of a branch could change the outcome of another branch. This would fly in the face of a crucial design goal: you can leave your tracer calls in the program so they do not bitrot, but can also make them zero runtime cost by substituting nullTracer appropriately.
Instances3Contravariant, Semigroup, Monoid
Monad m => Contravariant (Tracer m)Defined in contra-tracer-0.2.1.1 · Control.TracerMonad m => Semigroup (Tracer m s)Defined in contra-tracer-0.2.1.1 · Control.Tracertr1 <> tr2will runtr1and thentr2with the same input.Monad m => Monoid (Tracer m s)Defined in contra-tracer-0.2.1.1 · Control.Tracer
Constructors
Constructors
Constructors
Constructors
Constructors
Constructors
Constructors
FromToExcluding k kFromToIncluding k k
Methods
serialiseKey :: k -> RawBytesdeserialiseKey :: RawBytes -> k
Methods
serialiseValue :: v -> RawBytesdeserialiseValue :: RawBytes -> v
Constructors
Constructors
Constructors
Constructors
Constructors
Constructors
Constructors
Constructors
TraceOpenSessionTraceNewSessionTraceRestoreSessionTraceCreatedSessionTraceCloseSessionTraceClosedSessionTraceDeleteSnapshot SnapshotNameTraceDeletedSnapshot SnapshotNameTraceListSnapshotsTraceImportSnapshot SnapshotName FsPathTraceImportedSnapshot SnapshotNameTraceExportSnapshot SnapshotName FsPathTraceExportedSnapshot SnapshotNameTraceRetrieveBlobs Int
Constructors
ErrSnapshotCorrupted !SnapshotName !FileCorruptedError
Constructors
Constructors
Constructors
Constructors
Constructors
Constructors
TraceCreatedTable SessionId TableConfigTraceNewTable TableConfigTraceCloseTableTraceClosedTableTraceLookups IntTraceRangeLookup (Range SerialisedKey)TraceUpdates IntTraceUpdated IntTraceOpenTableFromSnapshot SnapshotName TableConfigOverrideTraceSaveSnapshot SnapshotNameTraceSavedSnapshot SnapshotNameTraceDuplicate TableIdTraceIncrementalUnions (NonEmpty TableId)TraceRemainingUnionDebtTraceSupplyUnionCredits UnionCreditsTraceSuppliedUnionCredits UnionCredits UnionCredits
Constructors
Constructors
Constructors
Entry !k !vEntryWithBlob !k !v !b
Instances7Bifunctor, Functor, Foldable, Traversable, Eq, Show, …
Bifunctor (Entry k)Defined in lsm-tree-1.1.1.0 · Database.LSMTreeFunctor (Entry k v)Defined in lsm-tree-1.1.1.0 · Database.LSMTreeFoldable (Entry k v)Defined in lsm-tree-1.1.1.0 · Database.LSMTreeTraversable (Entry k v)Defined in lsm-tree-1.1.1.0 · Database.LSMTree(Eq k, Eq v, Eq b) => Eq (Entry k v b)Defined in lsm-tree-1.1.1.0 · Database.LSMTree(Show k, Show v, Show b) => Show (Entry k v b)Defined in lsm-tree-1.1.1.0 · Database.LSMTree(NFData k, NFData v, NFData b) => NFData (Entry k v b)Defined in lsm-tree-1.1.1.0 · Database.LSMTree
type IOLike (m :: Type -> Type) = (MonadAsync m, MonadMVar m, MonadThrow m, MonadThrow (STM m), MonadCatch m, MonadMask m, PrimMonad m, MonadST m, MonadEvaluate m)Constructors
NotFoundFound !vFoundWithBlob !v !b
Instances7Bifunctor, Functor, Foldable, Traversable, Eq, Show, …
Bifunctor LookupResultDefined in lsm-tree-1.1.1.0 · Database.LSMTreeFunctor (LookupResult v)Defined in lsm-tree-1.1.1.0 · Database.LSMTreeFoldable (LookupResult v)Defined in lsm-tree-1.1.1.0 · Database.LSMTreeTraversable (LookupResult v)Defined in lsm-tree-1.1.1.0 · Database.LSMTree(Eq v, Eq b) => Eq (LookupResult v b)Defined in lsm-tree-1.1.1.0 · Database.LSMTree(Show v, Show b) => Show (LookupResult v b)Defined in lsm-tree-1.1.1.0 · Database.LSMTree(NFData v, NFData b) => NFData (LookupResult v b)Defined in lsm-tree-1.1.1.0 · Database.LSMTree