| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Ouroboros.Consensus.Storage.LedgerDB.V2.LSM
Description
Implementation of the LedgerTablesHandle interface with LSM trees.
Synopsis
- data LSM
- class NoThunks (Resources m backend) ⇒ Backend (m ∷ Type → Type) backend blk where
- data Args (m ∷ Type → Type) backend
- data Resources (m ∷ Type → Type) backend
- data Trace backend
- mkResources ∷ Proxy blk → Tracer m LedgerDBV2Trace → Args m backend → SomeHasFS m → WithTempRegistry fState m (Resources m backend)
- releaseResources ∷ Proxy blk → Resources m backend → m ()
- createAndPopulateStateRefFromGenesis ∷ Tracer m LedgerDBV2Trace → Resources m backend → ExtLedgerState blk ValuesMK → m (StateRef m ExtLedgerState blk)
- openStateRefFromSnapshot ∷ Tracer m LedgerDBV2Trace → CodecConfig blk → SomeHasFS m → Resources m backend → DiskSnapshot → ExceptT (SnapshotFailure blk) m (StateRef m ExtLedgerState blk, RealPoint blk)
- snapshotManager ∷ Proxy blk → Resources m backend → CodecConfig blk → Tracer m (TraceSnapshotEvent blk) → SomeHasFS m → SnapshotManager m blk (StateRef m ExtLedgerState blk)
- data family Args (m ∷ Type → Type) backend
- data family Trace backend
- data LSMTreeTrace
- mkLSMArgsIO ∷ (LedgerSupportsProtocol blk, LedgerDbSerialiseConstraints blk) ⇒ Proxy blk → FilePath → Maybe FilePath → FilePath → DiskCachePolicy → StdGen → (LedgerDbBackendArgs IO blk, StdGen)
- stdMkBlockIOFS ∷ FilePath → WithTempRegistry st IO (SomeHasFSAndBlockIO IO)
- data family YieldArgs (m ∷ Type → Type) backend (l ∷ Type → (Type → Type → Type) → Type) blk
- mkLSMYieldArgs ∷ ∀ m (l ∷ StateKind) blk. (IOLike m, LSMConstraints l blk) ⇒ FilePath → DiskSnapshot → (FilePath → WithTempRegistry () m (SomeHasFSAndBlockIO m)) → m StdGen → m (YieldArgs m LSM l blk)
- mkExportedLSMYieldArgs ∷ ∀ m (l ∷ StateKind) blk. (IOLike m, LSMConstraints l blk) ⇒ FilePath → DiskSnapshot → (FilePath → WithTempRegistry () m (SomeHasFSAndBlockIO m)) → (FilePath → SomeHasFS m) → m StdGen → m (YieldArgs m LSM l blk)
- data family SinkArgs (m ∷ Type → Type) backend (l ∷ Type → (Type → Type → Type) → Type) blk
- mkLSMSinkArgs ∷ ∀ m (l ∷ Type → (Type → Type → Type) → Type) blk. IOLike m ⇒ FilePath → DiskSnapshot → SomeHasFS m → (FilePath → WithTempRegistry () m (SomeHasFSAndBlockIO m)) → m StdGen → m (SinkArgs m LSM l blk)
- mkExportedLSMSinkArgs ∷ ∀ m (l ∷ Type → (Type → Type → Type) → Type) blk. IOLike m ⇒ FilePath → DiskSnapshot → SomeHasFS m → (FilePath → WithTempRegistry () m (SomeHasFSAndBlockIO m)) → m StdGen → m (SinkArgs m LSM l blk)
- lsmDbExportSnapshot ∷ FilePath → String → FilePath → IO ()
- lsmDbImportSnapshot ∷ FilePath → String → FilePath → IO ()
- type Salt = Word64
- data SomeHasFSAndBlockIO (m ∷ Type → Type) where
- SomeHasFSAndBlockIO ∷ ∀ h (m ∷ Type → Type). (Eq h, Typeable h) ⇒ HasFS m h → HasBlockIO m h → SomeHasFSAndBlockIO m
- data DiskCachePolicy
Backend API
Instances
class NoThunks (Resources m backend) ⇒ Backend (m ∷ Type → Type) backend blk where Source #
Operations needed to open and operate a LedgerDB V2
Associated Types
data Args (m ∷ Type → Type) backend Source #
The Arguments that will be used initially to create the Resources.
data Resources (m ∷ Type → Type) backend Source #
The Resources that will be stored in the LedgerDB environment and given to the handle operations.
A trace dependent on the particular backend.
Methods
mkResources ∷ Proxy blk → Tracer m LedgerDBV2Trace → Args m backend → SomeHasFS m → WithTempRegistry fState m (Resources m backend) Source #
releaseResources ∷ Proxy blk → Resources m backend → m () Source #
Release the acquired resources.
createAndPopulateStateRefFromGenesis ∷ Tracer m LedgerDBV2Trace → Resources m backend → ExtLedgerState blk ValuesMK → m (StateRef m ExtLedgerState blk) Source #
Create a new handle from the given Genesis state.
openStateRefFromSnapshot ∷ Tracer m LedgerDBV2Trace → CodecConfig blk → SomeHasFS m → Resources m backend → DiskSnapshot → ExceptT (SnapshotFailure blk) m (StateRef m ExtLedgerState blk, RealPoint blk) Source #
Create a new handle from a snapshot.
snapshotManager ∷ Proxy blk → Resources m backend → CodecConfig blk → Tracer m (TraceSnapshotEvent blk) → SomeHasFS m → SnapshotManager m blk (StateRef m ExtLedgerState blk) Source #
Instantiate the SnapshotManager for this backend.
Instances
| (IOLike m, LedgerDbSerialiseConstraints blk, LedgerSupportsProtocol blk, CanUpgradeLedgerTables LedgerState blk) ⇒ Backend m Mem blk Source # | |||||||||||||
Defined in Ouroboros.Consensus.Storage.LedgerDB.V2.InMemory Methods mkResources ∷ Proxy blk → Tracer m LedgerDBV2Trace → Args m Mem → SomeHasFS m → WithTempRegistry fState m (Resources m Mem) Source # releaseResources ∷ Proxy blk → Resources m Mem → m () Source # createAndPopulateStateRefFromGenesis ∷ Tracer m LedgerDBV2Trace → Resources m Mem → ExtLedgerState blk ValuesMK → m (StateRef m ExtLedgerState blk) Source # openStateRefFromSnapshot ∷ Tracer m LedgerDBV2Trace → CodecConfig blk → SomeHasFS m → Resources m Mem → DiskSnapshot → ExceptT (SnapshotFailure blk) m (StateRef m ExtLedgerState blk, RealPoint blk) Source # snapshotManager ∷ Proxy blk → Resources m Mem → CodecConfig blk → Tracer m (TraceSnapshotEvent blk) → SomeHasFS m → SnapshotManager m blk (StateRef m ExtLedgerState blk) Source # | |||||||||||||
| (LedgerSupportsProtocol blk, IOLike m, LedgerDbSerialiseConstraints blk, HasLedgerTables LedgerState blk) ⇒ Backend m LSM blk Source # | |||||||||||||
Defined in Ouroboros.Consensus.Storage.LedgerDB.V2.LSM Associated Types
Methods mkResources ∷ Proxy blk → Tracer m LedgerDBV2Trace → Args m LSM → SomeHasFS m → WithTempRegistry fState m (Resources m LSM) Source # releaseResources ∷ Proxy blk → Resources m LSM → m () Source # createAndPopulateStateRefFromGenesis ∷ Tracer m LedgerDBV2Trace → Resources m LSM → ExtLedgerState blk ValuesMK → m (StateRef m ExtLedgerState blk) Source # openStateRefFromSnapshot ∷ Tracer m LedgerDBV2Trace → CodecConfig blk → SomeHasFS m → Resources m LSM → DiskSnapshot → ExceptT (SnapshotFailure blk) m (StateRef m ExtLedgerState blk, RealPoint blk) Source # snapshotManager ∷ Proxy blk → Resources m LSM → CodecConfig blk → Tracer m (TraceSnapshotEvent blk) → SomeHasFS m → SnapshotManager m blk (StateRef m ExtLedgerState blk) Source # | |||||||||||||
data family Args (m ∷ Type → Type) backend Source #
The Arguments that will be used initially to create the Resources.
Instances
| data Args m Mem Source # | |
| data Args m LSM Source # | |
Defined in Ouroboros.Consensus.Storage.LedgerDB.V2.LSM data Args m LSM = LSMArgs FsPath (Maybe FsPath) Salt DiskCachePolicy (∀ st. WithTempRegistry st m (SomeHasFSAndBlockIO m)) | |
data family Trace backend Source #
A trace dependent on the particular backend.
data LSMTreeTrace #
Constructors
| TraceSession SessionId SessionTrace | |
| TraceTable TableId TableTrace | |
| TraceCursor CursorId CursorTrace |
Instances
| Eq LSMTreeTrace # | |
Defined in Database.LSMTree.Internal.Unsafe | |
| Show LSMTreeTrace # | |
Defined in Database.LSMTree.Internal.Unsafe Methods showsPrec ∷ Int → LSMTreeTrace → ShowS # show ∷ LSMTreeTrace → String # showList ∷ [LSMTreeTrace] → ShowS # | |
Arguments
| ∷ (LedgerSupportsProtocol blk, LedgerDbSerialiseConstraints blk) | |
| ⇒ Proxy blk | |
| → FilePath | LSM database path, relative to the FS root. |
| → Maybe FilePath | LSM export path, relative to the FS root. |
| → FilePath | Root for the LSM filesystem. |
| → DiskCachePolicy | Disk cache policy for the UTxO table, see |
| → StdGen | |
| → (LedgerDbBackendArgs IO blk, StdGen) |
Create arguments for initializing the LedgerDB using the LSM-trees backend.
Streaming
data family YieldArgs (m ∷ Type → Type) backend (l ∷ Type → (Type → Type → Type) → Type) blk Source #
Arguments
| ∷ ∀ m (l ∷ StateKind) blk. (IOLike m, LSMConstraints l blk) | |
| ⇒ FilePath | The filepath in which the LSM database lives. Must not have a trailing slash! |
| → DiskSnapshot | The complete name of the snapshot to open, so |
| → (FilePath → WithTempRegistry () m (SomeHasFSAndBlockIO m)) | Usually |
| → m StdGen | Usually |
| → m (YieldArgs m LSM l blk) |
Create Yield arguments for LSM
mkExportedLSMYieldArgs Source #
Arguments
| ∷ ∀ m (l ∷ StateKind) blk. (IOLike m, LSMConstraints l blk) | |
| ⇒ FilePath | The directory containing the exported snapshot. Must not have a trailing slash! |
| → DiskSnapshot | |
| → (FilePath → WithTempRegistry () m (SomeHasFSAndBlockIO m)) | Usually |
| → (FilePath → SomeHasFS m) | Usually |
| → m StdGen | Usually |
| → m (YieldArgs m LSM l blk) |
Create Yield arguments for a standalone (exported) LSM snapshot.
Unlike mkLSMYieldArgs, which reads a snapshot out of a live LSM database,
this opens a temporary scratch session next to the exported snapshot,
imports the exported snapshot into it, and then streams it as usual. The
scratch session is removed by releaseYieldArgs.
The scratch session is created in the parent directory of the exported snapshot, so that it lives on the same volume (a requirement of importing).
data family SinkArgs (m ∷ Type → Type) backend (l ∷ Type → (Type → Type → Type) → Type) blk Source #
Instances
| data SinkArgs m Mem l blk Source # | |
Defined in Ouroboros.Consensus.Storage.LedgerDB.V2.InMemory data SinkArgs m Mem l blk = SinkInMemory Int (TxIn blk → Encoding) (TxOut blk → Encoding) (SomeHasFS m) DiskSnapshot | |
| data SinkArgs m LSM l blk Source # | |
Defined in Ouroboros.Consensus.Storage.LedgerDB.V2.LSM data SinkArgs m LSM l blk = SinkLSM Int (SomeHasFS m) (SomeHasFSAndBlockIO m) DiskSnapshot (Session m) (m ()) (m ()) | |
Arguments
| ∷ ∀ m (l ∷ Type → (Type → Type → Type) → Type) blk. IOLike m | |
| ⇒ FilePath | The filepath for the LSM database |
| → DiskSnapshot | The filepath to the snapshot to be created, so |
| → SomeHasFS m | Usually |
| → (FilePath → WithTempRegistry () m (SomeHasFSAndBlockIO m)) | Usually |
| → m StdGen | Usually |
| → m (SinkArgs m LSM l blk) |
Create Sink arguments for LSM
mkExportedLSMSinkArgs Source #
Arguments
| ∷ ∀ m (l ∷ Type → (Type → Type → Type) → Type) blk. IOLike m | |
| ⇒ FilePath | The destination directory for the exported snapshot. It will be (re)created, and must not have a trailing slash! |
| → DiskSnapshot | |
| → SomeHasFS m | Usually |
| → (FilePath → WithTempRegistry () m (SomeHasFSAndBlockIO m)) | Usually |
| → m StdGen | Usually |
| → m (SinkArgs m LSM l blk) |
Create Sink arguments for a standalone (exported) LSM snapshot.
Unlike mkLSMSinkArgs, which sinks into a live LSM database, this sinks into
a temporary scratch session next to the destination directory, and then
exports the resulting snapshot to that directory (see exportSnapshot).
The scratch session is removed by releaseSinkArgs.
The scratch session is created in the parent directory of the destination, so
that it lives on the same volume (a requirement of exportSnapshot).
Standalone (exported) snapshots
Arguments
| ∷ FilePath | The LSM database (session) directory. |
| → String | |
| → FilePath | The destination directory, which must not exist yet. |
| → IO () |
Export a snapshot out of a (offline) LSM database into a standalone directory, which must not exist yet.
The database session and the destination must live on the same volume.
Arguments
| ∷ FilePath | The LSM database (session) directory. Created if it does not exist; must be empty otherwise. |
| → String | |
| → FilePath | The source directory containing the exported snapshot. |
| → IO () |
Import a snapshot from a standalone directory into a new (offline) LSM database, created at the given (empty or absent) directory.
The database session and the source must live on the same volume.
Exported for tests
data SomeHasFSAndBlockIO (m ∷ Type → Type) where Source #
Constructors
| SomeHasFSAndBlockIO ∷ ∀ h (m ∷ Type → Type). (Eq h, Typeable h) ⇒ HasFS m h → HasBlockIO m h → SomeHasFSAndBlockIO m |
Disk cache policy
data DiskCachePolicy #
Constructors
| DiskCacheAll | |
| DiskCacheLevelOneTo !Int | |
| DiskCacheNone |
Instances
| NFData DiskCachePolicy # | |
Defined in Database.LSMTree.Internal.Config Methods rnf ∷ DiskCachePolicy → () # | |
| Eq DiskCachePolicy # | |
Defined in Database.LSMTree.Internal.Config Methods (==) ∷ DiskCachePolicy → DiskCachePolicy → Bool # (/=) ∷ DiskCachePolicy → DiskCachePolicy → Bool # | |
| Show DiskCachePolicy # | |
Defined in Database.LSMTree.Internal.Config Methods showsPrec ∷ Int → DiskCachePolicy → ShowS # show ∷ DiskCachePolicy → String # showList ∷ [DiskCachePolicy] → ShowS # | |
| Override DiskCachePolicy TableConfig # | |
Defined in Database.LSMTree.Internal.Config.Override Methods | |
| Override DiskCachePolicy SnapshotMetaData # | |
Defined in Database.LSMTree.Internal.Config.Override Methods override ∷ DiskCachePolicy → SnapshotMetaData → SnapshotMetaData | |
| Override DiskCachePolicy (SnapLevels SnapshotRun) # | |
Defined in Database.LSMTree.Internal.Config.Override Methods override ∷ DiskCachePolicy → SnapLevels SnapshotRun → SnapLevels SnapshotRun | |