cassy-0.4: A high level driver for the Cassandra datastore

Safe HaskellNone

Database.Cassandra.Pack

Description

A Collection of utilities for binary packing values into Bytestring |

Synopsis

Documentation

class CasType a whereSource

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")]

Instances

CasType Int 
CasType String 
CasType ByteString 
CasType Text 
CasType ByteString 
CasType Text 
CasType TUtf8

Encode and decode as Utf8 Text

CasType TLong

Pack as an 8 byte unsigned number; negative signs are lost.

CasType TInt

Pack as an 8 byte number - same as TLong

CasType TInt32

Pack as a 4 byte number

CasType TCounter 
CasType TBytes 
CasType TAscii 
CasType a => CasType (Single a)

Use the Single wrapper when querying only with the first of a two or more field CompositeType.

(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) 

newtype TAscii Source

Constructors

TAscii 

Fields

getAscii :: ByteString
 

newtype TBytes Source

Constructors

TBytes 

newtype TInt Source

Constructors

TInt 

Fields

getInt :: Integer
 

Instances

Eq TInt 
Ord TInt 
Read TInt 
Show TInt 
CasType TInt

Pack as an 8 byte number - same as TLong

newtype TInt32 Source

Constructors

TInt32 

Fields

getInt32 :: Int32
 

Instances

Eq TInt32 
Ord TInt32 
Read TInt32 
Show TInt32 
CasType TInt32

Pack as a 4 byte number

newtype TUtf8 Source

Constructors

TUtf8 

Fields

getUtf8 :: Text
 

Instances

Eq TUtf8 
Ord TUtf8 
Read TUtf8 
Show TUtf8 
CasType TUtf8

Encode and decode as Utf8 Text

newtype TUUID Source

Constructors

TUUID 

Fields

getUUID :: ByteString
 

newtype TLong Source

Constructors

TLong 

Fields

getLong :: Integer
 

Instances

Eq TLong 
Ord TLong 
Read TLong 
Show TLong 
CasType TLong

Pack as an 8 byte unsigned number; negative signs are lost.

newtype Exclusive a Source

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.

Constructors

Exclusive a 

Instances

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) 

newtype Single a Source

Use the Single wrapper when you want to refer only to the first coolumn of a CompositeType column.

Constructors

Single a 

Instances

Eq a => Eq (Single a) 
Ord a => Ord (Single a) 
Read a => Read (Single a) 
Show a => Show (Single a) 
CasType a => CasType (Single a)

Use the Single wrapper when querying only with the first of a two or more field CompositeType.