Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Database.LSMTree.Internal.Types
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 BlobRef m b = forall h.Typeable h => BlobRef !(WeakBlobRef m h)
- data Cursor m k v b = forall h.Typeable h => Cursor !(Cursor m h)
- class ResolveValue v where
- resolveCompatibility :: (SerialiseValue v, ResolveValue v) => v -> v -> Bool
- resolveAssociativity :: (SerialiseValue v, ResolveValue v) => v -> v -> v -> Bool
- resolveValidOutput :: (SerialiseValue v, ResolveValue v, NFData v) => v -> v -> Bool
- newtype ResolveViaSemigroup v = ResolveViaSemigroup v
- newtype ResolveAsFirst v = ResolveAsFirst {
- unResolveAsFirst :: v
Documentation
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.
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.
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) |
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.
class ResolveValue v where Source #
An instance of
specifies how to merge values when using
monoidal upsert.ResolveValue
v
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
andresolveSerialised
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
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
.
default resolveSerialised :: SerialiseValue v => Proxy v -> RawBytes -> RawBytes -> RawBytes Source #
Instances
(Num v, SerialiseValue v) => ResolveValue (Sum v) Source # | |
ResolveValue (ResolveAsFirst v) Source # | |
Defined in Database.LSMTree.Internal.Types Methods resolve :: ResolveAsFirst v -> ResolveAsFirst v -> ResolveAsFirst v Source # resolveSerialised :: Proxy (ResolveAsFirst v) -> RawBytes -> RawBytes -> RawBytes Source # | |
(SerialiseValue v, Semigroup v) => ResolveValue (ResolveViaSemigroup v) Source # | |
Defined in Database.LSMTree.Internal.Types Methods resolve :: ResolveViaSemigroup v -> ResolveViaSemigroup v -> ResolveViaSemigroup v Source # resolveSerialised :: Proxy (ResolveViaSemigroup v) -> RawBytes -> RawBytes -> RawBytes Source # |
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 |
Instances
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
|
Instances
Show v => Show (ResolveAsFirst v) Source # | |
Defined in Database.LSMTree.Internal.Types Methods showsPrec :: Int -> ResolveAsFirst v -> ShowS # show :: ResolveAsFirst v -> String # showList :: [ResolveAsFirst v] -> ShowS # | |
Eq v => Eq (ResolveAsFirst v) Source # | |
Defined in Database.LSMTree.Internal.Types Methods (==) :: ResolveAsFirst v -> ResolveAsFirst v -> Bool # (/=) :: ResolveAsFirst v -> ResolveAsFirst v -> Bool # | |
SerialiseValue v => SerialiseValue (ResolveAsFirst v) Source # | |
Defined in Database.LSMTree.Internal.Types Methods serialiseValue :: ResolveAsFirst v -> RawBytes Source # deserialiseValue :: RawBytes -> ResolveAsFirst v Source # | |
ResolveValue (ResolveAsFirst v) Source # | |
Defined in Database.LSMTree.Internal.Types Methods resolve :: ResolveAsFirst v -> ResolveAsFirst v -> ResolveAsFirst v Source # resolveSerialised :: Proxy (ResolveAsFirst v) -> RawBytes -> RawBytes -> RawBytes Source # |