Safe Haskell | None |
---|
A Collection of utilities for binary packing values into Bytestring |
- class CasType a where
- encodeCas :: a -> ByteString
- decodeCas :: ByteString -> a
- newtype TAscii = TAscii {}
- newtype TBytes = TBytes {}
- newtype TCounter = TCounter {}
- newtype TInt = TInt {}
- newtype TInt32 = TInt32 {}
- newtype TUtf8 = TUtf8 {}
- newtype TUUID = TUUID {}
- newtype TLong = TLong {}
- newtype Exclusive a = Exclusive a
- newtype Single a = Single a
Documentation
This typeclass defines and maps to haskell types that Cassandra natively knows about and uses in sorting and potentially validating column key values.
All column keys are eventually sent to and received from Cassandra in binary form. This typeclass allows us to map some Haskell type definitions to their binary representation. The correct binary serialization is handled for you behind the scenes.
For simplest cases, just use one of the string-like instances, e.g.
ByteString
, String
or Text
. Please keep in mind that these
are just mapped to untyped BytesType.
Remember that for special column types, such as TLong
, to have
any effect, your ColumnFamily must have been created with that
comparator or validator. Otherwise you're just encoding/decoding
integer values without any Cassandra support for sorting or
correctness.
The Python library pycassa has a pretty good tutorial to learn more.
Tuple instances support fixed ComponentType columns. Example:
insert "testCF" "row1" [packCol ((TLong 124, TAscii "Hello"), "some content")]
encodeCas :: a -> ByteStringSource
decodeCas :: ByteString -> aSource
CasType Int | |
CasType String | |
CasType ByteString | |
CasType Text | |
CasType ByteString | |
CasType Text | |
CasType TUtf8 | Encode and decode as Utf8 |
CasType TLong | Pack as an 8 byte unsigned number; negative signs are lost. |
CasType TInt | Pack as an 8 byte number - same as |
CasType TInt32 | Pack as a 4 byte number |
CasType TCounter | |
CasType TBytes | |
CasType TAscii | |
CasType a => CasType (Single a) | Use the |
(CasType a, CasType b) => CasType (a, Exclusive b) | |
(CasType a, CasType b) => CasType (a, b) | Composite types - see Cassandra or pycassa docs to understand |
(CasType a, CasType b, CasType c) => CasType (a, b, Exclusive c) | |
(CasType a, CasType b, CasType c) => CasType (a, b, c) | |
(CasType a, CasType b, CasType c, CasType d) => CasType (a, b, c, Exclusive d) | |
(CasType a, CasType b, CasType c, CasType d) => CasType (a, b, c, d) |
Exclusive tag for composite column. You may tag the end of a composite range with this to make the range exclusive. See pycassa documentation for more information.
Eq a => Eq (Exclusive a) | |
Ord a => Ord (Exclusive a) | |
Read a => Read (Exclusive a) | |
Show a => Show (Exclusive a) | |
(CasType a, CasType b) => CasType (a, Exclusive b) | |
(CasType a, CasType b, CasType c) => CasType (a, b, Exclusive c) | |
(CasType a, CasType b, CasType c, CasType d) => CasType (a, b, c, Exclusive d) |
Use the Single wrapper when you want to refer only to the first coolumn of a CompositeType column.
Single a |