Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data Elem
- = None
- | Tuple [Elem]
- | Bytes ByteString
- | Text Text
- | Int Integer
- | Float Float
- | Double Double
- | Bool Bool
- | UUID Word32 Word32 Word32 Word32
- | CompleteVS (Versionstamp 'Complete)
- | IncompleteVS (Versionstamp 'Incomplete)
- sizeLimits :: Array Int Integer
- bisectSize :: Integer -> Int
- bitLen :: Integer -> Int
- byteLen :: Integer -> Int
- nullCode :: Word8
- bytesCode :: Word8
- stringCode :: Word8
- nestedCode :: Word8
- zeroCode :: Word8
- posEndCode :: Word8
- negStartCode :: Word8
- floatCode :: Word8
- doubleCode :: Word8
- falseCode :: Word8
- trueCode :: Word8
- uuidCode :: Word8
- versionstampCode :: Word8
- data SerializationState = SerializationState {}
- newtype PutTuple a = PutTuple {}
- runPutTuple :: PutTuple () -> (ByteString, Maybe Int)
- incrLength :: Int -> PutTuple ()
- liftPutM :: PutM a -> PutTuple a
- putWord8 :: Word8 -> PutTuple ()
- putWord16be :: Word16 -> PutTuple ()
- putWord32be :: Word32 -> PutTuple ()
- putWord64be :: Word64 -> PutTuple ()
- putByteString :: ByteString -> PutTuple ()
- encodeBytes :: ByteString -> PutTuple ()
- truncatedInt :: Int -> Integer -> ByteString
- encodeLargePosInt :: Integer -> PutTuple ()
- encodeLargeNegInt :: Integer -> PutTuple ()
- encodePosInt :: Integer -> PutTuple ()
- encodeNegInt :: Integer -> PutTuple ()
- floatAdjust :: Bool -> ByteString -> ByteString
- encodeElem :: Bool -> Elem -> PutTuple ()
- encodeTupleElems :: Traversable t => t Elem -> ByteString
- encodeTupleElemsWPrefix :: Traversable t => ByteString -> t Elem -> ByteString
- decodeTupleElems :: ByteString -> Either String [Elem]
- decodeTupleElemsWPrefix :: ByteString -> ByteString -> Either String [Elem]
- runGetComplete :: ByteString -> Get a -> Either String a
- decodeElem :: Bool -> Get Elem
- expectCode :: Word8 -> Get ()
- bytesTerminator :: Get ()
- getBytesUntilTerminator :: Get ByteString
- decodeBytesElem :: Get Elem
- decodeTextElem :: Get Elem
- decodeSmallPosInt :: Word8 -> Get Elem
- decodeSmallNegInt :: Word8 -> Get Elem
- decodeLargeNegInt :: Get Elem
- decodeLargePosInt :: Get Elem
- decodeFloatElem :: Get Elem
- decodeDoubleElem :: Get Elem
- decodeUUIDElem :: Get Elem
- decodeTupleElem :: Get Elem
- decodeVersionstamp :: Get Elem
Documentation
Elements of tuples. A tuple is represented as a list of these. Note that a tuple may contain at most one incomplete version stamp. Future versions of this library may introduce a more strongly typed tuple representation that enforces this restriction.
None | Corresponds to null or nil types in other language bindings. |
Tuple [Elem] | Nested tuples. |
Bytes ByteString | |
Text Text | |
Int Integer | Variable-length integer encodings. For values that fit within a 64-bit signed integer, the standard integer encoding is used. For larger values, the provisional spec for Java and Python values is used. |
Float Float | |
Double Double | |
Bool Bool | |
UUID Word32 Word32 Word32 Word32 | Crude UUID to avoid dependency on UUID library. Interconvertible with
|
CompleteVS (Versionstamp 'Complete) | |
IncompleteVS (Versionstamp 'Incomplete) | This constructor is to be used in conjunction with |
Instances
bisectSize :: Integer -> Int Source #
Returns smallest size limit greater than input.
byteLen :: Integer -> Int Source #
Returns the minimum number of bytes needed to encode the given int.
stringCode :: Word8 Source #
nestedCode :: Word8 Source #
posEndCode :: Word8 Source #
negStartCode :: Word8 Source #
doubleCode :: Word8 Source #
data SerializationState Source #
Instances
Instances
Monad PutTuple Source # | |
Functor PutTuple Source # | |
Applicative PutTuple Source # | |
MonadState SerializationState PutTuple Source # | |
Defined in FoundationDB.Layer.Tuple.Internal get :: PutTuple SerializationState # put :: SerializationState -> PutTuple () # state :: (SerializationState -> (a, SerializationState)) -> PutTuple a # |
runPutTuple :: PutTuple () -> (ByteString, Maybe Int) Source #
returns the serialized tuple and the position of the incomplete version stamp, if any.
incrLength :: Int -> PutTuple () Source #
putWord16be :: Word16 -> PutTuple () Source #
putWord32be :: Word32 -> PutTuple () Source #
putWord64be :: Word64 -> PutTuple () Source #
putByteString :: ByteString -> PutTuple () Source #
encodeBytes :: ByteString -> PutTuple () Source #
truncatedInt :: Int -> Integer -> ByteString Source #
encodeLargePosInt :: Integer -> PutTuple () Source #
encodeLargeNegInt :: Integer -> PutTuple () Source #
encodePosInt :: Integer -> PutTuple () Source #
encodeNegInt :: Integer -> PutTuple () Source #
floatAdjust :: Bool -> ByteString -> ByteString Source #
given an IEEE 754 float/double, adjust it for encoding.
encodeTupleElems :: Traversable t => t Elem -> ByteString Source #
Encodes a tuple from a list of tuple elements. Returns the encoded tuple.
Warning: this function can throw an Error
with TupleIntTooLarge
if you
pass an Int element that requires more than 255 bytes to serialize. Since
the smallest such number is 614 decimal digits long, we deemed this situation
unlikely enough that it wasn't worth returning a sum type from this function.
Note: this encodes to the format expected by FoundationDB as input, which
is slightly different from the format returned by FoundationDB as output. The
difference is that if the encoded bytes include an incomplete version stamp,
four bytes are appended to the end to indicate the index of the incomplete
version stamp so that FoundationDB can fill in the transaction version and
batch order when this function is used in conjunction with
setVersionstampedKey
and setVersionstampedValue
:
do let k = pack mySubspace [IncompleteVS (IncompleteVersionstamp 123)] atomicOp k (setVersionstampedKey "my_value")
Because FoundationDB uses two bytes at the end of the key for this, only
one IncompleteVS
can be used per key.
This also means that (decodeTupleElems . encodeTupleElems)
gives
strange results when an IncompleteVS
is present in the input, because the
two extra bytes are interpreted as being part of the tuple.
>>>
decodeTupleElems $ encodeTupleElems [IncompleteVS (IncompleteVersionstamp 1)]
Right [IncompleteVS (IncompleteVersionstamp 1),Bytes "",None,None]
For this reason, decodeTupleElems
should only be called on keys that have
been returned from the database, because setVersionstampedKey
drops
the last two bytes when it writes the key to the database.
encodeTupleElemsWPrefix :: Traversable t => ByteString -> t Elem -> ByteString Source #
Like encodeTupleElems
, but prepends a raw bytestring prefix to the
tuple. This is used by the subspace and directory layers.
decodeTupleElems :: ByteString -> Either String [Elem] Source #
Decodes a tuple, or returns a parse error. This function will never return
IncompleteVS
tuple elements. See the note on encodeTupleElems
for more
information.
decodeTupleElemsWPrefix Source #
:: ByteString | expected prefix |
-> ByteString | encoded tuple |
-> Either String [Elem] |
Decodes a tuple that was encoded with a given prefix. Fails if the input prefix is not actually a prefix of the encoded tuple.
runGetComplete :: ByteString -> Get a -> Either String a Source #
expectCode :: Word8 -> Get () Source #
bytesTerminator :: Get () Source #
getBytesUntilTerminator :: Get ByteString Source #
Reads all bytes up to (but not including) the terminator byte
decodeTextElem :: Get Elem Source #
decodeUUIDElem :: Get Elem Source #