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

Database.LSMTree.Internal.Serialise

Description

Newtype wrappers and utilities for serialised keys, values and blobs.

Synopsis

Re-exports

class SerialiseKey k 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.

Minimal complete definition

serialiseKey, deserialiseKey

class SerialiseValue v 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

Minimal complete definition

serialiseValue, deserialiseValue

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

Keys

newtype SerialisedKey Source #

Representation of a serialised key.

Serialisation should preserve equality and ordering. The Ord instance for SerialisedKey uses lexicographical ordering.

Constructors

SerialisedKey RawBytes 

Bundled Patterns

pattern SerialisedKey' :: Vector Word8 -> SerialisedKey 

Instances

Instances details
Show SerialisedKey Source # 
Instance details

Defined in Database.LSMTree.Internal.Serialise

NFData SerialisedKey Source # 
Instance details

Defined in Database.LSMTree.Internal.Serialise

Methods

rnf :: SerialisedKey -> () #

Eq SerialisedKey Source # 
Instance details

Defined in Database.LSMTree.Internal.Serialise

Ord SerialisedKey Source # 
Instance details

Defined in Database.LSMTree.Internal.Serialise

Hashable SerialisedKey Source # 
Instance details

Defined in Database.LSMTree.Internal.Serialise

Show (Unsliced SerialisedKey) Source # 
Instance details

Defined in Database.LSMTree.Internal.Unsliced

Eq (Unsliced SerialisedKey) Source # 
Instance details

Defined in Database.LSMTree.Internal.Unsliced

Ord (Unsliced SerialisedKey) Source # 
Instance details

Defined in Database.LSMTree.Internal.Unsliced

sizeofKey :: SerialisedKey -> Int Source #

Size of key in number of bytes.

sizeofKey16 :: SerialisedKey -> Word16 Source #

Size of key in number of bytes.

sizeofKey32 :: SerialisedKey -> Word32 Source #

Size of key in number of bytes.

sizeofKey64 :: SerialisedKey -> Word64 Source #

Size of key in number of bytes.

Values

sizeofValue16 :: SerialisedValue -> Word16 Source #

Size of value in number of bytes.

sizeofValue32 :: SerialisedValue -> Word32 Source #

Size of value in number of bytes.

sizeofValue64 :: SerialisedValue -> Word64 Source #

Size of value in number of bytes.

Blobs

sizeofBlob :: SerialisedBlob -> Int Source #

Size of blob in number of bytes.