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 !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
- = TraceOpenSession FsPath
- | TraceNewSession
- | TraceRestoreSession
- | TraceCloseSession
- | TraceNewTable
- | TraceOpenTableFromSnapshot SnapshotName OverrideDiskCachePolicy
- | TraceTable TableId TableTrace
- | TraceDeleteSnapshot SnapshotName
- | TraceListSnapshots
- | TraceCursor CursorId CursorTrace
- | TraceUnions (NonEmpty TableId)
- data TableTrace
- data CursorTrace
- 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))
- 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) => OverrideDiskCachePolicy -> 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 !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.
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.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
data LSMTreeTrace Source #
Constructors
Instances
Show LSMTreeTrace Source # | |
Defined in Database.LSMTree.Internal.Unsafe 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 | |
TraceSnapshot SnapshotName | |
TraceDuplicate | |
TraceRemainingUnionDebt | |
TraceSupplyUnionCredits UnionCredits |
Instances
Show TableTrace Source # | |
Defined in Database.LSMTree.Internal.Unsafe Methods showsPrec :: Int -> TableTrace -> ShowS # show :: TableTrace -> String # showList :: [TableTrace] -> ShowS # |
data CursorTrace Source #
Constructors
TraceCreateCursor TableId | |
TraceCloseCursor | |
TraceReadCursor Int |
Instances
Show CursorTrace Source # | |
Defined in Database.LSMTree.Internal.Unsafe Methods showsPrec :: Int -> CursorTrace -> ShowS # show :: CursorTrace -> String # showList :: [CursorTrace] -> 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
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:
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 # |
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) | |
=> OverrideDiskCachePolicy | |
-> 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
.