cassy-0.7.1: 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

Assumed to be a 64-bit Int and encoded as such.

CasType Int32 
CasType Int64 
CasType String 
CasType ByteString 
CasType ByteString 
CasType Text 
CasType UTCTime

Via TTimeStamp, which is via TLong

CasType Text 
CasType Day

Encode days as LongType via TLong.

CasType TTimeStamp 
CasType TUtf8

Encode and decode as Utf8 Text

CasType TLong

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

CasType TInt64

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 b) => CasType (SliceStart (a, b))

Composite types - see Cassandra or pycassa docs to understand

(CasType a, CasType b, CasType c) => CasType (SliceStart (a, b, c)) 
(CasType a, CasType b, CasType c, CasType d) => CasType (SliceStart (a, b, c, d)) 
CasType a => CasType (SliceStart (Single a)) 
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 (Exclusive (Single a)) 
(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 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 TInt64 Source

Constructors

TInt64 

Fields

getInt64 :: Int64
 

Instances

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

Enum TLong 
Eq TLong 
Integral TLong 
Num TLong 
Ord TLong 
Read TLong 
Real TLong 
Show TLong 
CasType TLong

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

newtype TTimeStamp Source

Timestamp that stores micro-seconds since epoch as TLong underneath.

Constructors

TTimeStamp 

Fields

getTimeStamp :: TLong
 

toTimeStamp :: UTCTime -> TTimeStampSource

Convert commonly used UTCTime to TTimeStamp.

First converts to seconds since epoch (POSIX seconds), then multiplies by a million and floors the resulting value. The value, therefore, is in micro-seconds and is accurate to within a microsecond.

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 (Exclusive (Single 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 (SliceStart (Single a)) 
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 (Exclusive (Single a)) 

newtype SliceStart a Source

Wrap your composite columns in this type when you're starting an inclusive column slice.

Constructors

SliceStart a 

Instances

Eq a => Eq (SliceStart a) 
Ord a => Ord (SliceStart a) 
Read a => Read (SliceStart a) 
Show a => Show (SliceStart a) 
(CasType a, CasType b) => CasType (SliceStart (a, b))

Composite types - see Cassandra or pycassa docs to understand

(CasType a, CasType b, CasType c) => CasType (SliceStart (a, b, c)) 
(CasType a, CasType b, CasType c, CasType d) => CasType (SliceStart (a, b, c, d)) 
CasType a => CasType (SliceStart (Single a))