lsm-tree-0.1.0.0: Log-structured merge-trees
Safe HaskellSafe-Inferred
LanguageGHC2021

Database.LSMTree.Internal.Types

Synopsis

Documentation

data Session m Source #

A session stores context that is shared by multiple tables.

Each session is associated with one session directory where the files containing table data are stored. Each session locks its session directory. There can only be one active session for each session directory at a time. If a database is must be accessed from multiple parts of a program, one session should be opened and shared between those parts of the program. Session directories cannot be shared between OS processes.

A session may contain multiple tables, which may each have a different configuration and different key, value, and BLOB types. Furthermore, sessions may contain both simple and full-featured tables.

Constructors

forall h.Typeable h => Session !(Session m h) 

Instances

Instances details
NFData (Session m) Source # 
Instance details

Defined in Database.LSMTree.Internal.Types

Methods

rnf :: Session m -> () #

data Table m k v b Source #

A table is a handle to an individual LSM-tree key/value store with both in-memory and on-disk parts.

Warning: Tables are ephemeral. Once you close a table, its data is lost forever. To persist tables, use snapshots.

Constructors

forall h.Typeable h => Table !(Table m h) 

Instances

Instances details
NFData (Table m k v b) Source # 
Instance details

Defined in Database.LSMTree.Internal.Types

Methods

rnf :: Table m k v b -> () #

data BlobRef m b Source #

A blob reference is a reference to an on-disk blob.

Warning: A blob reference is not stable. Any operation that modifies the table, cursor, or session that corresponds to a blob reference may cause it to be invalidated.

The word "blob" in this type comes from the acronym Binary Large Object.

Constructors

forall h.Typeable h => BlobRef !(WeakBlobRef m h) 

Instances

Instances details
Show (BlobRef m b) Source # 
Instance details

Defined in Database.LSMTree.Internal.Types

Methods

showsPrec :: Int -> BlobRef m b -> ShowS #

show :: BlobRef m b -> String #

showList :: [BlobRef m b] -> ShowS #

data Cursor m k v b Source #

A cursor is a stable read-only iterator for a table.

A cursor iterates over the entries in a table following the order of the serialised keys. After the cursor is created, updates to the referenced table do not affect the cursor.

The name of this type references database cursors, not, e.g., text editor cursors.

Constructors

forall h.Typeable h => Cursor !(Cursor m h) 

Instances

Instances details
NFData (Cursor m k v b) Source # 
Instance details

Defined in Database.LSMTree.Internal.Types

Methods

rnf :: Cursor m k v b -> () #

class ResolveValue v where Source #

An instance of ResolveValue v specifies how to merge values when using monoidal upsert.

The class has two functions. The function resolve acts on values, whereas the function resolveSerialised acts on serialised values. Each function has a default implementation in terms of the other and serialisation/deserialisation. The user is encouraged to implement resolveSerialised.

Instances should satisfy the following:

Compatibility
The functions resolve and resolveSerialised should be compatible:
serialiseValue (resolve v1 v2) == resolveSerialised (Proxy @v) (serialiseValue v1) (serialiseValue v2)
Associativity
The function resolve should be associative:
serialiseValue (v1 `resolve` (v2 `resolve` v3)) == serialiseValue ((v1 `resolve` v2) `resolve` v3)
Valid Output
The function resolveSerialised should only return deserialisable values:
deserialiseValue (resolveSerialised (Proxy @v) rb1 rb2) `deepseq` True

Minimal complete definition

resolve | resolveSerialised

Methods

resolve :: v -> v -> v Source #

Combine two values.

default resolve :: SerialiseValue v => v -> v -> v Source #

resolveSerialised :: Proxy v -> RawBytes -> RawBytes -> RawBytes Source #

Combine two serialised values.

The user may assume that the input bytes are valid and can be deserialised using deserialiseValue. The inputs are only ever produced by serialiseValue and resolveSerialised.

resolveCompatibility :: (SerialiseValue v, ResolveValue v) => v -> v -> Bool Source #

Test the Compatibility law for the ResolveValue class.

resolveAssociativity :: (SerialiseValue v, ResolveValue v) => v -> v -> v -> Bool Source #

Test the Associativity law for the ResolveValue class.

resolveValidOutput :: (SerialiseValue v, ResolveValue v, NFData v) => v -> v -> Bool Source #

Test the Valid Output law for the ResolveValue class.

newtype ResolveViaSemigroup v Source #

Wrapper that provides an instance of ResolveValue via the Semigroup instance of the underlying type.

resolve (ResolveViaSemigroup v1) (ResolveViaSemigroup v2) = ResolveViaSemigroup (v1 <> v2)

Constructors

ResolveViaSemigroup v 

newtype ResolveAsFirst v Source #

Wrapper that provides an instance of ResolveValue such that upsert behaves as insert.

The name ResolveAsFirst is in reference to the wrapper First from Data.Semigroup.

resolve = const

Constructors

ResolveAsFirst 

Fields