cassandra

package
v0.0.0-...-d730caa Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 5, 2016 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CASS_VALUE_TYPE_UNKNOWN   = 0xFFFF
	CASS_VALUE_TYPE_CUSTOM    = 0x0000
	CASS_VALUE_TYPE_ASCII     = 0x0001
	CASS_VALUE_TYPE_BIGINT    = 0x0002
	CASS_VALUE_TYPE_BLOB      = 0x0003
	CASS_VALUE_TYPE_BOOLEAN   = 0x0004
	CASS_VALUE_TYPE_COUNTER   = 0x0005
	CASS_VALUE_TYPE_DECIMAL   = 0x0006
	CASS_VALUE_TYPE_DOUBLE    = 0x0007
	CASS_VALUE_TYPE_FLOAT     = 0x0008
	CASS_VALUE_TYPE_INT       = 0x0009
	CASS_VALUE_TYPE_TEXT      = 0x000A
	CASS_VALUE_TYPE_TIMESTAMP = 0x000B
	CASS_VALUE_TYPE_UUID      = 0x000C
	CASS_VALUE_TYPE_VARCHAR   = 0x000D
	CASS_VALUE_TYPE_VARINT    = 0x000E
	CASS_VALUE_TYPE_TIMEUUID  = 0x000F
	CASS_VALUE_TYPE_INET      = 0x0010
	CASS_VALUE_TYPE_DATE      = 0x0011
	CASS_VALUE_TYPE_TIME      = 0x0012
	CASS_VALUE_TYPE_SMALL_INT = 0x0013
	CASS_VALUE_TYPE_TINY_INT  = 0x0014
	CASS_VALUE_TYPE_LIST      = 0x0020
	CASS_VALUE_TYPE_MAP       = 0x0021
	CASS_VALUE_TYPE_SET       = 0x0022
	CASS_VALUE_TYPE_UDT       = 0x0030
	CASS_VALUE_TYPE_TUPLE     = 0x0031
)

Variables

View Source
var (
	CUnknown   = newCassType(CASS_VALUE_TYPE_UNKNOWN)
	CAscii     = newCassType(CASS_VALUE_TYPE_ASCII)
	CBigInt    = newCassType(CASS_VALUE_TYPE_BIGINT)
	CBlob      = newCassType(CASS_VALUE_TYPE_BLOB)
	CBoolean   = newCassType(CASS_VALUE_TYPE_BOOLEAN)
	CDecimal   = newCassType(CASS_VALUE_TYPE_DECIMAL)
	CDouble    = newCassType(CASS_VALUE_TYPE_DOUBLE)
	CFloat     = newCassType(CASS_VALUE_TYPE_FLOAT)
	CInt       = newCassType(CASS_VALUE_TYPE_INT)
	CText      = newCassType(CASS_VALUE_TYPE_TEXT)
	CTimestamp = newCassType(CASS_VALUE_TYPE_TIMESTAMP)
	CUuid      = newCassType(CASS_VALUE_TYPE_UUID)
	CVarchar   = newCassType(CASS_VALUE_TYPE_VARCHAR)
	CVarint    = newCassType(CASS_VALUE_TYPE_VARINT)
	CTimeuuid  = newCassType(CASS_VALUE_TYPE_TIMEUUID)
	CInet      = newCassType(CASS_VALUE_TYPE_INET)
	CDate      = newCassType(CASS_VALUE_TYPE_DATE)
	CTime      = newCassType(CASS_VALUE_TYPE_TIME)
	CSmallInt  = newCassType(CASS_VALUE_TYPE_SMALL_INT)
	CTinyInt   = newCassType(CASS_VALUE_TYPE_TINY_INT)
	// collections
	CList  = newCassType(CASS_VALUE_TYPE_LIST)
	CSet   = newCassType(CASS_VALUE_TYPE_SET)
	CMap   = newCassType(CASS_VALUE_TYPE_MAP)
	CTuple = newCassType(CASS_VALUE_TYPE_TUPLE)
	CUdt   = newCassType(CASS_VALUE_TYPE_UDT)
)

Predefined CassTypes for all known Cassandra data types.

View Source
var Epoch = time.Date(1970, 1, 1, 0, 0, 0, 0, time.UTC)

Functions

func NewConnectionOptions

func NewConnectionOptions() connectionOptions

Configure only the settings that are of interest. The rest will use the defaults.

func NewQueueOptions

func NewQueueOptions() queueOptions

func NewRequestOptions

func NewRequestOptions() requestOptions

func Set

func Set(val interface{}) setmarker

Utility method allowing to mark an array, slice, or map as a value to be written as Cassandra `set` from simple statements (in which automatic conversions wouldn't recognize those types as potential sets without incurring a significant penalty)

Types

type CassType

type CassType struct {
	// contains filtered or unexported fields
}

A CassType represents a specific Cassandra data type. Collection types (list, set, map, tuple, UDTs) have subtypes specifying the data type of their elements.

func (CassType) Equals

func (ct CassType) Equals(other CassType) bool

func (CassType) Specialize

func (ct CassType) Specialize(subTypes ...CassType) CassType

Specialize a collection type (list, set, map, tuple) with the type(s) of its elements

func (CassType) String

func (ct CassType) String() string

type Cluster

type Cluster struct {
	// contains filtered or unexported fields
}

func NewCluster

func NewCluster(contactPoints ...string) *Cluster

func (*Cluster) Close

func (cluster *Cluster) Close()

func (*Cluster) Connect

func (cluster *Cluster) Connect() (*Session, error)

func (*Cluster) SetConnectionOptions

func (cluster *Cluster) SetConnectionOptions(opts connectionOptions) error

func (*Cluster) SetConnectionTimeout

func (cluster *Cluster) SetConnectionTimeout(timeout time.Duration)

func (*Cluster) SetProtocolVersion

func (cluster *Cluster) SetProtocolVersion(version uint8)

func (*Cluster) SetQueueOptions

func (cluster *Cluster) SetQueueOptions(opts queueOptions) error

func (*Cluster) SetRequestOptions

func (cluster *Cluster) SetRequestOptions(opts requestOptions) error

func (*Cluster) SetRequestTimeout

func (cluster *Cluster) SetRequestTimeout(timeout time.Duration)

func (*Cluster) SetUseSchemaMetadata

func (cluster *Cluster) SetUseSchemaMetadata(flag bool)

Disable retrieving and updating schema metadata. When disabled, the cluster initialization is faster, but this also disables the token-aware routing of requests

type Consistency

type Consistency int
const (
	ANY Consistency
	ONE
	TWO
	THREE
	QUORUM
	ALL
	LOCAL_QUORUM
	EACH_QUORUM
	// Serial Consistency
	SERIAL
	LOCAL_SERIAL
	LOCAL_ONE
)

type Date

type Date struct {
	// contains filtered or unexported fields
}

Cassandra Date is a 32-bit unsigned integer representing the number of days with Epoch (1970-1-1) at the center of the range

func NewDate

func NewDate(year int, month time.Month, day int) Date

Create a new Date.

func ParseDate

func ParseDate(s string) (Date, error)

Creates a new Date value from the string representation. The accepted formats are: * yyyy-mm-dd * yyyy-m-d * yyyy-mm-d * yyyy-m-dd If the value cannot be parsed to a valid date, this function return a non-nil error

func (Date) NativeString

func (d Date) NativeString() string

Returns a representation that can be used directly in CQL

func (Date) Raw

func (d Date) Raw() uint32

func (Date) String

func (d Date) String() string

func (Date) Time

func (d Date) Time() time.Time

Only the year, month, day part are set in the returned time.Time

type Decimal

type Decimal struct {
	Value *big.Int
	Scale int32
}

A Decimal type corresponding to the Cassandra decimal data type. The internal representation of the decimal is an arbitrary precision integer unscaled balue and a 32-bit integer scale. Thus the value is equal to (unscaled * 10 ^ (-scale))

func NewDecimal

func NewDecimal(val int64, scale int32) *Decimal

func ParseDecimal

func ParseDecimal(val string) (*Decimal, error)

func (Decimal) NativeString

func (d Decimal) NativeString() string

func (Decimal) String

func (d Decimal) String() string

type Future

type Future struct {
	// contains filtered or unexported fields
}

func (*Future) Close

func (future *Future) Close()

func (*Future) Error

func (future *Future) Error() error

func (*Future) Result

func (future *Future) Result() *Rows

func (*Future) Wait

func (future *Future) Wait()

func (*Future) WaitTimed

func (future *Future) WaitTimed(timeout uint64) bool

type PreparedStatement

type PreparedStatement struct {
	// contains filtered or unexported fields
}

func (*PreparedStatement) Close

func (pstmt *PreparedStatement) Close()

func (*PreparedStatement) Exec

func (pstmt *PreparedStatement) Exec(args ...interface{}) (*Rows, error)

func (*PreparedStatement) ExecAsync

func (pstmt *PreparedStatement) ExecAsync(args ...interface{}) *Future

func (*PreparedStatement) Query

func (pstmt *PreparedStatement) Query(args ...interface{}) (*Statement, error)

func (*PreparedStatement) SetConsistency

func (pstmt *PreparedStatement) SetConsistency(c Consistency)

func (*PreparedStatement) SetSerialConsistency

func (pstmt *PreparedStatement) SetSerialConsistency(c Consistency)

type Rows

type Rows struct {
	// contains filtered or unexported fields
}

func (*Rows) Close

func (rows *Rows) Close()

func (*Rows) ColumnCount

func (rows *Rows) ColumnCount() uint64

func (*Rows) ColumnName

func (rows *Rows) ColumnName(index int) string

func (*Rows) ColumnType

func (rows *Rows) ColumnType(index int) CassType

func (*Rows) Err

func (r *Rows) Err() error

func (*Rows) Next

func (rows *Rows) Next() bool

func (*Rows) Scan

func (rows *Rows) Scan(args ...interface{}) error

type Session

type Session struct {
	Cluster *Cluster
	// contains filtered or unexported fields
}

func (*Session) Close

func (session *Session) Close()

func (*Session) Exec

func (session *Session) Exec(query string, args ...interface{}) (*Rows, error)

Executes the given query and returns either the resulting *Rows or an error.

func (*Session) ExecAsync

func (session *Session) ExecAsync(query string, args ...interface{}) *Future

Executes the given query asynchronously and returns a *Future that can be used to retrieve the results (or error).

func (*Session) Prepare

func (session *Session) Prepare(query string) (*PreparedStatement, error)

func (*Session) Query

func (session *Session) Query(query string, args ...interface{}) (*Statement, error)

Returns a *Statement which can be used to customize the CL, Serial CL, etc. The *Statement **must** be Close() once done.

type Statement

type Statement struct {
	Args []interface{}
	// contains filtered or unexported fields
}

func (*Statement) Close

func (stmt *Statement) Close()

func (*Statement) Exec

func (stmt *Statement) Exec() (*Rows, error)

func (*Statement) ExecAsync

func (stmt *Statement) ExecAsync() *Future

func (*Statement) WithConsistency

func (stmt *Statement) WithConsistency(c Consistency) *Statement

func (*Statement) WithSerialConsistency

func (stmt *Statement) WithSerialConsistency(c Consistency) *Statement

type Time

type Time int64

Cassandra `time` type represents a time of day with no date (and no notion of time zone)

func NewTime

func NewTime(hours, minutes, seconds, nanos uint) (Time, error)

func ParseTime

func ParseTime(str string) (Time, error)

func (Time) Hours

func (t Time) Hours() uint

func (Time) Minutes

func (t Time) Minutes() uint

func (Time) Nanoseconds

func (t Time) Nanoseconds() uint

func (Time) NativeString

func (t Time) NativeString() string

func (Time) Raw

func (t Time) Raw() int64

func (Time) Seconds

func (t Time) Seconds() uint

func (Time) String

func (t Time) String() string

type Timestamp

type Timestamp struct {
	// contains filtered or unexported fields
}

Cassandra `timestamp` represents a date plus time, encoded as 8 bytes since epoch

func NewTimestamp

func NewTimestamp(secondsFromEpoch int64) Timestamp

func NewTimestampFromTime

func NewTimestampFromTime(t time.Time) Timestamp

func (Timestamp) NativeString

func (t Timestamp) NativeString() string

func (Timestamp) Raw

func (t Timestamp) Raw() int64

func (Timestamp) String

func (t Timestamp) String() string

func (Timestamp) Time

func (t Timestamp) Time() time.Time

type Tuple

type Tuple struct {
	// contains filtered or unexported fields
}

A Tuple type corresponding to the Cassandra tuple data type.

func NewTuple

func NewTuple(t CassType, args ...interface{}) *Tuple

func (Tuple) Get

func (tuple Tuple) Get(index int) interface{}

func (Tuple) Kind

func (tuple Tuple) Kind() CassType

func (Tuple) Len

func (tuple Tuple) Len() int

func (Tuple) NativeString

func (tuple Tuple) NativeString() string

func (*Tuple) Set

func (tuple *Tuple) Set(index int, value interface{}) *Tuple

Sets the value at the given index and returns the same pointer to the Tuple so multiple Set operations can be chained. This method panics if the provided index falls outside the length of the tuple

func (*Tuple) SetValues

func (tuple *Tuple) SetValues(values ...interface{}) error

func (Tuple) String

func (tuple Tuple) String() string

func (Tuple) Values

func (tuple Tuple) Values() []interface{}

type UUID

type UUID [16]byte

Used to represent both a Cassandra `uuid` (UUID v4) and `timeuuid` (UUID v1).

Inspired by: * https://github.com/satori/go.uuid * https://github.com/pborman/uuid

func ParseUUID

func ParseUUID(s string) (uuid UUID, err error)

func (UUID) NativeString

func (u UUID) NativeString() string

func (UUID) Raw

func (u UUID) Raw() [16]byte

func (UUID) String

func (u UUID) String() string

func (UUID) Version

func (u UUID) Version() uint

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL