Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Database.LSMTree.Internal.Serialise.Class
Contents
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
- serialiseKeyPreservesOrdering :: (Ord k, SerialiseKey k) => k -> k -> Bool
- serialiseKeyMinimalSize :: SerialiseKey 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
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.
Instances
SerialiseKey Word64 Source # | |
Defined in Database.LSMTree.Internal.Serialise.Class | |
SerialiseKey ByteString Source # | Placeholder instance, not optimised |
Defined in Database.LSMTree.Internal.Serialise.Class Methods serialiseKey :: ByteString -> RawBytes Source # deserialiseKey :: RawBytes -> ByteString Source # | |
SerialiseKey ByteString Source # | Placeholder instance, not optimised |
Defined in Database.LSMTree.Internal.Serialise.Class Methods serialiseKey :: ByteString -> RawBytes Source # deserialiseKey :: RawBytes -> ByteString Source # | |
SerialiseKey ShortByteString Source # | |
Defined in Database.LSMTree.Internal.Serialise.Class Methods |
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
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
Raw bytes with no alignment constraint (i.e. byte aligned), and no guarantee of pinned or unpinned memory (i.e. could be either).
Instances
IsString RawBytes Source # | Mostly to make test cases shorter to write. |
Defined in Database.LSMTree.Internal.RawBytes Methods fromString :: String -> RawBytes # | |
Monoid RawBytes Source # | |
Semigroup RawBytes Source # | |
IsList RawBytes Source # | |
Show RawBytes Source # | |
NFData RawBytes Source # | |
Defined in Database.LSMTree.Internal.RawBytes | |
Eq RawBytes Source # | |
Ord RawBytes Source # | Lexicographical |
Defined in Database.LSMTree.Internal.RawBytes | |
Hashable RawBytes Source # | |
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