| Safe Haskell | Safe-Inferred | 
|---|---|
| Language | GHC2021 | 
Database.LSMTree.Internal.Serialise.Class
Description
Public API for serialisation of keys, blobs and values
Synopsis
- class SerialiseKey k where
- serialiseKey :: k -> RawBytes
 - deserialiseKey :: RawBytes -> k
 
 - serialiseKeyIdentity :: (Eq k, SerialiseKey k) => k -> Bool
 - serialiseKeyIdentityUpToSlicing :: (Eq k, SerialiseKey k) => RawBytes -> k -> RawBytes -> Bool
 - class SerialiseKey k => SerialiseKeyOrderPreserving k
 - serialiseKeyPreservesOrdering :: (Ord k, SerialiseKey k) => k -> k -> Bool
 - class SerialiseValue v where
- serialiseValue :: v -> RawBytes
 - deserialiseValue :: RawBytes -> v
 
 - serialiseValueIdentity :: (Eq v, SerialiseValue v) => v -> Bool
 - serialiseValueIdentityUpToSlicing :: (Eq v, SerialiseValue v) => RawBytes -> v -> RawBytes -> Bool
 - newtype RawBytes = RawBytes (Vector Word8)
 - packSlice :: RawBytes -> RawBytes -> RawBytes -> RawBytes
 - requireBytesExactly :: String -> Int -> Int -> a -> a
 
SerialiseKey
class SerialiseKey k where Source #
Serialisation of keys.
Instances should satisfy the following laws:
- Identity
 deserialiseKey(serialiseKeyx) == x- Identity up to slicing
 deserialiseKey(packSliceprefix (serialiseKeyx) suffix) == x
Instances
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
class SerialiseKey k => SerialiseKeyOrderPreserving k Source #
Order-preserving serialisation of keys.
Table data is sorted by serialised keys. Range lookups and cursors return entries in this order. If serialisation does not preserve the ordering of unserialised keys, then range lookups and cursors return entries out of order.
If the SerialiseKey instance for a type preserves the ordering,
then it can safely be given an instance of SerialiseKeyOrderPreserving.
These should satisfy the following law:
- Order-preserving
 x `compare` y ==serialiseKeyx `compare`serialiseKeyy
Serialised keys are lexicographically ordered. To satisfy the Order-preserving law, keys should be serialised into a big-endian format.
Instances
serialiseKeyPreservesOrdering :: (Ord k, SerialiseKey k) => k -> k -> Bool Source #
Test the Order-preserving law for the SerialiseKeyOrderPreserving class
SerialiseValue
class SerialiseValue v where Source #
Serialisation of values and blobs.
Instances should satisfy the following laws:
- Identity
 deserialiseValue(serialiseValuex) == x- Identity up to slicing
 deserialiseValue(packSliceprefix (serialiseValuex) suffix) == x
Instances
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
RawBytes
Raw bytes.
This type imposes no alignment constraint and provides no guarantee of whether the memory is pinned or unpinned.
Instances
| IsString RawBytes Source # | 
 Warning:   | 
Defined in Database.LSMTree.Internal.RawBytes Methods fromString :: String -> RawBytes #  | |
| Monoid RawBytes Source # | 
 
  | 
| Semigroup RawBytes Source # | 
 
  | 
| IsList RawBytes Source # | 
 
  | 
| Show RawBytes Source # | |
| Hashable RawBytes Source # | |
Defined in Database.LSMTree.Internal.RawBytes  | |
| NFData RawBytes Source # | |
Defined in Database.LSMTree.Internal.RawBytes  | |
| Eq RawBytes Source # | |
| Ord RawBytes Source # | This instance uses lexicographic ordering.  | 
Defined in Database.LSMTree.Internal.RawBytes  | |
| type Item RawBytes Source # | |
Defined in Database.LSMTree.Internal.RawBytes  | |
packSlice :: RawBytes -> RawBytes -> RawBytes -> RawBytes Source #
 makes packSlice prefix x suffixx 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