libQtCassandra 0.3.2

QtCassandra::QCassandraValue Class Reference

Holds a cell value. More...

#include <QCassandraValue.h>

List of all members.

Public Types

typedef
controlled_vars::limited_auto_init
< int32_t, 0, INT_MAX,
TTL_PERMANENT
cassandra_ttl_t
 A safe TTL variable type.
enum  def_timestamp_mode_t { TIMESTAMP_MODE_CASSANDRA, TIMESTAMP_MODE_AUTO, TIMESTAMP_MODE_DEFINED }
 

Intermediate definition to support a safe timestamp mode.

More...
typedef
controlled_vars::limited_auto_init
< def_timestamp_mode_t,
TIMESTAMP_MODE_CASSANDRA,
TIMESTAMP_MODE_DEFINED,
TIMESTAMP_MODE_AUTO > 
timestamp_mode_t
 A timestamp mode.

Public Member Functions

 QCassandraValue ()
 Initialize a QCassandraValue object.
 QCassandraValue (bool value)
 Initialize a QCassandraValue object.
 QCassandraValue (signed char value)
 Initialize a QCassandraValue object.
 QCassandraValue (int32_t value)
 Initialize a QCassandraValue object.
 QCassandraValue (uint32_t value)
 Initialize a QCassandraValue object.
 QCassandraValue (unsigned char value)
 Initialize a QCassandraValue object.
 QCassandraValue (int64_t value)
 Initialize a QCassandraValue object.
 QCassandraValue (uint64_t value)
 Initialize a QCassandraValue object.
 QCassandraValue (char value)
 Initialize a QCassandraValue object.
 QCassandraValue (int16_t value)
 Initialize a QCassandraValue object.
 QCassandraValue (float value)
 Initialize a QCassandraValue object.
 QCassandraValue (double value)
 Initialize a QCassandraValue object.
 QCassandraValue (uint16_t value)
 Initialize a QCassandraValue object.
 QCassandraValue (const QString &value)
 Initialize a QCassandraValue object.
 QCassandraValue (const QByteArray &value)
 Initialize a QCassandraValue object.
const QByteArray & binaryValue () const
 Get a reference to the internal buffer value.
char charValue () const
 Retrieve the first byte of the value.
consistency_level_t consistencyLevel () const
 Retrieve the current consistency level of this value.
double doubleValue () const
 Retrieve the first eight bytes of the value.
float floatValue () const
 Retrieve the first four bytes of the value.
int16_t int16Value () const
 Retrieve the first two bytes of the value.
int32_t int32Value () const
 Retrieve the first four bytes of the value.
int64_t int64Value () const
 Retrieve the first eight bytes of the value.
bool nullValue () const
 Determine whether this value is empty.
bool operator!= (const QCassandraValue &rhs)
 Compare this and rhs values for inequality.
bool operator< (const QCassandraValue &rhs)
 Compare this and rhs values for inequality.
bool operator<= (const QCassandraValue &rhs)
 Compare this and rhs values for inequality.
QCassandraValueoperator= (int64_t value)
 Set the value to the int64_t parameter.
QCassandraValueoperator= (const QString &value)
 Set the value to the string data.
QCassandraValueoperator= (const char *null_value)
 Make the value empty.
QCassandraValueoperator= (bool value)
 Set the value to the bool parameter.
QCassandraValueoperator= (char value)
 Set the value to the char parameter.
QCassandraValueoperator= (signed char value)
 Set the value to the signed char parameter.
QCassandraValueoperator= (unsigned char value)
 Set the value to the unsigned char parameter.
QCassandraValueoperator= (uint16_t value)
 Set the value to the uint16_t parameter.
QCassandraValueoperator= (int32_t value)
 Set the value to the int32_t parameter.
QCassandraValueoperator= (uint32_t value)
 Set the value to the uint32_t parameter.
QCassandraValueoperator= (int16_t value)
 Set the value to the int16_t parameter.
QCassandraValueoperator= (uint64_t value)
 Set the value to the uint64_t parameter.
QCassandraValueoperator= (float value)
 Set the value to the float parameter.
QCassandraValueoperator= (double value)
 Set the value to the double parameter.
QCassandraValueoperator= (const QByteArray &value)
 Set the value to binary data.
bool operator== (const QCassandraValue &rhs)
 Compare this and rhs values for equality.
bool operator> (const QCassandraValue &rhs)
 Compare this and rhs values for inequality.
bool operator>= (const QCassandraValue &rhs)
 Compare this and rhs values for inequality.
void setBinaryValue (const QByteArray &value)
 Set value to this binary buffer.
void setBoolValue (bool value)
 Set the value to the bool parameter.
void setCharValue (char value)
 Set the value to the char parameter.
void setConsistencyLevel (consistency_level_t level)
 Define the consistency level of this cell.
void setDoubleValue (double value)
 Set the value to the double parameter.
void setFloatValue (float value)
 Set the value to the float parameter.
void setInt16Value (int16_t value)
 Set the value to the int16_t parameter.
void setInt32Value (int32_t value)
 Set the value to the int32_t parameter.
void setInt64Value (int64_t value)
 Set the value to the int64_t parameter.
void setNullValue ()
 Make the value empty.
void setSignedCharValue (signed char value)
 Set the value to the signed char parameter.
void setStringValue (const QString &value)
 Set the value to the string data.
void setTimestamp (int64_t timestamp)
 Define your own timestamp for this value.
void setTimestampMode (timestamp_mode_t mode)
 Change the timestamp mode.
void setTtl (int32_t ttl=TTL_PERMANENT)
 Set the time to live of this cell.
void setUInt16Value (uint16_t value)
 Set the value to the uint16_t parameter.
void setUInt32Value (uint32_t value)
 Set the value to the uint32_t parameter.
void setUInt64Value (uint64_t value)
 Set the value to the uint64_t parameter.
void setUnsignedCharValue (unsigned char value)
 Set the value to the unsigned char parameter.
signed char signedCharValue () const
 Retrieve the first byte of the value.
int size () const
 Return the size of the value.
QString stringValue () const
 Get a string from the value.
int64_t timestamp () const
 Retrieve the current timestamp of this value.
timestamp_mode_t timestampMode () const
 Retrieve the current timestamp mode.
int32_t ttl () const
 Retrieve the current time to live value.
uint16_t uint16Value () const
 Retrieve the first two bytes of the value.
uint32_t uint32Value () const
 Retrieve the first four bytes of the value.
uint64_t uint64Value () const
 Retrieve the first eight bytes of the value.
unsigned char unsignedCharValue () const
 Retrieve the first byte of the value.

Static Public Attributes

static const int32_t TTL_PERMANENT = 0
 Mark the column as permanent.

Private Member Functions

void assignTimestamp (int64_t timestamp)
 Assign a new timestamp to this value.

Private Attributes

consistency_level_t f_consistency_level
 The consitency level for this value.
controlled_vars::zint64_t f_timestamp
 The timestamp for this value.
timestamp_mode_t f_timestamp_mode
 The timestamp mode.
cassandra_ttl_t f_ttl
 The TTL of this value.
QByteArray f_value
 The actual data of this value object.

Friends

class QCassandraPrivate

Detailed Description

This class defines a value that is saved in a cell in the Cassandra database. The class is optimized to with a QByteArray as the main data holder.

You can set the value as an integer, a floating point, a string, or directly as a binary buffer. Strings are converted to UTF-8. Integers and floating points are saved in big endian format (i.e. can then be compared with a simple memcmp() call and sorted without magic when saved as a Cassandra BytesType.)

At this point, the copy operator is not overloaded meaning that everything is copied as is. This also means the QByteArray copy on write feature is used (i.e. the data buffer itself doesn't get copied until the source of the destination is written to.)

On the other hand, this means we need to copy the QByteArray buffer to the std::string of the Column structure defined in the Cassandra thrift code before sending it to Cassandra. In other words, you may end up with one copy that you could otherwise have avoided. On the other hand, many times just the QCassandraValue objects will be copied between each others.

Definition at line 259 of file QCassandraValue.h.


Member Typedef Documentation

This definition is used to handle the TTL of a cell and is defined in the value of each cell.

The type forces the TTL value to TTL_PERMANENT by default. It also bounds the value to positive numbers (plus 0 as TTL_PERMANENT is zero.)

Definition at line 265 of file QCassandraValue.h.

The timestamp can be defined in multiple ways. This mode specifies which way you want to use for this value. The same mode is used by the different remove() functions.

The available modes are:

  • TIMESTAMP_MODE_CASSANDRA -- the Cassandra server defines the timestamp
  • TIMESTAMP_MODE_AUTO -- the libQtCassandra library defines the timestamp
  • TIMESTAMP_MODE_DEFINED -- the user defined the timestamp
See also:
QCassandraValue::f_timestamp_mode

Definition at line 272 of file QCassandraValue.h.


Member Enumeration Documentation

The intermediate definition of the timestamp is used to declare a limited controlled variable that has bounds checked automatically and initializes variables of type timestamp_mode_t to TIMESTAMP_MODE_AUTO.

Enumerator:
TIMESTAMP_MODE_CASSANDRA 

Mark the timestamp as unused.

It is possible to mark the Value timestamp as unused. This means the libQtCassandra library will not set the timestamp leaving to the Cassandra server that task. This is not always possible.

TBD -- it looks like the timestamp is mandatory even when marked optional; there may be some cases when it's not necessary but while writing to a row, it's dearly required. So this is not the default. Instead the TIMESTAMP_MODE_AUTO is.

TIMESTAMP_MODE_AUTO 

Ask the library to define the timestamp.

The timestamp will automatically be set using the gettimeofday(2) function. The seconds are multiplied by 1,000,000 and the microseconds added to the result. This fits in 64 bits and will do so for a long while.

Note that the last timestamp generated by the system gets saved in the corresponding QCassandraValue f_timestamp variable member.

This is the default.

TIMESTAMP_MODE_DEFINED 

The timestamp was defined by you.

The QCassandraValue::f_timestamp will be used as the timestamp of this value.

Note that when you read the value of a cell, its timestamp is saved in the QCassandraValue, but the mode is not changed. The result is that you can still retrieve the timestamp with the timestamp() function.

Definition at line 267 of file QCassandraValue.h.


Constructor & Destructor Documentation

QtCassandra::QCassandraValue::QCassandraValue ( )

This function initializes a QCassandraRow object to NULL. This is an equivalent to a BINARY with a size of 0.

Definition at line 212 of file QCassandraValue.cpp.

QtCassandra::QCassandraValue::QCassandraValue ( bool  value)

This function initializes a QCassandraValue object to true or false.

Parameters:
[in]valueThe start value of the QCassandraValue object.

Definition at line 229 of file QCassandraValue.cpp.

References f_value, and setBoolValue().

QtCassandra::QCassandraValue::QCassandraValue ( char  value)

This function initializes a QCassandraValue object an 8 bits value. The value may be signed or not depending on your compiler settings.

Parameters:
[in]valueThe start value of the QCassandraValue object.

Definition at line 247 of file QCassandraValue.cpp.

References f_value, and setCharValue().

QtCassandra::QCassandraValue::QCassandraValue ( signed char  value)

This function initializes a QCassandraValue object to a signed value between -128 and +127.

Parameters:
[in]valueThe start value of the QCassandraValue object.

Definition at line 264 of file QCassandraValue.cpp.

References f_value, and setSignedCharValue().

QtCassandra::QCassandraValue::QCassandraValue ( unsigned char  value)

This function initializes a QCassandraValue object to an unsigned value between 0 and 255.

Parameters:
[in]valueThe start value of the QCassandraValue object.

Definition at line 281 of file QCassandraValue.cpp.

References f_value, and setUnsignedCharValue().

QtCassandra::QCassandraValue::QCassandraValue ( int16_t  value)

This function initializes a QCassandraValue object to a signed value between -32768 and +32768.

Parameters:
[in]valueThe start value of the QCassandraValue object.

Definition at line 298 of file QCassandraValue.cpp.

References f_value, and setInt16Value().

QtCassandra::QCassandraValue::QCassandraValue ( uint16_t  value)

This function initializes a QCassandraValue object to an unsigned value between 0 and 65535.

Parameters:
[in]valueThe start value of the QCassandraValue object.

Definition at line 315 of file QCassandraValue.cpp.

References f_value, and setUInt16Value().

QtCassandra::QCassandraValue::QCassandraValue ( int32_t  value)

This function initializes a QCassandraValue object to a signed integer of 32 bits.

Parameters:
[in]valueThe start value of the QCassandraValue object.

Definition at line 332 of file QCassandraValue.cpp.

References f_value, and setInt32Value().

QtCassandra::QCassandraValue::QCassandraValue ( uint32_t  value)

This function initializes a QCassandraValue object to an unsigned integer of 32 bits.

Parameters:
[in]valueThe start value of the QCassandraValue object.

Definition at line 349 of file QCassandraValue.cpp.

References f_value, and setUInt32Value().

QtCassandra::QCassandraValue::QCassandraValue ( int64_t  value)

This function initializes a QCassandraValue object to a signed integer of 64 bits.

Parameters:
[in]valueThe start value of the QCassandraValue object.

Definition at line 366 of file QCassandraValue.cpp.

References f_value, and setInt64Value().

QtCassandra::QCassandraValue::QCassandraValue ( uint64_t  value)

This function initializes a QCassandraValue object to an unsigned integer of 64 bits.

Parameters:
[in]valueThe start value of the QCassandraValue object.

Definition at line 383 of file QCassandraValue.cpp.

References f_value, and setUInt64Value().

QtCassandra::QCassandraValue::QCassandraValue ( float  value)

This function initializes a QCassandraValue object to a floating point value defined on 32 bits.

Parameters:
[in]valueThe start value of the QCassandraValue object.

Definition at line 400 of file QCassandraValue.cpp.

References f_value, and setFloatValue().

QtCassandra::QCassandraValue::QCassandraValue ( double  value)

This function initializes a QCassandraValue object to a floating point value defined on 64 bits.

Parameters:
[in]valueThe start value of the QCassandraValue object.

Definition at line 417 of file QCassandraValue.cpp.

References f_value, and setDoubleValue().

QtCassandra::QCassandraValue::QCassandraValue ( const QString &  value)

This function initializes a QCassandraValue object to a UTF-8 string.

Parameters:
[in]valueThe start value of the QCassandraValue object.

Definition at line 434 of file QCassandraValue.cpp.

QtCassandra::QCassandraValue::QCassandraValue ( const QByteArray &  value)

This function initializes a QCassandraValue object to a buffer.

Parameters:
[in]valueThe start value of the QCassandraValue object.

Definition at line 450 of file QCassandraValue.cpp.


Member Function Documentation

void QtCassandra::QCassandraValue::assignTimestamp ( int64_t  timestamp) [private]

This function assigns a new timestamp to this value without changing the timestamp mode. This is used internally whenever a value is read from the Cassandra server.

Parameters:
[in]timestampThe new value timestamp.

Definition at line 1598 of file QCassandraValue.cpp.

References f_timestamp, and timestamp().

Referenced by QtCassandra::QCassandraPrivate::getColumnSlice(), QtCassandra::QCassandraPrivate::getRowSlices(), and QtCassandra::QCassandraPrivate::getValue().

const QByteArray & QtCassandra::QCassandraValue::binaryValue ( ) const

This function is used to retrieve a direct reference to the internal buffer. (The reference is constant though!)

This means you can get direct access to all the data saved in this value. The buffer may be empty (null value.)

Returns:
The binary value held by this value.

Definition at line 989 of file QCassandraValue.cpp.

References f_value.

Referenced by QtCassandra::QCassandraPrivate::insertValue().

char QtCassandra::QCassandraValue::charValue ( ) const

This function is used to retrieve the value in the form of a byte. Whether the value is signed depends on your compiler.

It is assumed that you know what you're doing (i.e. that you created this cell with a one byte value.)

Exceptions:
std::runtime_errorIf the buffer is empty, this function raises an exception.
Returns:
One character from the buffer.

Definition at line 707 of file QCassandraValue.cpp.

References f_value.

consistency_level_t QtCassandra::QCassandraValue::consistencyLevel ( ) const

This function returns the consistency level of this value. By default it is set to one (CONSISTENCY_LEVEL_ONE.)

The consistency level can be set using the setConsistencyLevel() function.

Returns:
The consistency level of this value.
See also:
setConsistencyLevel()

Definition at line 1425 of file QCassandraValue.cpp.

References f_consistency_level.

Referenced by QtCassandra::QCassandraPrivate::getValue(), and QtCassandra::QCassandraPrivate::insertValue().

double QtCassandra::QCassandraValue::doubleValue ( ) const

This function is used to retrieve the first eight bytes of the value in the form of a double floating point (64 bits).

It is assumed that you know what you're doing (i.e. that you created this cell with a eight byte floating point value.)

Exceptions:
std::runtime_errorIf the buffer is empty, this function raises an exception.
Returns:
One character from the buffer.

Definition at line 947 of file QCassandraValue.cpp.

References f_value.

float QtCassandra::QCassandraValue::floatValue ( ) const

This function is used to retrieve the first four bytes of the value in the form of a double floating point (32 bits).

It is assumed that you know what you're doing (i.e. that you created this cell with a four byte floating point value.)

Exceptions:
std::runtime_errorIf the buffer is empty, this function raises an exception.
Returns:
One character from the buffer.

Definition at line 917 of file QCassandraValue.cpp.

References f_value.

int16_t QtCassandra::QCassandraValue::int16Value ( ) const

This function is used to retrieve the first two bytes of the value in the form of an integer.

It is assumed that you know what you're doing (i.e. that you created this cell with a two byte value.)

Exceptions:
std::runtime_errorIf the buffer is empty, this function raises an exception.
Returns:
One character from the buffer.

Definition at line 769 of file QCassandraValue.cpp.

References f_value.

int32_t QtCassandra::QCassandraValue::int32Value ( ) const

This function is used to retrieve the first four bytes of the value in the form of a signed integer.

It is assumed that you know what you're doing (i.e. that you created this cell with a four byte value.)

Exceptions:
std::runtime_errorIf the buffer is empty, this function raises an exception.
Returns:
One character from the buffer.

Definition at line 813 of file QCassandraValue.cpp.

References f_value.

int64_t QtCassandra::QCassandraValue::int64Value ( ) const

This function is used to retrieve the first eight bytes of the value in the form of a signed integer.

It is assumed that you know what you're doing (i.e. that you created this cell with a eight byte value.)

Exceptions:
std::runtime_errorIf the buffer is empty, this function raises an exception.
Returns:
One character from the buffer.

Definition at line 861 of file QCassandraValue.cpp.

References f_value.

bool QtCassandra::QCassandraValue::nullValue ( ) const

This function returns true if the value has no data (i.e. empty buffer.)

Returns:
true if the value is an empty buffer, false otherwise.

Definition at line 689 of file QCassandraValue.cpp.

References f_value.

bool QtCassandra::QCassandraValue::operator!= ( const QCassandraValue rhs)

This function returns true if this value and the rhs value are considered inequal.

The inequality takes the value buffer content, the TTL and the consistency level in account. Any of the three must be inequal for the function to return true.

Parameters:
[in]rhsThe value to compare against this value.
Returns:
true if both values are considered inequal, false otherwise.

Definition at line 1263 of file QCassandraValue.cpp.

References f_consistency_level, f_ttl, f_value, and size().

bool QtCassandra::QCassandraValue::operator< ( const QCassandraValue rhs)

This function returns true if this value is considered smaller than the rhs value.

The inequality comparison only takes the value buffers in account. All the other parameters are ignored (i.e. TTL, timestamp, and consistency level.)

Parameters:
[in]rhsThe value to compare against this value.
Returns:
true if this value is considered smaller than rhs, false otherwise.

Definition at line 1290 of file QCassandraValue.cpp.

References f_value, and size().

bool QtCassandra::QCassandraValue::operator<= ( const QCassandraValue rhs)

This function returns true if this value is considered smaller than or equal to the rhs value.

The inequality comparison only takes the value buffers in account. All the other parameters are ignored (i.e. TTL, timestamp, and consistency level.)

Parameters:
[in]rhsThe value to compare against this value.
Returns:
true if this value is considered smaller than or equal to rhs, false otherwise.

Definition at line 1314 of file QCassandraValue.cpp.

References f_value, and size().

QCassandraValue & QtCassandra::QCassandraValue::operator= ( bool  value)

This function copies the specified bool in the value buffer. The bool is saved as 0 or 1.

Parameters:
[in]valueThe new value to copy in this value buffer.
Returns:
A reference to this QCassandra value.

Definition at line 1018 of file QCassandraValue.cpp.

References f_value, and setBoolValue().

QCassandraValue & QtCassandra::QCassandraValue::operator= ( char  value)

This function copies the specified char in the value buffer. The char is saved in big endian.

Parameters:
[in]valueThe new value to copy in this value buffer.
Returns:
A reference to this QCassandra value.

Definition at line 1033 of file QCassandraValue.cpp.

References f_value, and setCharValue().

QCassandraValue & QtCassandra::QCassandraValue::operator= ( signed char  value)

This function copies the specified signed char in the value buffer. The signed char is saved in big endian.

Parameters:
[in]valueThe new value to copy in this value buffer.
Returns:
A reference to this QCassandra value.

Definition at line 1048 of file QCassandraValue.cpp.

References f_value, and setSignedCharValue().

QCassandraValue & QtCassandra::QCassandraValue::operator= ( unsigned char  value)

This function copies the specified unsigned char in the value buffer. The unsigned char is saved in big endian.

Parameters:
[in]valueThe new value to copy in this value buffer.
Returns:
A reference to this QCassandra value.

Definition at line 1063 of file QCassandraValue.cpp.

References f_value, and setUnsignedCharValue().

QCassandraValue & QtCassandra::QCassandraValue::operator= ( int16_t  value)

This function copies the specified int16_t in the value buffer. The int16_t is saved in big endian.

Parameters:
[in]valueThe new value to copy in this value buffer.
Returns:
A reference to this QCassandra value.

Definition at line 1078 of file QCassandraValue.cpp.

References f_value, and setInt16Value().

QCassandraValue & QtCassandra::QCassandraValue::operator= ( double  value)

This function copies the specified double in the value buffer. The double is saved in big endian.

Parameters:
[in]valueThe new value to copy in this value buffer.
Returns:
A reference to this QCassandra value.

Definition at line 1183 of file QCassandraValue.cpp.

References f_value, and setDoubleValue().

QCassandraValue & QtCassandra::QCassandraValue::operator= ( uint16_t  value)

This function copies the specified uint16_t in the value buffer. The uint16_t is saved in big endian.

Parameters:
[in]valueThe new value to copy in this value buffer.
Returns:
A reference to this QCassandra value.

Definition at line 1093 of file QCassandraValue.cpp.

References f_value, and setUInt16Value().

QCassandraValue & QtCassandra::QCassandraValue::operator= ( int32_t  value)

This function copies the specified int32_t in the value buffer. The int32_t is saved in big endian.

Parameters:
[in]valueThe new value to copy in this value buffer.
Returns:
A reference to this QCassandra value.

Definition at line 1108 of file QCassandraValue.cpp.

References f_value, and setInt32Value().

QCassandraValue & QtCassandra::QCassandraValue::operator= ( uint32_t  value)

This function copies the specified uint32_t in the value buffer. The uint32_t is saved in big endian.

Parameters:
[in]valueThe new value to copy in this value buffer.
Returns:
A reference to this QCassandra value.

Definition at line 1123 of file QCassandraValue.cpp.

References f_value, and setUInt32Value().

QCassandraValue & QtCassandra::QCassandraValue::operator= ( int64_t  value)

This function copies the specified int64_t in the value buffer. The int64_t is saved in big endian.

Parameters:
[in]valueThe new value to copy in this value buffer.
Returns:
A reference to this QCassandra value.

Definition at line 1138 of file QCassandraValue.cpp.

References f_value, and setInt64Value().

QCassandraValue & QtCassandra::QCassandraValue::operator= ( uint64_t  value)

This function copies the specified uint64_t in the value buffer. The uint64_t is saved in big endian.

Parameters:
[in]valueThe new value to copy in this value buffer.
Returns:
A reference to this QCassandra value.

Definition at line 1153 of file QCassandraValue.cpp.

References f_value, and setUInt64Value().

QCassandraValue & QtCassandra::QCassandraValue::operator= ( float  value)

This function copies the specified float in the value buffer. The float is saved in big endian.

Parameters:
[in]valueThe new value to copy in this value buffer.
Returns:
A reference to this QCassandra value.

Definition at line 1168 of file QCassandraValue.cpp.

References f_value, and setFloatValue().

QCassandraValue & QtCassandra::QCassandraValue::operator= ( const QString &  value)

This function copies the specified string data in the value buffer. The string is converted to UTF-8 first.

Parameters:
[in]valueThe new value to copy in this value buffer.
Returns:
A reference to this QCassandra value.

Definition at line 1198 of file QCassandraValue.cpp.

References f_value, and setStringValue().

QCassandraValue & QtCassandra::QCassandraValue::operator= ( const QByteArray &  value)

This function copies the specified binary data in the value buffer.

Parameters:
[in]valueThe new value to copy in this value buffer.
Returns:
A reference to this QCassandra value.

Definition at line 1215 of file QCassandraValue.cpp.

References f_value, and setBinaryValue().

QCassandraValue & QtCassandra::QCassandraValue::operator= ( const char *  null_value)

This function empties the value buffer. The null_value parameter can be set to any value, it is ignored.

Parameters:
[in]null_valueAn ignored pointer (should be set to NULL)
Returns:
A reference to this QCassandra value.

Definition at line 1003 of file QCassandraValue.cpp.

References f_value, and setNullValue().

bool QtCassandra::QCassandraValue::operator== ( const QCassandraValue rhs)

This function returns true if this value and the rhs value are considered equal.

The equality takes the value buffer content, the TTL and the consistency level in account. All three must be equal for the function to return true.

Parameters:
[in]rhsThe value to compare against this value.
Returns:
true if both values are considered equal, false otherwise.

Definition at line 1236 of file QCassandraValue.cpp.

References f_consistency_level, f_ttl, f_value, and size().

bool QtCassandra::QCassandraValue::operator> ( const QCassandraValue rhs)

This function returns true if this value is considered larger than the rhs value.

The inequality comparison only takes the value buffers in account. All the other parameters are ignored (i.e. TTL, timestamp, and consistency level.)

Parameters:
[in]rhsThe value to compare against this value.
Returns:
true if this value is considered larger than rhs, false otherwise.

Definition at line 1338 of file QCassandraValue.cpp.

References f_value, and size().

bool QtCassandra::QCassandraValue::operator>= ( const QCassandraValue rhs)

This function returns true if this value is considered larger than or equal to the rhs value.

The inequality comparison only takes the value buffers in account. All the other parameters are ignored (i.e. TTL, timestamp, and consistency level.)

Parameters:
[in]rhsThe value to compare against this value.
Returns:
true if this value is considered larger than or equal to rhs, false otherwise.

Definition at line 1362 of file QCassandraValue.cpp.

References f_value, and size().

void QtCassandra::QCassandraValue::setBinaryValue ( const QByteArray &  value)

This function sets the contents of this value object to the specified binary buffer. This is the only case where the input data is saved untouched in the value buffer.

Exceptions:
std::runtime_errorThis exception is raised whenever the input binary buffer is larger than 64Mb. Later we may allow you to change the limit, however, we probably will give you a way to save large data sets using multiple cells instead (i.e. blobs.)
Parameters:
[in]valueThe binary buffer to save in this value object.

Definition at line 662 of file QCassandraValue.cpp.

References f_value.

Referenced by QtCassandra::QCassandraPrivate::getColumnSlice(), QtCassandra::QCassandraPrivate::getRowSlices(), QtCassandra::QCassandraPrivate::getValue(), and operator=().

void QtCassandra::QCassandraValue::setBoolValue ( bool  value)

This function copies the specified bool in the value buffer. The bool is saved as 0 or 1.

Parameters:
[in]valueThe new value to copy in this value buffer.
Returns:
A reference to this QCassandra value.

Definition at line 478 of file QCassandraValue.cpp.

References f_value.

Referenced by operator=(), and QCassandraValue().

void QtCassandra::QCassandraValue::setCharValue ( char  value)

This function copies the specified char in the value buffer. The char is saved in big endian.

Parameters:
[in]valueThe new value to copy in this value buffer.
Returns:
A reference to this QCassandra value.

Definition at line 492 of file QCassandraValue.cpp.

References f_value.

Referenced by operator=(), and QCassandraValue().

void QtCassandra::QCassandraValue::setConsistencyLevel ( consistency_level_t  level)

This function defines the consistency level of this cell. The level is defined as a static value in the QCassandraValue.

Note that this value is mandatory so defining the right value is probably often a good. The default is set to one which means the data is only saved on that one cluster you are connected to. One of the best value is QUORUM.

The available values are:

  • CONSISTENCY_LEVEL_ONE
  • CONSISTENCY_LEVEL_QUORUM
  • CONSISTENCY_LEVEL_LOCAL_QUORUM
  • CONSISTENCY_LEVEL_EACH_QUORUM
  • CONSISTENCY_LEVEL_ALL
  • CONSISTENCY_LEVEL_ANY
  • CONSISTENCY_LEVEL_TWO
  • CONSISTENCY_LEVEL_THREE

The consistency level is probably better explained in the Cassandra documentations that here.

Parameters:
[in]levelThe new consistency level for this cell.

Definition at line 1455 of file QCassandraValue.cpp.

References QtCassandra::CONSISTENCY_LEVEL_ALL, QtCassandra::CONSISTENCY_LEVEL_ANY, QtCassandra::CONSISTENCY_LEVEL_DEFAULT, QtCassandra::CONSISTENCY_LEVEL_EACH_QUORUM, QtCassandra::CONSISTENCY_LEVEL_LOCAL_QUORUM, QtCassandra::CONSISTENCY_LEVEL_ONE, QtCassandra::CONSISTENCY_LEVEL_QUORUM, QtCassandra::CONSISTENCY_LEVEL_THREE, QtCassandra::CONSISTENCY_LEVEL_TWO, and f_consistency_level.

void QtCassandra::QCassandraValue::setDoubleValue ( double  value)

This function copies the specified double in the value buffer. The double is saved in big endian.

Parameters:
[in]valueThe new value to copy in this value buffer.

Definition at line 622 of file QCassandraValue.cpp.

References f_value.

Referenced by operator=(), and QCassandraValue().

void QtCassandra::QCassandraValue::setFloatValue ( float  value)

This function copies the specified float in the value buffer. The float is saved in big endian.

Parameters:
[in]valueThe new value to copy in this value buffer.

Definition at line 610 of file QCassandraValue.cpp.

References f_value.

Referenced by operator=(), and QCassandraValue().

void QtCassandra::QCassandraValue::setInt16Value ( int16_t  value)

This function copies the specified int16_t in the value buffer. The int16_t is saved in big endian.

Parameters:
[in]valueThe new value to copy in this value buffer.
Returns:
A reference to this QCassandra value.

Definition at line 534 of file QCassandraValue.cpp.

References f_value.

Referenced by operator=(), and QCassandraValue().

void QtCassandra::QCassandraValue::setInt32Value ( int32_t  value)

This function copies the specified int32_t in the value buffer. The int32_t is saved in big endian.

Parameters:
[in]valueThe new value to copy in this value buffer.

Definition at line 560 of file QCassandraValue.cpp.

References f_value.

Referenced by operator=(), and QCassandraValue().

void QtCassandra::QCassandraValue::setInt64Value ( int64_t  value)

This function copies the specified int64_t in the value buffer. The int64_t is saved in big endian.

Parameters:
[in]valueThe new value to copy in this value buffer.

Definition at line 586 of file QCassandraValue.cpp.

References f_value.

Referenced by operator=(), and QCassandraValue().

void QtCassandra::QCassandraValue::setNullValue ( )

This function empties the value buffer.

Definition at line 464 of file QCassandraValue.cpp.

References f_value.

Referenced by QtCassandra::QCassandraCell::clearCache(), QtCassandra::QCassandraPrivate::getValue(), and operator=().

void QtCassandra::QCassandraValue::setSignedCharValue ( signed char  value)

This function copies the specified signed char in the value buffer. The signed char is saved in big endian.

Parameters:
[in]valueThe new value to copy in this value buffer.
Returns:
A reference to this QCassandra value.

Definition at line 506 of file QCassandraValue.cpp.

References f_value.

Referenced by operator=(), and QCassandraValue().

void QtCassandra::QCassandraValue::setStringValue ( const QString &  value)

This function copies the specified string data in the value buffer. The string is converted to UTF-8 first.

Exceptions:
std::runtime_errorThis exception is raised whenever the input binary buffer is larger than 64Mb. Later we may allow you to change the limit, however, we probably will give you a way to save large data sets using multiple cells instead (i.e. blobs.)
Parameters:
[in]valueThe new value to copy in this value buffer.

Definition at line 640 of file QCassandraValue.cpp.

References f_value.

Referenced by operator=().

void QtCassandra::QCassandraValue::setTimestamp ( int64_t  timestamp)

The timestamp value is used by the Cassandra server to choose which one of the values to keep. The value with the largest timestamp is kept in the database and all the others are removed.

The value can be anything you'd like such as a simple counter or the time of day (see gettimeofday(2)).

If you use the time of day, you must make sure that all the servers that run your software have the same time (i.e. use ntpd or an equivalent.)

By default (TIMESTAMP_MODE_CASSANDRA), we let the Cassandra server define the timestamp for us.

The special mode CASSANDRA_VALUE_AUTO_TIMESTAMP can be used to request the QtCassandra library to use the gettimeofday() function to determine the timestamp with as much precision as that function offers (we send the seconds and microseconds.) This is done at the time the value is saved (each time.)

In any event, changing the timestamp en route is not a good idea. You may lose data doing so. So make sure that a specific cell always get the same timestamp definition.

Note that if you start with a timestamp of 1 and increase it by 1 each time you write the value, it works just the same (assuming that two nodes cannot write to the database at the same time...)

Note:
This call automatically sets the mode to TIMESTAMP_MODE_DEFINED.
When a QCassandraValue is copied around in memory it completely ignores the timestamp. In other words, you can copy an old value over a new value and it will overwrite the new value.
Parameters:
[in]timestampThe time used to mark this value.

Definition at line 1584 of file QCassandraValue.cpp.

References f_timestamp, f_timestamp_mode, timestamp(), and TIMESTAMP_MODE_DEFINED.

void QtCassandra::QCassandraValue::setTimestampMode ( timestamp_mode_t  mode)

This function is used to change the timestamp mode to one of:

  • TIMESTAMP_MODE_CASSANDRA -- let the Cassandra server define the timestamp
  • TIMESTAMP_MODE_AUTO -- let the libQtCassandra library define the timestamp

Note that you cannot set the mode to TIMESTAMP_MODE_DEFINED with this function. Instead use the setTimestamp() function which has the side effect of setting the mode to defined.

Parameters:
[in]modeThe new mode for this value's timestamp.
See also:
setTimestamp()

Definition at line 1510 of file QCassandraValue.cpp.

References f_timestamp_mode, TIMESTAMP_MODE_AUTO, and TIMESTAMP_MODE_CASSANDRA.

void QtCassandra::QCassandraValue::setTtl ( int32_t  ttl = TTL_PERMANENT)

Each cell can be defined as permanent (i.e. TTL not defined, or set to TTL_PERMANENT) or can be defined as temporary.

This value represents the number of seconds you want this value to remain in the database.

Note that if you want to keep values while running and then lose them, you may want to consider creating a context in memory only (i.e. a context on which you never call the create() function.) Then the TTL is completely ignored, but when you quit your application, the data is gone.

Parameters:
[in]ttlThe new time to live of this value.

Definition at line 1405 of file QCassandraValue.cpp.

References f_ttl, and ttl().

Referenced by QtCassandra::QCassandraPrivate::getColumnSlice(), QtCassandra::QCassandraPrivate::getRowSlices(), and QtCassandra::QCassandraPrivate::getValue().

void QtCassandra::QCassandraValue::setUInt16Value ( uint16_t  value)

This function copies the specified uint16_t in the value buffer. The uint16_t is saved in big endian.

Parameters:
[in]valueThe new value to copy in this value buffer.
Returns:
A reference to this QCassandra value.

Definition at line 548 of file QCassandraValue.cpp.

References f_value.

Referenced by operator=(), and QCassandraValue().

void QtCassandra::QCassandraValue::setUInt32Value ( uint32_t  value)

This function copies the specified uint32_t in the value buffer. The uint32_t is saved in big endian.

Parameters:
[in]valueThe new value to copy in this value buffer.
Returns:
A reference to this QCassandra value.

Definition at line 574 of file QCassandraValue.cpp.

References f_value.

Referenced by operator=(), and QCassandraValue().

void QtCassandra::QCassandraValue::setUInt64Value ( uint64_t  value)

This function copies the specified uint64_t in the value buffer. The uint64_t is saved in big endian.

Parameters:
[in]valueThe new value to copy in this value buffer.

Definition at line 598 of file QCassandraValue.cpp.

References f_value.

Referenced by operator=(), and QCassandraValue().

void QtCassandra::QCassandraValue::setUnsignedCharValue ( unsigned char  value)

This function copies the specified unsigned char in the value buffer. The unsigned char is saved in big endian.

Parameters:
[in]valueThe new value to copy in this value buffer.
Returns:
A reference to this QCassandra value.

Definition at line 520 of file QCassandraValue.cpp.

References f_value.

Referenced by operator=(), and QCassandraValue().

signed char QtCassandra::QCassandraValue::signedCharValue ( ) const

This function is used to retrieve the value in the form of a signed byte.

It is assumed that you know what you're doing (i.e. that you created this cell with a one byte value.)

Exceptions:
std::runtime_errorIf the buffer is empty, this function raises an exception.
Returns:
One character from the buffer.

Definition at line 727 of file QCassandraValue.cpp.

References f_value.

int QtCassandra::QCassandraValue::size ( ) const

This function returns the number of bytes that the value uses.

The size can be zero.

Returns:
The size of the value buffer.

Definition at line 678 of file QCassandraValue.cpp.

References f_value.

Referenced by operator!=(), operator<(), operator<=(), operator==(), operator>(), and operator>=().

QString QtCassandra::QCassandraValue::stringValue ( ) const

This function retrieves the value as a QString, which means it's UTF-8.

Returns:
The binary value held by this value.

Definition at line 974 of file QCassandraValue.cpp.

References f_value.

int64_t QtCassandra::QCassandraValue::timestamp ( ) const

This function returns the timestamp of this value.

Please, see the setTimestamp() function for more information.

Note that when the timestamp mode is not TIMESTAMP_MODE_DEFINED, this value is not used when saving the QCassandraValue in the database. Otherwise it is set to the last value it was set at (i.e. either the timestamp found in the Cassandra database or the last value you set it to with the setTimestamp() function.)

Returns:
The timestamp 64bit value.
See also:
setTimestamp()

Definition at line 1540 of file QCassandraValue.cpp.

References f_timestamp.

Referenced by assignTimestamp(), QtCassandra::QCassandraPrivate::insertValue(), and setTimestamp().

QCassandraValue::timestamp_mode_t QtCassandra::QCassandraValue::timestampMode ( ) const

This function returns the timestamp mode.

Please, see the setTimestamp() function and the different timestamp modes for more information.

Returns:
The timestamp mode.
See also:
setTimestamp()
TIMESTAMP_MODE_CASSANDRA
TIMESTAMP_MODE_AUTO
TIMESTAMP_MODE_DEFINED

Definition at line 1490 of file QCassandraValue.cpp.

References f_timestamp_mode.

Referenced by QtCassandra::QCassandraPrivate::insertValue().

int32_t QtCassandra::QCassandraValue::ttl ( ) const

This function returns the number of seconds defined as the lifetime of this cell. The time to live is useful to create some temporary data. For example, if you create an index of recent posts, you may want the older posts to automatically be dropped after a given amount of time (i.e. 2 weeks.)

This value can be set using the setTtl() function.

Returns:
The number of seconds the cell will live.

Definition at line 1384 of file QCassandraValue.cpp.

References f_ttl.

Referenced by QtCassandra::QCassandraPrivate::insertValue(), and setTtl().

uint16_t QtCassandra::QCassandraValue::uint16Value ( ) const

This function is used to retrieve the first two bytes of the value in the form of an unsigned integer.

It is assumed that you know what you're doing (i.e. that you created this cell with a two byte value.)

Exceptions:
std::runtime_errorIf the buffer is empty, this function raises an exception.
Returns:
One character from the buffer.

Definition at line 791 of file QCassandraValue.cpp.

References f_value.

uint32_t QtCassandra::QCassandraValue::uint32Value ( ) const

This function is used to retrieve the first four bytes of the value in the form of an unsigned integer.

It is assumed that you know what you're doing (i.e. that you created this cell with a four byte value.)

Exceptions:
std::runtime_errorIf the buffer is empty, this function raises an exception.
Returns:
One character from the buffer.

Definition at line 837 of file QCassandraValue.cpp.

References f_value.

uint64_t QtCassandra::QCassandraValue::uint64Value ( ) const

This function is used to retrieve the first eight bytes of the value in the form of an unsigned integer.

It is assumed that you know what you're doing (i.e. that you created this cell with a eight byte value.)

Exceptions:
std::runtime_errorIf the buffer is empty, this function raises an exception.
Returns:
One character from the buffer.

Definition at line 889 of file QCassandraValue.cpp.

References f_value.

unsigned char QtCassandra::QCassandraValue::unsignedCharValue ( ) const

This function is used to retrieve the value in the form of an unsigned byte.

It is assumed that you know what you're doing (i.e. that you created this cell with a one byte value.)

Exceptions:
std::runtime_errorIf the buffer is empty, this function raises an exception.
Returns:
One character from the buffer.

Definition at line 748 of file QCassandraValue.cpp.

References f_value.


Friends And Related Function Documentation

friend class QCassandraPrivate [friend]

Definition at line 369 of file QCassandraValue.h.


Member Data Documentation

Whenever saving or retrieving a value, you need to specify the consistency level to use to do so. This parameter defines this consistency level.

By default it is set to CONSISTENCY_LEVEL_DEFAULT which means that the system will make use of the default consistency value defined in the QCassandra object.

See also:
QCassandra::setDefaultConsistencyLevel()

Definition at line 373 of file QCassandraValue.h.

Referenced by consistencyLevel(), operator!=(), operator==(), and setConsistencyLevel().

This variable member holds the timestamp of this value, however it is used only if the QCassandraValue::f_timestamp_mode is set to CASSANDRA_VALUE_TIMESTAMP. In all other cases it is ignored.

Definition at line 375 of file QCassandraValue.h.

Referenced by assignTimestamp(), setTimestamp(), and timestamp().

This variable member defines how the timestamp value is used. It can be set to any one of the timestamp_mode_t values.

Definition at line 374 of file QCassandraValue.h.

Referenced by setTimestamp(), setTimestampMode(), and timestampMode().

The TTL represents the number of seconds this value will be kept in the Cassandra database. For example, a log could be made to disappear automatically after 3 months.

The default value is TTL_PERMANENT which means that the value is permanent.

Definition at line 372 of file QCassandraValue.h.

Referenced by operator!=(), operator==(), setTtl(), and ttl().

By default, all the cells are saved with a TLL set to TTL_PERMANENT which means that the cells will persist as long as they are not deleted with a remove, truncate, or drop.

This value represents a permanent cell, whereas other values saved in the TTL parameter represent seconds.

See also:
setTtl()
ttl()

Definition at line 262 of file QCassandraValue.h.

Referenced by QtCassandra::QCassandraPrivate::insertValue().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

This document is part of the libQtCassandra Project.

Copyright by Made to Order Software Corp.