| Safe Haskell | Safe-Inferred | 
|---|---|
| Language | GHC2021 | 
Database.LSMTree.Internal.Unsafe
Description
This module brings together the internal parts to provide an API in terms of untyped serialised keys, values and blobs.
Apart from defining the API, this module mainly deals with concurrency- and exception-safe opening and closing of resources. Any other non-trivial logic should live somewhere else.
Synopsis
- data SessionDirDoesNotExistError = ErrSessionDirDoesNotExist !FsErrorPath
 - data SessionDirLockedError = ErrSessionDirLocked !FsErrorPath
 - data SessionDirCorruptedError = ErrSessionDirCorrupted !Text !FsErrorPath
 - data SessionClosedError = ErrSessionClosed
 - data TableClosedError = ErrTableClosed
 - data TableCorruptedError = ErrLookupByteCountDiscrepancy !ByteCount !ByteCount
 - data TableTooLargeError = ErrTableTooLarge
 - data TableUnionNotCompatibleError
 - data SnapshotExistsError = ErrSnapshotExists !SnapshotName
 - data SnapshotDoesNotExistError = ErrSnapshotDoesNotExist !SnapshotName
 - data SnapshotCorruptedError = ErrSnapshotCorrupted !SnapshotName !FileCorruptedError
 - data SnapshotNotCompatibleError = ErrSnapshotWrongLabel !SnapshotName !SnapshotLabel !SnapshotLabel
 - data BlobRefInvalidError = ErrBlobRefInvalid !Int
 - data CursorClosedError = ErrCursorClosed
 - data FileFormat
 - data FileCorruptedError
 - data InvalidSnapshotNameError = ErrInvalidSnapshotName !String
 - data LSMTreeTrace
 - newtype SessionId = SessionId FsPath
 - data SessionTrace
 - data TableTrace
- = TraceCreatedTable SessionId TableConfig
 - | TraceNewTable TableConfig
 - | TraceCloseTable
 - | TraceClosedTable
 - | TraceLookups Int
 - | TraceRangeLookup (Range SerialisedKey)
 - | TraceUpdates Int
 - | TraceUpdated Int
 - | TraceOpenTableFromSnapshot SnapshotName TableConfigOverride
 - | TraceSaveSnapshot SnapshotName
 - | TraceSavedSnapshot SnapshotName
 - | TraceDuplicate TableId
 - | TraceIncrementalUnions (NonEmpty TableId)
 - | TraceRemainingUnionDebt
 - | TraceSupplyUnionCredits UnionCredits
 - | TraceSuppliedUnionCredits UnionCredits UnionCredits
 
 - data CursorTrace
 - data Session m h = Session {
- sessionState :: !(RWVar m (SessionState m h))
 - lsmTreeTracer :: !(Tracer m LSMTreeTrace)
 - sessionTracer :: !(Tracer m SessionTrace)
 - sessionUniqCounter :: !(UniqCounter m)
 
 - data SessionState m h
- = SessionOpen !(SessionEnv m h)
 - | SessionClosed
 
 - data SessionEnv m h = SessionEnv {
- sessionRoot :: !SessionRoot
 - sessionSalt :: !Salt
 - sessionHasFS :: !(HasFS m h)
 - sessionHasBlockIO :: !(HasBlockIO m h)
 - sessionLockFile :: !(LockFileHandle m)
 - sessionOpenTables :: !(StrictMVar m (Map TableId (Table m h)))
 - sessionOpenCursors :: !(StrictMVar m (Map CursorId (Cursor m h)))
 - sessionRefCtx :: !RefCtx
 
 - withKeepSessionOpen :: (MonadSTM m, MonadThrow m) => Session m h -> (SessionEnv m h -> m a) -> m a
 - withOpenSession :: forall m h a. (MonadSTM m, MonadMVar m, PrimMonad m, MonadMask m, MonadEvaluate m) => Tracer m LSMTreeTrace -> HasFS m h -> HasBlockIO m h -> Salt -> FsPath -> (Session m h -> m a) -> m a
 - withNewSession :: forall m h a. (MonadSTM m, MonadMVar m, PrimMonad m, MonadMask m) => Tracer m LSMTreeTrace -> HasFS m h -> HasBlockIO m h -> Salt -> FsPath -> (Session m h -> m a) -> m a
 - withRestoreSession :: forall m h a. (MonadSTM m, MonadMVar m, PrimMonad m, MonadMask m, MonadEvaluate m) => Tracer m LSMTreeTrace -> HasFS m h -> HasBlockIO m h -> FsPath -> (Session m h -> m a) -> m a
 - openSession :: forall m h. (MonadSTM m, MonadMVar m, PrimMonad m, MonadMask m, MonadEvaluate m) => Tracer m LSMTreeTrace -> HasFS m h -> HasBlockIO m h -> Salt -> FsPath -> m (Session m h)
 - newSession :: forall m h. (MonadSTM m, MonadMVar m, PrimMonad m, MonadMask m) => Tracer m LSMTreeTrace -> HasFS m h -> HasBlockIO m h -> Salt -> FsPath -> m (Session m h)
 - restoreSession :: forall m h. (MonadSTM m, MonadMVar m, PrimMonad m, MonadMask m, MonadEvaluate m) => Tracer m LSMTreeTrace -> HasFS m h -> HasBlockIO m h -> FsPath -> m (Session m h)
 - closeSession :: (MonadMask m, MonadSTM m, MonadMVar m, PrimMonad m) => Session m h -> m ()
 - data Table m h = Table {
- tableConfig :: !TableConfig
 - tableState :: !(RWVar m (TableState m h))
 - tableArenaManager :: !(ArenaManager (PrimState m))
 - tableTracer :: !(Tracer m TableTrace)
 - tableId :: !TableId
 - tableSession :: !(Session m h)
 
 - data TableState m h
- = TableOpen !(TableEnv m h)
 - | TableClosed
 
 - data TableEnv m h = TableEnv {
- tableSessionEnv :: !(SessionEnv m h)
 - tableContent :: !(RWVar m (TableContent m h))
 
 - withKeepTableOpen :: (MonadSTM m, MonadThrow m) => Table m h -> (TableEnv m h -> m a) -> m a
 - type ResolveSerialisedValue = SerialisedValue -> SerialisedValue -> SerialisedValue
 - withTable :: (MonadMask m, MonadSTM m, MonadMVar m, PrimMonad m) => Session m h -> TableConfig -> (Table m h -> m a) -> m a
 - new :: (MonadSTM m, MonadMVar m, PrimMonad m, MonadMask m) => Session m h -> TableConfig -> m (Table m h)
 - close :: (MonadMask m, MonadSTM m, MonadMVar m, PrimMonad m) => Table m h -> m ()
 - lookups :: (MonadAsync m, MonadMask m, MonadMVar m, MonadST m) => ResolveSerialisedValue -> Vector SerialisedKey -> Table m h -> m (Vector (Maybe (Entry SerialisedValue (WeakBlobRef m h))))
 - rangeLookup :: (MonadMask m, MonadMVar m, MonadST m, MonadSTM m) => ResolveSerialisedValue -> Range SerialisedKey -> Table m h -> (SerialisedKey -> SerialisedValue -> Maybe (WeakBlobRef m h) -> res) -> m (Vector res)
 - updates :: (MonadMask m, MonadMVar m, MonadST m, MonadSTM m) => ResolveSerialisedValue -> Vector (SerialisedKey, Entry SerialisedValue SerialisedBlob) -> Table m h -> m ()
 - retrieveBlobs :: (MonadMask m, MonadST m, MonadSTM m) => Session m h -> Vector (WeakBlobRef m h) -> m (Vector SerialisedBlob)
 - data Cursor m h = Cursor {
- cursorState :: !(StrictMVar m (CursorState m h))
 - cursorTracer :: !(Tracer m CursorTrace)
 
 - data CursorState m h
- = CursorOpen !(CursorEnv m h)
 - | CursorClosed
 
 - data CursorEnv m h = CursorEnv {
- cursorSession :: !(Session m h)
 - cursorSessionEnv :: !(SessionEnv m h)
 - cursorId :: !CursorId
 - cursorReaders :: !(Maybe (Readers m h))
 - cursorWBB :: !(Ref (WriteBufferBlobs m h))
 - cursorRuns :: !(Vector (Ref (Run m h)))
 - cursorUnion :: !(Maybe (UnionCache m h))
 
 - data OffsetKey
 - withCursor :: (MonadMask m, MonadMVar m, MonadST m, MonadSTM m) => ResolveSerialisedValue -> OffsetKey -> Table m h -> (Cursor m h -> m a) -> m a
 - newCursor :: (MonadMask m, MonadMVar m, MonadST m, MonadSTM m) => ResolveSerialisedValue -> OffsetKey -> Table m h -> m (Cursor m h)
 - closeCursor :: (MonadMask m, MonadMVar m, MonadSTM m, PrimMonad m) => Cursor m h -> m ()
 - readCursor :: forall m h res. (MonadMask m, MonadMVar m, MonadST m, MonadSTM m) => ResolveSerialisedValue -> Int -> Cursor m h -> (SerialisedKey -> SerialisedValue -> Maybe (WeakBlobRef m h) -> res) -> m (Vector res)
 - readCursorWhile :: forall m h res. (MonadMask m, MonadMVar m, MonadST m, MonadSTM m) => ResolveSerialisedValue -> (SerialisedKey -> Bool) -> Int -> Cursor m h -> (SerialisedKey -> SerialisedValue -> Maybe (WeakBlobRef m h) -> res) -> m (Vector res)
 - data SnapshotLabel
 - saveSnapshot :: (MonadMask m, MonadMVar m, MonadST m, MonadSTM m) => SnapshotName -> SnapshotLabel -> Table m h -> m ()
 - openTableFromSnapshot :: (MonadMask m, MonadMVar m, MonadST m, MonadSTM m) => TableConfigOverride -> Session m h -> SnapshotName -> SnapshotLabel -> ResolveSerialisedValue -> m (Table m h)
 - deleteSnapshot :: (MonadMask m, MonadSTM m) => Session m h -> SnapshotName -> m ()
 - doesSnapshotExist :: (MonadMask m, MonadSTM m) => Session m h -> SnapshotName -> m Bool
 - listSnapshots :: (MonadMask m, MonadSTM m) => Session m h -> m [SnapshotName]
 - duplicate :: (MonadMask m, MonadMVar m, MonadST m, MonadSTM m) => Table m h -> m (Table m h)
 - unions :: (MonadMask m, MonadMVar m, MonadST m, MonadSTM m) => NonEmpty (Table m h) -> m (Table m h)
 - newtype UnionDebt = UnionDebt Int
 - remainingUnionDebt :: (MonadSTM m, MonadMVar m, MonadThrow m, PrimMonad m) => Table m h -> m UnionDebt
 - newtype UnionCredits = UnionCredits Int
 - supplyUnionCredits :: (MonadST m, MonadSTM m, MonadMVar m, MonadMask m) => ResolveSerialisedValue -> Table m h -> UnionCredits -> m UnionCredits
 
Exceptions
data SessionDirDoesNotExistError Source #
The session directory does not exist.
Constructors
| ErrSessionDirDoesNotExist !FsErrorPath | 
Instances
| Exception SessionDirDoesNotExistError Source # | |
| Show SessionDirDoesNotExistError Source # | |
Defined in Database.LSMTree.Internal.Unsafe Methods showsPrec :: Int -> SessionDirDoesNotExistError -> ShowS # show :: SessionDirDoesNotExistError -> String # showList :: [SessionDirDoesNotExistError] -> ShowS #  | |
| Eq SessionDirDoesNotExistError Source # | |
Defined in Database.LSMTree.Internal.Unsafe Methods (==) :: SessionDirDoesNotExistError -> SessionDirDoesNotExistError -> Bool # (/=) :: SessionDirDoesNotExistError -> SessionDirDoesNotExistError -> Bool #  | |
data SessionDirLockedError Source #
The session directory is locked by another active session.
Constructors
| ErrSessionDirLocked !FsErrorPath | 
Instances
| Exception SessionDirLockedError Source # | |
Defined in Database.LSMTree.Internal.Unsafe  | |
| Show SessionDirLockedError Source # | |
Defined in Database.LSMTree.Internal.Unsafe Methods showsPrec :: Int -> SessionDirLockedError -> ShowS # show :: SessionDirLockedError -> String # showList :: [SessionDirLockedError] -> ShowS #  | |
| Eq SessionDirLockedError Source # | |
Defined in Database.LSMTree.Internal.Unsafe Methods (==) :: SessionDirLockedError -> SessionDirLockedError -> Bool # (/=) :: SessionDirLockedError -> SessionDirLockedError -> Bool #  | |
data SessionDirCorruptedError Source #
The session directory is corrupted, e.g., it misses required files or contains unexpected files.
Constructors
| ErrSessionDirCorrupted !Text !FsErrorPath | 
Instances
| Exception SessionDirCorruptedError Source # | |
Defined in Database.LSMTree.Internal.Unsafe  | |
| Show SessionDirCorruptedError Source # | |
Defined in Database.LSMTree.Internal.Unsafe Methods showsPrec :: Int -> SessionDirCorruptedError -> ShowS # show :: SessionDirCorruptedError -> String # showList :: [SessionDirCorruptedError] -> ShowS #  | |
| Eq SessionDirCorruptedError Source # | |
Defined in Database.LSMTree.Internal.Unsafe Methods (==) :: SessionDirCorruptedError -> SessionDirCorruptedError -> Bool # (/=) :: SessionDirCorruptedError -> SessionDirCorruptedError -> Bool #  | |
data SessionClosedError Source #
The session is closed.
Constructors
| ErrSessionClosed | 
Instances
| Exception SessionClosedError Source # | |
Defined in Database.LSMTree.Internal.Unsafe Methods toException :: SessionClosedError -> SomeException # fromException :: SomeException -> Maybe SessionClosedError #  | |
| Show SessionClosedError Source # | |
Defined in Database.LSMTree.Internal.Unsafe Methods showsPrec :: Int -> SessionClosedError -> ShowS # show :: SessionClosedError -> String # showList :: [SessionClosedError] -> ShowS #  | |
| Eq SessionClosedError Source # | |
Defined in Database.LSMTree.Internal.Unsafe Methods (==) :: SessionClosedError -> SessionClosedError -> Bool # (/=) :: SessionClosedError -> SessionClosedError -> Bool #  | |
data TableClosedError Source #
The table is closed.
Constructors
| ErrTableClosed | 
Instances
| Exception TableClosedError Source # | |
Defined in Database.LSMTree.Internal.Unsafe Methods toException :: TableClosedError -> SomeException #  | |
| Show TableClosedError Source # | |
Defined in Database.LSMTree.Internal.Unsafe Methods showsPrec :: Int -> TableClosedError -> ShowS # show :: TableClosedError -> String # showList :: [TableClosedError] -> ShowS #  | |
| Eq TableClosedError Source # | |
Defined in Database.LSMTree.Internal.Unsafe Methods (==) :: TableClosedError -> TableClosedError -> Bool # (/=) :: TableClosedError -> TableClosedError -> Bool #  | |
data TableCorruptedError Source #
The table data is corrupted.
Constructors
| ErrLookupByteCountDiscrepancy | |
Instances
| Exception TableCorruptedError Source # | |
Defined in Database.LSMTree.Internal.Lookup Methods toException :: TableCorruptedError -> SomeException # fromException :: SomeException -> Maybe TableCorruptedError #  | |
| Show TableCorruptedError Source # | |
Defined in Database.LSMTree.Internal.Lookup Methods showsPrec :: Int -> TableCorruptedError -> ShowS # show :: TableCorruptedError -> String # showList :: [TableCorruptedError] -> ShowS #  | |
| Eq TableCorruptedError Source # | |
Defined in Database.LSMTree.Internal.Lookup Methods (==) :: TableCorruptedError -> TableCorruptedError -> Bool # (/=) :: TableCorruptedError -> TableCorruptedError -> Bool #  | |
data TableTooLargeError Source #
The table contains a run that has more than \(2^{40}\) physical entries.
Constructors
| ErrTableTooLarge | 
Instances
| Exception TableTooLargeError Source # | |
Defined in Database.LSMTree.Internal.MergingRun Methods toException :: TableTooLargeError -> SomeException # fromException :: SomeException -> Maybe TableTooLargeError #  | |
| Show TableTooLargeError Source # | |
Defined in Database.LSMTree.Internal.MergingRun Methods showsPrec :: Int -> TableTooLargeError -> ShowS # show :: TableTooLargeError -> String # showList :: [TableTooLargeError] -> ShowS #  | |
| Eq TableTooLargeError Source # | |
Defined in Database.LSMTree.Internal.MergingRun Methods (==) :: TableTooLargeError -> TableTooLargeError -> Bool # (/=) :: TableTooLargeError -> TableTooLargeError -> Bool #  | |
data TableUnionNotCompatibleError Source #
A table union was constructed with two tables that are not compatible.
Constructors
| ErrTableUnionHandleTypeMismatch | |
| ErrTableUnionSessionMismatch | |
Fields 
  | |
Instances
data SnapshotExistsError Source #
The named snapshot already exists.
Constructors
| ErrSnapshotExists !SnapshotName | 
Instances
| Exception SnapshotExistsError Source # | |
Defined in Database.LSMTree.Internal.Unsafe Methods toException :: SnapshotExistsError -> SomeException # fromException :: SomeException -> Maybe SnapshotExistsError #  | |
| Show SnapshotExistsError Source # | |
Defined in Database.LSMTree.Internal.Unsafe Methods showsPrec :: Int -> SnapshotExistsError -> ShowS # show :: SnapshotExistsError -> String # showList :: [SnapshotExistsError] -> ShowS #  | |
| Eq SnapshotExistsError Source # | |
Defined in Database.LSMTree.Internal.Unsafe Methods (==) :: SnapshotExistsError -> SnapshotExistsError -> Bool # (/=) :: SnapshotExistsError -> SnapshotExistsError -> Bool #  | |
data SnapshotDoesNotExistError Source #
The named snapshot does not exist.
Constructors
| ErrSnapshotDoesNotExist !SnapshotName | 
Instances
| Exception SnapshotDoesNotExistError Source # | |
Defined in Database.LSMTree.Internal.Unsafe  | |
| Show SnapshotDoesNotExistError Source # | |
Defined in Database.LSMTree.Internal.Unsafe Methods showsPrec :: Int -> SnapshotDoesNotExistError -> ShowS # show :: SnapshotDoesNotExistError -> String # showList :: [SnapshotDoesNotExistError] -> ShowS #  | |
| Eq SnapshotDoesNotExistError Source # | |
Defined in Database.LSMTree.Internal.Unsafe Methods (==) :: SnapshotDoesNotExistError -> SnapshotDoesNotExistError -> Bool # (/=) :: SnapshotDoesNotExistError -> SnapshotDoesNotExistError -> Bool #  | |
data SnapshotCorruptedError Source #
The named snapshot is corrupted.
Constructors
| ErrSnapshotCorrupted !SnapshotName !FileCorruptedError | 
Instances
| Exception SnapshotCorruptedError Source # | |
Defined in Database.LSMTree.Internal.Unsafe  | |
| Show SnapshotCorruptedError Source # | |
Defined in Database.LSMTree.Internal.Unsafe Methods showsPrec :: Int -> SnapshotCorruptedError -> ShowS # show :: SnapshotCorruptedError -> String # showList :: [SnapshotCorruptedError] -> ShowS #  | |
| Eq SnapshotCorruptedError Source # | |
Defined in Database.LSMTree.Internal.Unsafe Methods (==) :: SnapshotCorruptedError -> SnapshotCorruptedError -> Bool # (/=) :: SnapshotCorruptedError -> SnapshotCorruptedError -> Bool #  | |
data SnapshotNotCompatibleError Source #
The named snapshot is not compatible with the expected type.
Constructors
| ErrSnapshotWrongLabel | The named snapshot is not compatible with the given label.  | 
Fields 
  | |
Instances
| Exception SnapshotNotCompatibleError Source # | |
| Show SnapshotNotCompatibleError Source # | |
Defined in Database.LSMTree.Internal.Unsafe Methods showsPrec :: Int -> SnapshotNotCompatibleError -> ShowS # show :: SnapshotNotCompatibleError -> String # showList :: [SnapshotNotCompatibleError] -> ShowS #  | |
| Eq SnapshotNotCompatibleError Source # | |
Defined in Database.LSMTree.Internal.Unsafe Methods (==) :: SnapshotNotCompatibleError -> SnapshotNotCompatibleError -> Bool # (/=) :: SnapshotNotCompatibleError -> SnapshotNotCompatibleError -> Bool #  | |
data BlobRefInvalidError Source #
A BlobRef used with retrieveBlobs was invalid.
BlobRefs are obtained from lookups in a Table, but they may be
invalidated by subsequent changes in that Table. In general the
reliable way to retrieve blobs is not to change the Table before
retrieving the blobs. To allow later retrievals, duplicate the table
before making modifications and keep the table open until all blob
retrievals are complete.
Constructors
| ErrBlobRefInvalid !Int | The   | 
Instances
| Exception BlobRefInvalidError Source # | |
Defined in Database.LSMTree.Internal.Unsafe Methods toException :: BlobRefInvalidError -> SomeException # fromException :: SomeException -> Maybe BlobRefInvalidError #  | |
| Show BlobRefInvalidError Source # | |
Defined in Database.LSMTree.Internal.Unsafe Methods showsPrec :: Int -> BlobRefInvalidError -> ShowS # show :: BlobRefInvalidError -> String # showList :: [BlobRefInvalidError] -> ShowS #  | |
| Eq BlobRefInvalidError Source # | |
Defined in Database.LSMTree.Internal.Unsafe Methods (==) :: BlobRefInvalidError -> BlobRefInvalidError -> Bool # (/=) :: BlobRefInvalidError -> BlobRefInvalidError -> Bool #  | |
data CursorClosedError Source #
The cursor is closed.
Constructors
| ErrCursorClosed | 
Instances
| Exception CursorClosedError Source # | |
Defined in Database.LSMTree.Internal.Unsafe Methods toException :: CursorClosedError -> SomeException #  | |
| Show CursorClosedError Source # | |
Defined in Database.LSMTree.Internal.Unsafe Methods showsPrec :: Int -> CursorClosedError -> ShowS # show :: CursorClosedError -> String # showList :: [CursorClosedError] -> ShowS #  | |
| Eq CursorClosedError Source # | |
Defined in Database.LSMTree.Internal.Unsafe Methods (==) :: CursorClosedError -> CursorClosedError -> Bool # (/=) :: CursorClosedError -> CursorClosedError -> Bool #  | |
data FileFormat Source #
Constructors
| FormatChecksumsFile | |
| FormatBloomFilterFile | |
| FormatIndexFile | |
| FormatWriteBufferFile | |
| FormatSnapshotMetaData | 
Instances
| Show FileFormat Source # | |
Defined in Database.LSMTree.Internal.CRC32C Methods showsPrec :: Int -> FileFormat -> ShowS # show :: FileFormat -> String # showList :: [FileFormat] -> ShowS #  | |
| Eq FileFormat Source # | |
Defined in Database.LSMTree.Internal.CRC32C  | |
data FileCorruptedError Source #
The file is corrupted.
Constructors
| ErrFileFormatInvalid | The file fails to parse.  | 
Fields 
  | |
| ErrFileChecksumMismatch | The file CRC32 checksum is invalid.  | 
Fields 
  | |
Instances
| Exception FileCorruptedError Source # | |
Defined in Database.LSMTree.Internal.CRC32C Methods toException :: FileCorruptedError -> SomeException # fromException :: SomeException -> Maybe FileCorruptedError #  | |
| Show FileCorruptedError Source # | |
Defined in Database.LSMTree.Internal.CRC32C Methods showsPrec :: Int -> FileCorruptedError -> ShowS # show :: FileCorruptedError -> String # showList :: [FileCorruptedError] -> ShowS #  | |
| Eq FileCorruptedError Source # | |
Defined in Database.LSMTree.Internal.CRC32C Methods (==) :: FileCorruptedError -> FileCorruptedError -> Bool # (/=) :: FileCorruptedError -> FileCorruptedError -> Bool #  | |
data InvalidSnapshotNameError Source #
Constructors
| ErrInvalidSnapshotName !String | 
Instances
| Exception InvalidSnapshotNameError Source # | |
Defined in Database.LSMTree.Internal.Paths  | |
| Show InvalidSnapshotNameError Source # | |
Defined in Database.LSMTree.Internal.Paths Methods showsPrec :: Int -> InvalidSnapshotNameError -> ShowS # show :: InvalidSnapshotNameError -> String # showList :: [InvalidSnapshotNameError] -> ShowS #  | |
| Eq InvalidSnapshotNameError Source # | |
Defined in Database.LSMTree.Internal.Paths Methods (==) :: InvalidSnapshotNameError -> InvalidSnapshotNameError -> Bool # (/=) :: InvalidSnapshotNameError -> InvalidSnapshotNameError -> Bool #  | |
Tracing
Trace messages are divided into three categories for each type of resource: sessions, tables, and cursors. The trace messages are structured so that:
- Resources have (unique) identifiers, and these are included in each message.
 - Operations that modify, create, or close resources trace a start and end message. The reasoning here is that it's useful for troubleshooting purposes to know not only that an operation started but also that it ended. To an extent this would also be useful for read-only operations like lookups, but since read-only operations do not modify resources, we've left out end messages for those. They could be added if asked for by users.
 - When we are in the process of creating a new resource from existing resources, then the child resource traces the identifier(s) of its parent resource(s).
 
These properties ensure that troubleshooting using tracers in a concurrent
  setting is possible. Messages can be interleaved, so it's important to find
  meaningful pairings of messages, like TraceCloseTable and
  TraceClosedTable.
data LSMTreeTrace Source #
Constructors
| TraceSession | Trace messages related to sessions.  | 
Fields 
  | |
| TraceTable | Trace messages related to tables.  | 
Fields 
  | |
| TraceCursor | Trace messages related to cursors.  | 
Fields 
  | |
Instances
| Show LSMTreeTrace Source # | |
Defined in Database.LSMTree.Internal.Unsafe Methods showsPrec :: Int -> LSMTreeTrace -> ShowS # show :: LSMTreeTrace -> String # showList :: [LSMTreeTrace] -> ShowS #  | |
| Eq LSMTreeTrace Source # | |
Defined in Database.LSMTree.Internal.Unsafe  | |
Sessions are identified by the path to their root directory.
data SessionTrace Source #
Trace messages related to sessions.
Constructors
| TraceOpenSession | We are opening a session in the requested session directory. A
   | 
| TraceNewSession | We are creating a new, fresh session. A   | 
| TraceRestoreSession | We are restoring a session from the directory contents. A
   | 
| TraceCreatedSession | A session has been successfully created.  | 
| TraceCloseSession | We are closing the session. A   | 
| TraceClosedSession | Closing the session was successful.  | 
| TraceDeleteSnapshot SnapshotName | We are deleting the snapshot with the given name. A
   | 
| TraceDeletedSnapshot SnapshotName | We have successfully deleted the snapshot with the given name.  | 
| TraceListSnapshots | We are listing snapshots.  | 
| TraceRetrieveBlobs Int | We are retrieving blobs.  | 
Instances
| Show SessionTrace Source # | |
Defined in Database.LSMTree.Internal.Unsafe Methods showsPrec :: Int -> SessionTrace -> ShowS # show :: SessionTrace -> String # showList :: [SessionTrace] -> ShowS #  | |
| Eq SessionTrace Source # | |
Defined in Database.LSMTree.Internal.Unsafe  | |
data TableTrace Source #
Trace messages related to tables.
Constructors
| TraceCreatedTable | A table has been successfully created with the specified config.  | 
Fields 
  | |
| TraceNewTable TableConfig | We are creating a new, fresh table with the specified config. A
   | 
| TraceCloseTable | We are closing the table. A   | 
| TraceClosedTable | Closing the table was succesful.  | 
| TraceLookups | We are performing a batch of lookups.  | 
Fields 
  | |
| TraceRangeLookup (Range SerialisedKey) | We are performing a range lookup.  | 
| TraceUpdates | We are performing a batch of updates.  | 
Fields 
  | |
| TraceUpdated | We have successfully performed a batch of updates.  | 
Fields 
  | |
| TraceOpenTableFromSnapshot SnapshotName TableConfigOverride | We are opening a table from a snapshot. A   | 
| TraceSaveSnapshot SnapshotName | We are saving a snapshot with the given name. A   | 
| TraceSavedSnapshot SnapshotName | A snapshot with the given name was saved successfully.  | 
| TraceDuplicate | We are creating a duplicate of a table. A   | 
Fields 
  | |
| TraceIncrementalUnions | We are creating an incremental union of a list of tables. A
   | 
| TraceRemainingUnionDebt | We are querying the remaining union debt.  | 
| TraceSupplyUnionCredits UnionCredits | We are supplying the given number of union credits.  | 
| TraceSuppliedUnionCredits | We have supplied union credits.  | 
Fields 
  | |
Instances
| Show TableTrace Source # | |
Defined in Database.LSMTree.Internal.Unsafe Methods showsPrec :: Int -> TableTrace -> ShowS # show :: TableTrace -> String # showList :: [TableTrace] -> ShowS #  | |
| Eq TableTrace Source # | |
Defined in Database.LSMTree.Internal.Unsafe  | |
data CursorTrace Source #
Trace messages related to cursors.
Constructors
| TraceCreatedCursor | A cursor has been successfully created.  | 
Fields 
  | |
| TraceNewCursor | We are creating a new, fresh cursor positioned at the given offset key.
 A   | 
| TraceCloseCursor | We are closing the cursor. A   | 
| TraceClosedCursor | Closing the cursor was succesful.  | 
| TraceReadingCursor | We are reading from the cursor. A   | 
Fields 
  | |
| TraceReadCursor | We have succesfully read from the cursor.  | 
Instances
| Show CursorTrace Source # | |
Defined in Database.LSMTree.Internal.Unsafe Methods showsPrec :: Int -> CursorTrace -> ShowS # show :: CursorTrace -> String # showList :: [CursorTrace] -> ShowS #  | |
| Eq CursorTrace Source # | |
Defined in Database.LSMTree.Internal.Unsafe  | |
Session
A session provides context that is shared across multiple tables.
For more information, see Session.
Constructors
| Session | |
Fields 
  | |
data SessionState m h Source #
Constructors
| SessionOpen !(SessionEnv m h) | |
| SessionClosed | 
data SessionEnv m h Source #
Constructors
| SessionEnv | |
Fields 
  | |
withKeepSessionOpen :: (MonadSTM m, MonadThrow m) => Session m h -> (SessionEnv m h -> m a) -> m a Source #
withKeepSessionOpen ensures that the session stays open for the duration of
 the provided continuation.
NOTE: any operation except sessionClose can use this function.
Implementation of public API
Arguments
| :: forall m h a. (MonadSTM m, MonadMVar m, PrimMonad m, MonadMask m, MonadEvaluate m) | |
| => Tracer m LSMTreeTrace | |
| -> HasFS m h | |
| -> HasBlockIO m h | |
| -> Salt | |
| -> FsPath | Path to the session directory  | 
| -> (Session m h -> m a) | |
| -> m a | 
Arguments
| :: forall m h a. (MonadSTM m, MonadMVar m, PrimMonad m, MonadMask m, MonadEvaluate m) | |
| => Tracer m LSMTreeTrace | |
| -> HasFS m h | |
| -> HasBlockIO m h | |
| -> FsPath | Path to the session directory  | 
| -> (Session m h -> m a) | |
| -> m a | 
Arguments
| :: forall m h. (MonadSTM m, MonadMVar m, PrimMonad m, MonadMask m, MonadEvaluate m) | |
| => Tracer m LSMTreeTrace | |
| -> HasFS m h | |
| -> HasBlockIO m h | |
| -> Salt | |
| -> FsPath | Path to the session directory  | 
| -> m (Session m h) | 
See openSession.
Arguments
| :: forall m h. (MonadSTM m, MonadMVar m, PrimMonad m, MonadMask m) | |
| => Tracer m LSMTreeTrace | |
| -> HasFS m h | |
| -> HasBlockIO m h | |
| -> Salt | |
| -> FsPath | Path to the session directory  | 
| -> m (Session m h) | 
See newSession.
Arguments
| :: forall m h. (MonadSTM m, MonadMVar m, PrimMonad m, MonadMask m, MonadEvaluate m) | |
| => Tracer m LSMTreeTrace | |
| -> HasFS m h | |
| -> HasBlockIO m h | |
| -> FsPath | Path to the session directory  | 
| -> m (Session m h) | 
See restoreSession.
closeSession :: (MonadMask m, MonadSTM m, MonadMVar m, PrimMonad m) => Session m h -> m () Source #
See closeSession.
A session's global resources will only be released once it is sure that no tables or cursors are open anymore.
Table
A handle to an on-disk key/value table.
For more information, see Table.
Constructors
| Table | |
Fields 
  | |
data TableState m h Source #
A table may assume that its corresponding session is still open as long as the table is open. A session's global resources, and therefore resources that are inherited by the table, will only be released once the session is sure that no tables are open anymore.
Constructors
| TableOpen !(TableEnv m h) | |
| TableClosed | 
Constructors
| TableEnv | |
Fields 
  | |
withKeepTableOpen :: (MonadSTM m, MonadThrow m) => Table m h -> (TableEnv m h -> m a) -> m a Source #
withKeepTableOpen ensures that the table stays open for the duration of the
 provided continuation.
NOTE: any operation except close can use this function.
Implementation of public API
withTable :: (MonadMask m, MonadSTM m, MonadMVar m, PrimMonad m) => Session m h -> TableConfig -> (Table m h -> m a) -> m a Source #
See withTable.
new :: (MonadSTM m, MonadMVar m, PrimMonad m, MonadMask m) => Session m h -> TableConfig -> m (Table m h) Source #
See new.
close :: (MonadMask m, MonadSTM m, MonadMVar m, PrimMonad m) => Table m h -> m () Source #
See close.
lookups :: (MonadAsync m, MonadMask m, MonadMVar m, MonadST m) => ResolveSerialisedValue -> Vector SerialisedKey -> Table m h -> m (Vector (Maybe (Entry SerialisedValue (WeakBlobRef m h)))) Source #
See lookups.
Arguments
| :: (MonadMask m, MonadMVar m, MonadST m, MonadSTM m) | |
| => ResolveSerialisedValue | |
| -> Range SerialisedKey | |
| -> Table m h | |
| -> (SerialisedKey -> SerialisedValue -> Maybe (WeakBlobRef m h) -> res) | How to map to a query result  | 
| -> m (Vector res) | 
See rangeLookup.
updates :: (MonadMask m, MonadMVar m, MonadST m, MonadSTM m) => ResolveSerialisedValue -> Vector (SerialisedKey, Entry SerialisedValue SerialisedBlob) -> Table m h -> m () Source #
See updates.
Does not enforce that upsert and BLOBs should not occur in the same table.
retrieveBlobs :: (MonadMask m, MonadST m, MonadSTM m) => Session m h -> Vector (WeakBlobRef m h) -> m (Vector SerialisedBlob) Source #
Cursor API
A read-only view into the table state at the time of cursor creation.
For more information, see Cursor.
The representation of a cursor is similar to that of a Table, but
 simpler, as it is read-only.
Constructors
| Cursor | |
Fields 
  | |
data CursorState m h Source #
Constructors
| CursorOpen !(CursorEnv m h) | |
| CursorClosed | Calls to a closed cursor raise an exception.  | 
Constructors
| CursorEnv | |
Fields 
  | |
Constructors
| NoOffsetKey | |
| OffsetKey !SerialisedKey | 
withCursor :: (MonadMask m, MonadMVar m, MonadST m, MonadSTM m) => ResolveSerialisedValue -> OffsetKey -> Table m h -> (Cursor m h -> m a) -> m a Source #
See withCursor.
newCursor :: (MonadMask m, MonadMVar m, MonadST m, MonadSTM m) => ResolveSerialisedValue -> OffsetKey -> Table m h -> m (Cursor m h) Source #
See newCursor.
closeCursor :: (MonadMask m, MonadMVar m, MonadSTM m, PrimMonad m) => Cursor m h -> m () Source #
See closeCursor.
Arguments
| :: forall m h res. (MonadMask m, MonadMVar m, MonadST m, MonadSTM m) | |
| => ResolveSerialisedValue | |
| -> Int | Maximum number of entries to read  | 
| -> Cursor m h | |
| -> (SerialisedKey -> SerialisedValue -> Maybe (WeakBlobRef m h) -> res) | How to map to a query result  | 
| -> m (Vector res) | 
See readCursor.
Arguments
| :: forall m h res. (MonadMask m, MonadMVar m, MonadST m, MonadSTM m) | |
| => ResolveSerialisedValue | |
| -> (SerialisedKey -> Bool) | Only read as long as this predicate holds  | 
| -> Int | Maximum number of entries to read  | 
| -> Cursor m h | |
| -> (SerialisedKey -> SerialisedValue -> Maybe (WeakBlobRef m h) -> res) | How to map to a query result  | 
| -> m (Vector res) | 
readCursorWhile _ p n cursor _ reads elements until either:
nelements have been read alreadypreturnsFalsefor the key of an entry to be read- the cursor is drained
 
Consequently, once a call returned fewer than n elements, any subsequent
 calls with the same predicate p will return an empty vector.
Snapshots
data SnapshotLabel Source #
Custom, user-supplied text that is included in the metadata.
The main use case for a SnapshotLabel is for the user to supply textual
 information about the key/value/blob type for the table that corresponds to
 the snapshot. This information is used to dynamically check that a snapshot
 is opened at the correct key/value/blob type.
Instances
| IsString SnapshotLabel Source # | |
Defined in Database.LSMTree.Internal.Snapshot Methods fromString :: String -> SnapshotLabel #  | |
| Show SnapshotLabel Source # | |
Defined in Database.LSMTree.Internal.Snapshot Methods showsPrec :: Int -> SnapshotLabel -> ShowS # show :: SnapshotLabel -> String # showList :: [SnapshotLabel] -> ShowS #  | |
| NFData SnapshotLabel Source # | |
Defined in Database.LSMTree.Internal.Snapshot Methods rnf :: SnapshotLabel -> () #  | |
| Eq SnapshotLabel Source # | |
Defined in Database.LSMTree.Internal.Snapshot Methods (==) :: SnapshotLabel -> SnapshotLabel -> Bool # (/=) :: SnapshotLabel -> SnapshotLabel -> Bool #  | |
| DecodeVersioned SnapshotLabel Source # | |
Defined in Database.LSMTree.Internal.Snapshot.Codec Methods decodeVersioned :: SnapshotVersion -> Decoder s SnapshotLabel Source #  | |
| Encode SnapshotLabel Source # | |
Defined in Database.LSMTree.Internal.Snapshot.Codec Methods encode :: SnapshotLabel -> Encoding Source #  | |
saveSnapshot :: (MonadMask m, MonadMVar m, MonadST m, MonadSTM m) => SnapshotName -> SnapshotLabel -> Table m h -> m () Source #
See saveSnapshot.
openTableFromSnapshot Source #
Arguments
| :: (MonadMask m, MonadMVar m, MonadST m, MonadSTM m) | |
| => TableConfigOverride | |
| -> Session m h | |
| -> SnapshotName | |
| -> SnapshotLabel | Expected label  | 
| -> ResolveSerialisedValue | |
| -> m (Table m h) | 
deleteSnapshot :: (MonadMask m, MonadSTM m) => Session m h -> SnapshotName -> m () Source #
See deleteSnapshot.
doesSnapshotExist :: (MonadMask m, MonadSTM m) => Session m h -> SnapshotName -> m Bool Source #
See doesSnapshotExist.
listSnapshots :: (MonadMask m, MonadSTM m) => Session m h -> m [SnapshotName] Source #
See listSnapshots.
Multiple writable tables
duplicate :: (MonadMask m, MonadMVar m, MonadST m, MonadSTM m) => Table m h -> m (Table m h) Source #
See duplicate.
Table union
unions :: (MonadMask m, MonadMVar m, MonadST m, MonadSTM m) => NonEmpty (Table m h) -> m (Table m h) Source #
See unions.
Union debt represents the amount of computation that must be performed before an incremental union is completed. This includes the cost of completing incremental unions that were part of a union's input.
Warning: The UnionDebt returned by remainingUnionDebt is an upper bound on the remaining union debt, not the exact union debt.
Instances
| Num UnionDebt Source # | |
Defined in Database.LSMTree.Internal.Unsafe  | |
| Show UnionDebt Source # | |
| Eq UnionDebt Source # | |
| Ord UnionDebt Source # | |
Defined in Database.LSMTree.Internal.Unsafe  | |
remainingUnionDebt :: (MonadSTM m, MonadMVar m, MonadThrow m, PrimMonad m) => Table m h -> m UnionDebt Source #
See remainingUnionDebt.
newtype UnionCredits Source #
Union credits are passed to supplyUnionCredits to perform some amount of computation to incrementally complete a union.
Constructors
| UnionCredits Int | 
Instances
supplyUnionCredits :: (MonadST m, MonadSTM m, MonadMVar m, MonadMask m) => ResolveSerialisedValue -> Table m h -> UnionCredits -> m UnionCredits Source #
See supplyUnionCredits.