ouroboros-consensus:lsm
Safe HaskellNone
LanguageHaskell2010

Ouroboros.Consensus.Storage.LedgerDB.V2.LSM

Description

Implementation of the LedgerTablesHandle interface with LSM trees.

Synopsis

Backend API

data LSM Source #

Instances

Instances details
(LedgerSupportsProtocol blk, IOLike m, LedgerDbSerialiseConstraints blk, HasLedgerTables LedgerState blk) ⇒ Backend m LSM blk Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V2.LSM

(LSMConstraints l blk, IOLike m) ⇒ StreamingBackend m LSM l blk Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V2.LSM

Associated Types

data YieldArgs m LSM l blk 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V2.LSM

data YieldArgs m LSM l blk = YieldLSM Int (LedgerTablesHandle m l blk) (Session m) (SomeHasFSAndBlockIO m) (m ())
data SinkArgs m LSM l blk 
Instance details

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 ())

Methods

yield ∷ Proxy LSM → YieldArgs m LSM l blk → Yield m l blk Source #

releaseYieldArgs ∷ YieldArgs m LSM l blk → m () Source #

sink ∷ Proxy LSM → SinkArgs m LSM l blk → Sink m l blk Source #

releaseSinkArgs ∷ SinkArgs m LSM l blk → m () Source #

Show (Trace LSM) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V2.LSM

Methods

showsPrec ∷ Int → Trace LSM → ShowS #

show ∷ Trace LSM → String #

showList ∷ [Trace LSM] → ShowS #

Generic (Resources m LSM) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V2.LSM

Associated Types

type Rep (Resources m LSM) 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V2.LSM

type Rep (Resources m LSM)

Methods

from ∷ Resources m LSM → Rep (Resources m LSM) x #

to ∷ Rep (Resources m LSM) x → Resources m LSM #

IOLike m ⇒ NoThunks (Resources m LSM) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V2.LSM

data Trace LSM Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V2.LSM

data SinkArgs m LSM l blk Source # 
Instance details

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 ())
data YieldArgs m LSM l blk Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V2.LSM

data YieldArgs m LSM l blk = YieldLSM Int (LedgerTablesHandle m l blk) (Session m) (SomeHasFSAndBlockIO m) (m ())
data Args m LSM Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V2.LSM

data Resources m LSM Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V2.LSM

type Rep (Resources m LSM) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V2.LSM

type Rep (Resources m LSM)

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.

data Trace backend Source #

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 #

Transform Args into Resources, with some context made up of LedgerDbArgs.

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

Instances details
(IOLike m, LedgerDbSerialiseConstraints blk, LedgerSupportsProtocol blk, CanUpgradeLedgerTables LedgerState blk) ⇒ Backend m Mem blk Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V2.InMemory

Associated Types

data Args m Mem 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V2.InMemory

data Args m Mem = InMemArgs
newtype Resources m Mem 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V2.InMemory

newtype Trace Mem 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V2.InMemory

newtype Trace Mem = NoTrace Void
(LedgerSupportsProtocol blk, IOLike m, LedgerDbSerialiseConstraints blk, HasLedgerTables LedgerState blk) ⇒ Backend m LSM blk Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V2.LSM

data family Args (m ∷ Type → Type) backend Source #

The Arguments that will be used initially to create the Resources.

Instances

Instances details
data Args m Mem Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V2.InMemory

data Args m Mem = InMemArgs
data Args m LSM Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V2.LSM

data family Trace backend Source #

A trace dependent on the particular backend.

mkLSMArgsIO Source #

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 DiskCachePolicy.

→ 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 #

Instances

Instances details
data YieldArgs m Mem l blk Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V2.InMemory

data YieldArgs m LSM l blk Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V2.LSM

data YieldArgs m LSM l blk = YieldLSM Int (LedgerTablesHandle m l blk) (Session m) (SomeHasFSAndBlockIO m) (m ())

mkLSMYieldArgs 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 slotno[_suffix].

→ (FilePath → WithTempRegistry () m (SomeHasFSAndBlockIO m))

Usually stdMkBlockIOFS

→ m StdGen

Usually newStdGen

→ 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

The complete name of the snapshot, so slotno[_suffix].

→ (FilePath → WithTempRegistry () m (SomeHasFSAndBlockIO m))

Usually stdMkBlockIOFS

→ (FilePath → SomeHasFS m)

Usually ioHasFS

→ m StdGen

Usually newStdGen

→ 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

Instances details
data SinkArgs m Mem l blk Source # 
Instance details

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 # 
Instance details

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 ())

mkLSMSinkArgs Source #

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 ......ledger/slotno[_suffix].

→ SomeHasFS m

Usually ioHasFS

→ (FilePath → WithTempRegistry () m (SomeHasFSAndBlockIO m))

Usually stdMkBlockIOFS

→ m StdGen

Usually newStdGen

→ 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

The complete name of the snapshot, so slotno[_suffix].

→ SomeHasFS m

Usually ioHasFS, for the LedgerDB snapshot (state/meta) files.

→ (FilePath → WithTempRegistry () m (SomeHasFSAndBlockIO m))

Usually stdMkBlockIOFS

→ m StdGen

Usually newStdGen

→ 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

lsmDbExportSnapshot Source #

Arguments

∷ FilePath

The LSM database (session) directory.

→ String

The name of the snapshot to export, so slotno[_suffix].

→ 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.

lsmDbImportSnapshot Source #

Arguments

∷ FilePath

The LSM database (session) directory. Created if it does not exist; must be empty otherwise.

→ String

The name to give the imported snapshot, so slotno[_suffix].

→ 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

type Salt = Word64 #

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 #

Instances

Instances details
NFData DiskCachePolicy # 
Instance details

Defined in Database.LSMTree.Internal.Config

Methods

rnf ∷ DiskCachePolicy → () #

Eq DiskCachePolicy # 
Instance details

Defined in Database.LSMTree.Internal.Config

Show DiskCachePolicy # 
Instance details

Defined in Database.LSMTree.Internal.Config

Override DiskCachePolicy TableConfig # 
Instance details

Defined in Database.LSMTree.Internal.Config.Override

Override DiskCachePolicy SnapshotMetaData # 
Instance details

Defined in Database.LSMTree.Internal.Config.Override

Methods

override ∷ DiskCachePolicy → SnapshotMetaData → SnapshotMetaData

Override DiskCachePolicy (SnapLevels SnapshotRun) # 
Instance details

Defined in Database.LSMTree.Internal.Config.Override

Methods

override ∷ DiskCachePolicy → SnapLevels SnapshotRun → SnapLevels SnapshotRun

Orphan instances

NoThunks (Table m txin txout Void) Source # 
Instance details

Methods

noThunks ∷ Context → Table m txin txout Void → IO (Maybe ThunkInfo) Source #

wNoThunks ∷ Context → Table m txin txout Void → IO (Maybe ThunkInfo) Source #

showTypeOf ∷ Proxy (Table m txin txout Void) → String Source #