Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Database.LSMTree.Internal
Description
This module brings together the internal parts to provide an API in terms of untyped serialised keys, values and blobs. It makes no distinction between normal and monoidal tables, accepting both blobs and mupserts. The typed normal and monoidal APIs then provide more type-safe wrappers and handle serialisation.
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 Session' m = forall h.Typeable h => Session' !(Session m h)
- data Table' m k v b = forall h.Typeable h => Table' (Table m h)
- data Cursor' m k v b = forall h.Typeable h => Cursor' (Cursor m h)
- data NormalTable m k v b = forall h.Typeable h => NormalTable !(Table m h)
- data NormalCursor m k v b = forall h.Typeable h => NormalCursor !(Cursor m h)
- data MonoidalTable m k v = forall h.Typeable h => MonoidalTable !(Table m h)
- data MonoidalCursor m k v = forall h.Typeable h => MonoidalCursor !(Cursor m h)
- data SessionDirDoesNotExistError = ErrSessionDirDoesNotExist !FsErrorPath
- data SessionDirLockedError = ErrSessionDirLocked !FsErrorPath
- data SessionDirCorruptedError = ErrSessionDirCorrupted !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
- data BlobRefInvalidError = ErrBlobRefInvalid !Int
- data CursorClosedError = ErrCursorClosed
- data FileFormat
- data FileCorruptedError
- data InvalidSnapshotNameError = ErrSnapshotNameInvalid !String
- data LSMTreeTrace
- = TraceOpenSession FsPath
- | TraceNewSession
- | TraceRestoreSession
- | TraceCloseSession
- | TraceNewTable
- | TraceOpenSnapshot SnapshotName TableConfigOverride
- | TraceTable TableId TableTrace
- | TraceDeleteSnapshot SnapshotName
- | TraceListSnapshots
- | TraceCursor CursorId CursorTrace
- | TraceUnions (NonEmpty TableId)
- data TableTrace
- data Session m h = Session {
- sessionState :: !(RWVar m (SessionState m h))
- sessionTracer :: !(Tracer m LSMTreeTrace)
- data SessionState m h
- = SessionOpen !(SessionEnv m h)
- | SessionClosed
- data SessionEnv m h = SessionEnv {
- sessionRoot :: !SessionRoot
- sessionHasFS :: !(HasFS m h)
- sessionHasBlockIO :: !(HasBlockIO m h)
- sessionLockFile :: !(LockFileHandle m)
- sessionUniqCounter :: !(UniqCounter m)
- sessionOpenTables :: !(StrictMVar m (Map TableId (Table m h)))
- sessionOpenCursors :: !(StrictMVar m (Map CursorId (Cursor m h)))
- withOpenSession :: (MonadSTM m, MonadThrow m) => Session m h -> (SessionEnv m h -> m a) -> m a
- withSession :: (MonadMask m, MonadSTM m, MonadMVar m, PrimMonad 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) => 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))
- withOpenTable :: (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))
- cursorRuns :: !(Vector (Ref (Run m h)))
- cursorWBB :: !(Ref (WriteBufferBlobs m h))
- data OffsetKey
- withCursor :: (MonadMask m, MonadMVar m, MonadST m, MonadSTM m) => OffsetKey -> Table m h -> (Cursor m h -> m a) -> m a
- newCursor :: (MonadMask m, MonadMVar m, MonadST m, MonadSTM m) => 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
- createSnapshot :: (MonadMask m, MonadMVar m, MonadST m, MonadSTM m) => SnapshotName -> SnapshotLabel -> SnapshotTableType -> Table m h -> m ()
- openSnapshot :: (MonadMask m, MonadMVar m, MonadST m, MonadSTM m) => Session m h -> SnapshotLabel -> SnapshotTableType -> TableConfigOverride -> SnapshotName -> 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
Existentials
data NormalTable m k v b Source #
Constructors
forall h.Typeable h => NormalTable !(Table m h) |
Instances
NFData (NormalTable m k v b) Source # | |
Defined in Database.LSMTree.Internal Methods rnf :: NormalTable m k v b -> () # |
data NormalCursor m k v b Source #
Constructors
forall h.Typeable h => NormalCursor !(Cursor m h) |
Instances
NFData (NormalCursor m k v b) Source # | |
Defined in Database.LSMTree.Internal Methods rnf :: NormalCursor m k v b -> () # |
data MonoidalTable m k v Source #
Constructors
forall h.Typeable h => MonoidalTable !(Table m h) |
Instances
NFData (MonoidalTable m k v) Source # | |
Defined in Database.LSMTree.Internal Methods rnf :: MonoidalTable m k v -> () # |
data MonoidalCursor m k v Source #
Constructors
forall h.Typeable h => MonoidalCursor !(Cursor m h) |
Instances
NFData (MonoidalCursor m k v) Source # | |
Defined in Database.LSMTree.Internal Methods rnf :: MonoidalCursor m k v -> () # |
Exceptions
data SessionDirDoesNotExistError Source #
The session directory does not exist.
Constructors
ErrSessionDirDoesNotExist !FsErrorPath |
Instances
Exception SessionDirDoesNotExistError Source # | |
Defined in Database.LSMTree.Internal | |
Show SessionDirDoesNotExistError Source # | |
Defined in Database.LSMTree.Internal Methods showsPrec :: Int -> SessionDirDoesNotExistError -> ShowS # show :: SessionDirDoesNotExistError -> String # showList :: [SessionDirDoesNotExistError] -> ShowS # | |
Eq SessionDirDoesNotExistError Source # | |
Defined in Database.LSMTree.Internal 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 | |
Show SessionDirLockedError Source # | |
Defined in Database.LSMTree.Internal Methods showsPrec :: Int -> SessionDirLockedError -> ShowS # show :: SessionDirLockedError -> String # showList :: [SessionDirLockedError] -> ShowS # | |
Eq SessionDirLockedError Source # | |
Defined in Database.LSMTree.Internal 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 !FsErrorPath |
Instances
Exception SessionDirCorruptedError Source # | |
Defined in Database.LSMTree.Internal | |
Show SessionDirCorruptedError Source # | |
Defined in Database.LSMTree.Internal Methods showsPrec :: Int -> SessionDirCorruptedError -> ShowS # show :: SessionDirCorruptedError -> String # showList :: [SessionDirCorruptedError] -> ShowS # | |
Eq SessionDirCorruptedError Source # | |
Defined in Database.LSMTree.Internal 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 Methods toException :: SessionClosedError -> SomeException # fromException :: SomeException -> Maybe SessionClosedError # | |
Show SessionClosedError Source # | |
Defined in Database.LSMTree.Internal Methods showsPrec :: Int -> SessionClosedError -> ShowS # show :: SessionClosedError -> String # showList :: [SessionClosedError] -> ShowS # | |
Eq SessionClosedError Source # | |
Defined in Database.LSMTree.Internal 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 Methods toException :: TableClosedError -> SomeException # | |
Show TableClosedError Source # | |
Defined in Database.LSMTree.Internal Methods showsPrec :: Int -> TableClosedError -> ShowS # show :: TableClosedError -> String # showList :: [TableClosedError] -> ShowS # | |
Eq TableClosedError Source # | |
Defined in Database.LSMTree.Internal 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
Exception TableUnionNotCompatibleError Source # | |
Show TableUnionNotCompatibleError Source # | |
Defined in Database.LSMTree.Internal Methods showsPrec :: Int -> TableUnionNotCompatibleError -> ShowS # show :: TableUnionNotCompatibleError -> String # showList :: [TableUnionNotCompatibleError] -> ShowS # | |
Eq TableUnionNotCompatibleError Source # | |
Defined in Database.LSMTree.Internal Methods (==) :: TableUnionNotCompatibleError -> TableUnionNotCompatibleError -> Bool # (/=) :: TableUnionNotCompatibleError -> TableUnionNotCompatibleError -> Bool # |
data SnapshotExistsError Source #
The named snapshot already exists.
Constructors
ErrSnapshotExists !SnapshotName |
Instances
Exception SnapshotExistsError Source # | |
Defined in Database.LSMTree.Internal Methods toException :: SnapshotExistsError -> SomeException # fromException :: SomeException -> Maybe SnapshotExistsError # | |
Show SnapshotExistsError Source # | |
Defined in Database.LSMTree.Internal Methods showsPrec :: Int -> SnapshotExistsError -> ShowS # show :: SnapshotExistsError -> String # showList :: [SnapshotExistsError] -> ShowS # | |
Eq SnapshotExistsError Source # | |
Defined in Database.LSMTree.Internal 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 | |
Show SnapshotDoesNotExistError Source # | |
Defined in Database.LSMTree.Internal Methods showsPrec :: Int -> SnapshotDoesNotExistError -> ShowS # show :: SnapshotDoesNotExistError -> String # showList :: [SnapshotDoesNotExistError] -> ShowS # | |
Eq SnapshotDoesNotExistError Source # | |
Defined in Database.LSMTree.Internal 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 | |
Show SnapshotCorruptedError Source # | |
Defined in Database.LSMTree.Internal Methods showsPrec :: Int -> SnapshotCorruptedError -> ShowS # show :: SnapshotCorruptedError -> String # showList :: [SnapshotCorruptedError] -> ShowS # | |
Eq SnapshotCorruptedError Source # | |
Defined in Database.LSMTree.Internal Methods (==) :: SnapshotCorruptedError -> SnapshotCorruptedError -> Bool # (/=) :: SnapshotCorruptedError -> SnapshotCorruptedError -> Bool # |
data SnapshotNotCompatibleError Source #
The named snapshot is not compatible with the expected type.
Constructors
ErrSnapshotWrongTableType | The named snapshot is not compatible with the current public API module. For instance, the snapshot was created using the simple API, but was opened using the full API. |
Fields
| |
ErrSnapshotWrongLabel | The named snapshot is not compatible with the given label. |
Fields
|
Instances
Exception SnapshotNotCompatibleError Source # | |
Defined in Database.LSMTree.Internal | |
Show SnapshotNotCompatibleError Source # | |
Defined in Database.LSMTree.Internal Methods showsPrec :: Int -> SnapshotNotCompatibleError -> ShowS # show :: SnapshotNotCompatibleError -> String # showList :: [SnapshotNotCompatibleError] -> ShowS # | |
Eq SnapshotNotCompatibleError Source # | |
Defined in Database.LSMTree.Internal Methods (==) :: SnapshotNotCompatibleError -> SnapshotNotCompatibleError -> Bool # (/=) :: SnapshotNotCompatibleError -> SnapshotNotCompatibleError -> Bool # |
data BlobRefInvalidError Source #
A BlobRef
used with retrieveBlobs
was invalid.
BlobRef
s 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 Methods toException :: BlobRefInvalidError -> SomeException # fromException :: SomeException -> Maybe BlobRefInvalidError # | |
Show BlobRefInvalidError Source # | |
Defined in Database.LSMTree.Internal Methods showsPrec :: Int -> BlobRefInvalidError -> ShowS # show :: BlobRefInvalidError -> String # showList :: [BlobRefInvalidError] -> ShowS # | |
Eq BlobRefInvalidError Source # | |
Defined in Database.LSMTree.Internal 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 Methods toException :: CursorClosedError -> SomeException # | |
Show CursorClosedError Source # | |
Defined in Database.LSMTree.Internal Methods showsPrec :: Int -> CursorClosedError -> ShowS # show :: CursorClosedError -> String # showList :: [CursorClosedError] -> ShowS # | |
Eq CursorClosedError Source # | |
Defined in Database.LSMTree.Internal 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. |
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
ErrSnapshotNameInvalid !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 # |
Tracing
data LSMTreeTrace Source #
Constructors
Instances
Show LSMTreeTrace Source # | |
Defined in Database.LSMTree.Internal Methods showsPrec :: Int -> LSMTreeTrace -> ShowS # show :: LSMTreeTrace -> String # showList :: [LSMTreeTrace] -> ShowS # |
data TableTrace Source #
Constructors
TraceCreateTable TableConfig | A table is created with the specified config. This message is traced in addition to messages like |
TraceCloseTable | |
TraceLookups Int | |
TraceRangeLookup (Range SerialisedKey) | |
TraceUpdates Int | |
TraceMerge (AtLevel MergeTrace) | |
TraceSnapshot SnapshotName | |
TraceDuplicate | |
TraceRemainingUnionDebt | |
TraceSupplyUnionCredits UnionCredits |
Instances
Show TableTrace Source # | |
Defined in Database.LSMTree.Internal Methods showsPrec :: Int -> TableTrace -> ShowS # show :: TableTrace -> String # showList :: [TableTrace] -> ShowS # |
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
|
withOpenSession :: (MonadSTM m, MonadThrow m) => Session m h -> (SessionEnv m h -> m a) -> m a Source #
withOpenSession
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
withSession :: (MonadMask m, MonadSTM m, MonadMVar m, PrimMonad m) => Tracer m LSMTreeTrace -> HasFS m h -> HasBlockIO m h -> FsPath -> (Session m h -> m a) -> m a Source #
See withSession
.
Arguments
:: forall m h. (MonadSTM m, MonadMVar m, PrimMonad m, MonadMask m) | |
=> Tracer m LSMTreeTrace | |
-> HasFS m h | |
-> HasBlockIO m h | |
-> FsPath | Path to the session directory |
-> m (Session m h) |
See openSession
.
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
|
withOpenTable :: (MonadSTM m, MonadThrow m) => Table m h -> (TableEnv m h -> m a) -> m a Source #
withOpenTable
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
type ResolveSerialisedValue = SerialisedValue -> SerialisedValue -> SerialisedValue Source #
Value resolve function: what to do when resolving two Mupdate
s
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, different for normal/monoidal |
-> 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 mupsert 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) => OffsetKey -> Table m h -> (Cursor m h -> m a) -> m a Source #
See withCursor
.
newCursor :: (MonadMask m, MonadMVar m, MonadST m, MonadSTM m) => 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, different for normal/monoidal |
-> 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, different for normal/monoidal |
-> m (Vector res) |
readCursorWhile _ p n cursor _
reads elements until either:
n
elements have been read alreadyp
returnsFalse
for 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 # |
createSnapshot :: (MonadMask m, MonadMVar m, MonadST m, MonadSTM m) => SnapshotName -> SnapshotLabel -> SnapshotTableType -> Table m h -> m () Source #
See createSnapshot'
.
Arguments
:: (MonadMask m, MonadMVar m, MonadST m, MonadSTM m) | |
=> Session m h | |
-> SnapshotLabel | Expected label |
-> SnapshotTableType | Expected table type |
-> TableConfigOverride | Optional config override |
-> SnapshotName | |
-> ResolveSerialisedValue | |
-> m (Table m h) |
See openSnapshot
.
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
.
See UnionDebt
.
Instances
Num UnionDebt Source # | |
Defined in Database.LSMTree.Internal | |
Show UnionDebt Source # | |
Eq UnionDebt Source # | |
Ord UnionDebt Source # | |
remainingUnionDebt :: (MonadSTM m, MonadMVar m, MonadThrow m, PrimMonad m) => Table m h -> m UnionDebt Source #
See remainingUnionDebt
.
newtype UnionCredits Source #
See UnionCredits
.
Constructors
UnionCredits Int |
Instances
supplyUnionCredits :: (MonadST m, MonadSTM m, MonadMVar m, MonadMask m) => ResolveSerialisedValue -> Table m h -> UnionCredits -> m UnionCredits Source #
See supplyUnionCredits
.