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

Database.LSMTree.Internal.Serialise.Class

Contents

Description

Public API for serialisation of keys, blobs and values

Synopsis

Documentation

class SerialiseKey k where Source #

Serialisation of keys.

Instances should satisfy the following:

Identity
deserialiseKey (serialiseKey x) == x
Identity up to slicing
deserialiseKey (packSlice prefix (serialiseKey x) suffix) == x

Instances may satisfy the following:

Ordering-preserving
x `compare` y == serialiseKey x `compare` serialiseKey y

Raw bytes are lexicographically ordered, so in particular this means that values should be serialised into big-endian formats. This constraint mainly exists for range queries, where the range is specified in terms of unserialised values, but the internal implementation works on the serialised representation.

serialiseKeyIdentity :: (Eq k, SerialiseKey k) => k -> Bool Source #

Test the Identity law for the SerialiseKey class

serialiseKeyIdentityUpToSlicing :: (Eq k, SerialiseKey k) => RawBytes -> k -> RawBytes -> Bool Source #

Test the Identity up to slicing law for the SerialiseKey class

serialiseKeyPreservesOrdering :: (Ord k, SerialiseKey k) => k -> k -> Bool Source #

Test the Ordering-preserving law for the SerialiseKey class

serialiseKeyMinimalSize :: SerialiseKey k => k -> Bool Source #

Test the Minimal size law for the SerialiseKey class.

class SerialiseValue v where Source #

Serialisation of values and blobs.

Instances should satisfy the following:

Identity
deserialiseValue (serialiseValue x) == x
Identity up to slicing
deserialiseValue (packSlice prefix (serialiseValue x) suffix) == x

Instances

Instances details
SerialiseValue ByteArray Source #

The Ord instance of ByteArray is not lexicographic, so there cannot be an order-preserving instance of SerialiseKey. Use ShortByteString instead.

Instance details

Defined in Database.LSMTree.Internal.Serialise.Class

SerialiseValue Void Source #

The deserialiseValue of this instance throws. (as does e.g. Word64 instance on invalid input.)

This instance is useful for tables without blobs.

Instance details

Defined in Database.LSMTree.Internal.Serialise.Class

SerialiseValue Word64 Source # 
Instance details

Defined in Database.LSMTree.Internal.Serialise.Class

SerialiseValue ByteString Source #

Placeholder instance, not optimised

Instance details

Defined in Database.LSMTree.Internal.Serialise.Class

SerialiseValue ByteString Source #

Placeholder instance, not optimised

Instance details

Defined in Database.LSMTree.Internal.Serialise.Class

SerialiseValue ShortByteString Source # 
Instance details

Defined in Database.LSMTree.Internal.Serialise.Class

SerialiseValue a => SerialiseValue (Sum a) Source #

An instance for Sum which is transparent to the serialisation of a.

Note: If you want to serialize Sum a differently than a, then you should create another newtype over Sum and define your alternative serialization.

Instance details

Defined in Database.LSMTree.Internal.Serialise.Class

SerialiseValue v => SerialiseValue (ResolveAsFirst v) Source # 
Instance details

Defined in Database.LSMTree

serialiseValueIdentity :: (Eq v, SerialiseValue v) => v -> Bool Source #

Test the Identity law for the SerialiseValue class

serialiseValueIdentityUpToSlicing :: (Eq v, SerialiseValue v) => RawBytes -> v -> RawBytes -> Bool Source #

Test the Identity up to slicing law for the SerialiseValue class

newtype RawBytes Source #

Raw bytes with no alignment constraint (i.e. byte aligned), and no guarantee of pinned or unpinned memory (i.e. could be either).

Constructors

RawBytes (Vector Word8) 

Instances

Instances details
IsString RawBytes Source #

Mostly to make test cases shorter to write.

Instance details

Defined in Database.LSMTree.Internal.RawBytes

Monoid RawBytes Source # 
Instance details

Defined in Database.LSMTree.Internal.RawBytes

Semigroup RawBytes Source # 
Instance details

Defined in Database.LSMTree.Internal.RawBytes

IsList RawBytes Source # 
Instance details

Defined in Database.LSMTree.Internal.RawBytes

Associated Types

type Item RawBytes #

Show RawBytes Source # 
Instance details

Defined in Database.LSMTree.Internal.RawBytes

NFData RawBytes Source # 
Instance details

Defined in Database.LSMTree.Internal.RawBytes

Methods

rnf :: RawBytes -> () #

Eq RawBytes Source # 
Instance details

Defined in Database.LSMTree.Internal.RawBytes

Ord RawBytes Source #

Lexicographical Ord instance.

Instance details

Defined in Database.LSMTree.Internal.RawBytes

Hashable RawBytes Source # 
Instance details

Defined in Database.LSMTree.Internal.RawBytes

type Item RawBytes Source # 
Instance details

Defined in Database.LSMTree.Internal.RawBytes

packSlice :: RawBytes -> RawBytes -> RawBytes -> RawBytes Source #

packSlice prefix x suffix makes x into a slice with prefix bytes on the left and suffix bytes on the right.

Errors

requireBytesExactly :: String -> Int -> Int -> a -> a Source #

requireBytesExactly tyName expected actual x