libQtCassandra 0.3.2

QtCassandra::QCassandraColumnRangePredicate Class Reference

Define a range of columns. More...

#include <QCassandraColumnPredicate.h>

Inheritance diagram for QtCassandra::QCassandraColumnRangePredicate:
Collaboration diagram for QtCassandra::QCassandraColumnRangePredicate:

List of all members.

Public Member Functions

 QCassandraColumnRangePredicate ()
 Initializes a column range predicate.
consistency_level_t consistencyLevel () const
 Retrieve the consistency level.
int32_t count () const
 Return the maximum number of cells that will be returned.
const QByteArray & endColumnKey () const
 Retrieve a copy of the end column key.
QString endColumnName () const
 Retrieve the end column name.
bool reversed () const
 Check whether the list of rows is returned from the start or the end.
void setConsistencyLevel (consistency_level_t consistency_level)
 Set the consistency level.
void setCount (int32_t count=100)
 Change the number of rows to return.
void setFinishColumnKey (const QByteArray &column_key)
 Define the last row key.
void setFinishColumnName (const QString &column_name)
 Set the end column name.
void setReversed (bool reversed=true)
 Defines whether the list of rows should start from the end.
void setStartColumnKey (const QByteArray &column_key)
 Set the start column key.
void setStartColumnName (const QString &column_name)
 Set the name of the start column.
const QByteArray & startColumnKey () const
 Retrieve a copy of the start column key.
QString startColumnName () const
 Retrieve a copy of the start column name.

Private Member Functions

virtual void toPredicate (void *data) const
 Transform to a Thrift predicate.

Private Attributes

cassandra_count_t f_count
 The maximum number of columns to retrieve.
QByteArray f_end_column
 The last column to return.
controlled_vars::zbool_t f_reversed
 Whether the list of columns is returned in reversed order.
QByteArray f_start_column
 The first column to return.

Detailed Description

This function constrains the set of columns to return using a lower and higher bounds. The bounds are inclusive (if they match a column name, they will be returned.

It is expected that the lower bound be smaller than the higher bound.

To avoid problems with transfering too much data, the column range is also bound by a counter. If more cells are found in the row, then only so many will be returned.

It is also possible to retrieve the columns in reverse order. This is really only useful if you have a large number of columns since once returned the columns are saved in a map which means it is sorted in some arbitrary way. You may need to clear the row cache to be able to read more data if the set is really large or some of the cells contain really large buffers (i.e. large images.)

Remember that once you executed and made use of data with large cells, it is wise to clear the cache in the row, the table, or the context.

See also:
setCount()
QCassandraRow::clearCache()
QCassandraCell::clearCache()

Definition at line 93 of file QCassandraColumnPredicate.h.


Constructor & Destructor Documentation

QtCassandra::QCassandraColumnRangePredicate::QCassandraColumnRangePredicate ( )

This function initializes a column range predicate.

By default, all the columns of a table are returned (limited to the count parameter.) If you add a start column name and a end column name, then only the columns defined between those (boundaries included) will be returned.

The constructor sets the reversed status to false (i.e. you get columns from the first to the last,) and sets the number of columns to return to 100.

Definition at line 364 of file QCassandraColumnPredicate.cpp.


Member Function Documentation

consistency_level_t QtCassandra::QCassandraColumnPredicate::consistencyLevel ( ) const [inherited]

This function returns the current consistency level defined in this column predicate. By default it is set to DEFAULT. You may want to change it with a call to the setConsistencyLevel() function.

To setup the default consistency, see the setConsistencyLevel() function of your QCassandra object.

Returns:
The current consistency level.
See also:
setConsistencyLevel()
QCassandra::setConsistencyLevel()

Definition at line 106 of file QCassandraColumnPredicate.cpp.

References QtCassandra::QCassandraColumnPredicate::f_consistency_level.

Referenced by QtCassandra::QCassandraPrivate::getCellCount(), and QtCassandra::QCassandraPrivate::getColumnSlice().

int32_t QtCassandra::QCassandraColumnRangePredicate::count ( ) const

This function retrieves the maximum number of cells that a column slice request will return. By default it is set to 100.

Returns:
The maximum number of cells to be returned by requests.
See also:
setCount()

Definition at line 519 of file QCassandraColumnPredicate.cpp.

References f_count.

Referenced by setCount().

const QByteArray & QtCassandra::QCassandraColumnRangePredicate::endColumnKey ( ) const

This function returns a constant reference to the current end column key.

Returns:
A constant reference key to the end column key.

Definition at line 458 of file QCassandraColumnPredicate.cpp.

References f_end_column.

QString QtCassandra::QCassandraColumnRangePredicate::endColumnName ( ) const

This function retrieves the column key in the form of a column name. The name is the UTF-8 string that you set using setColumnName().

If you used the setColumnKey() and the name was not valid UTF-8, then this function will throw an eror.

Returns:
The column string.

Definition at line 434 of file QCassandraColumnPredicate.cpp.

References f_end_column.

bool QtCassandra::QCassandraColumnRangePredicate::reversed ( ) const

This function retrieves the current state of the reversed flag. By default the flag is false which means rows are listed from the start to the end.

It can be changed using the setReversed() function.

Returns:
Whether the list of rows is returned in reverse order or not.
See also:
setReversed()

Definition at line 491 of file QCassandraColumnPredicate.cpp.

References f_reversed.

Referenced by setReversed().

void QtCassandra::QCassandraColumnPredicate::setConsistencyLevel ( consistency_level_t  consistency_level) [inherited]

This function changes the consistency level you want to use when you use this predicate.

The consistency levels are probably better on the Cassandra system. The default is ONE and the usual best choice is QUORUM.

Parameters:
[in]consistency_levelOne of the consistency levels.
See also:
consistencyLevel()

Definition at line 123 of file QCassandraColumnPredicate.cpp.

References QtCassandra::QCassandraColumnPredicate::f_consistency_level.

void QtCassandra::QCassandraColumnRangePredicate::setCount ( int32_t  count = 100)

This function defines the number of rows a table request will return when querying for a slice.

The default is 100.

Keep in mind that the entire set of rows will be returned in a single message, thus returning a very large number can fill up your memory quickly.

Parameters:
[in]countThe new number of rows to return when querying for a slice.
See also:
count()

Definition at line 539 of file QCassandraColumnPredicate.cpp.

References count(), and f_count.

void QtCassandra::QCassandraColumnRangePredicate::setFinishColumnKey ( const QByteArray &  column_key)

This function sets the last key you're interested in. It can safely be set to an empty key to not bound the last key.

Parameters:
[in]column_keyThe binary column key we stop searching.
See also:
endColumnKey()

Definition at line 472 of file QCassandraColumnPredicate.cpp.

References f_end_column.

Referenced by setFinishColumnName().

void QtCassandra::QCassandraColumnRangePredicate::setFinishColumnName ( const QString &  column_name)

This function defines the end column key using the UTF-8 string of the specified column name.

Parameters:
[in]column_nameThe name of the end column.

Definition at line 446 of file QCassandraColumnPredicate.cpp.

References setFinishColumnKey().

void QtCassandra::QCassandraColumnRangePredicate::setReversed ( bool  reversed = true)

This function defines whether the list of rows should start from the end of the table. By default, it starts from the beginning.

Parameters:
[in]reversedWhether it should be normal or reversed.
See also:
reversed()

Definition at line 505 of file QCassandraColumnPredicate.cpp.

References f_reversed, and reversed().

void QtCassandra::QCassandraColumnRangePredicate::setStartColumnKey ( const QByteArray &  column_key)

This function sets the start column key of this row predicate.

Parameters:
[in]column_keyThe new start column key.

Definition at line 416 of file QCassandraColumnPredicate.cpp.

References f_start_column.

Referenced by setStartColumnName().

void QtCassandra::QCassandraColumnRangePredicate::setStartColumnName ( const QString &  column_name)

This function defines the name of the start column to retrieve. All the columns defined between the start and end column names/keys will be returned by this predicate.

Parameters:
[in]column_nameThe name of the column to start with.

Definition at line 394 of file QCassandraColumnPredicate.cpp.

References setStartColumnKey().

const QByteArray & QtCassandra::QCassandraColumnRangePredicate::startColumnKey ( ) const

This function returns a constant reference to the start column key.

Returns:
A constant reference to the start column key.

Definition at line 405 of file QCassandraColumnPredicate.cpp.

References f_start_column.

QString QtCassandra::QCassandraColumnRangePredicate::startColumnName ( ) const

This function returns a copy of the start column name. If the start column key was defined with binary that is not UTF-8 compatible, this function will raise an exception while converting the buffer to UTF-8.

Returns:
The start column name.

Definition at line 381 of file QCassandraColumnPredicate.cpp.

References f_start_column.

void QtCassandra::QCassandraColumnRangePredicate::toPredicate ( void *  data) const [private, virtual]

This function is used to transform a QCassandraColumnRangePredicate object to a Cassandra SlicePredicate structure.

The input parameter is set to void * because the function is defined in the public header file and thus cannot directly make use of the Thrift type definitions.

Parameters:
[in]dataThe pointer to the SlicePredicate to setup.

Reimplemented from QtCassandra::QCassandraColumnPredicate.

Definition at line 555 of file QCassandraColumnPredicate.cpp.

References f_count, f_end_column, f_reversed, and f_start_column.


Member Data Documentation

This parameter defines the maximum number of columns that will be read using this predicate.

The number is ignored if the read is made using column names (since in that case the limit is defined by the number of column names you defined.)

Definition at line 120 of file QCassandraColumnPredicate.h.

Referenced by count(), setCount(), and toPredicate().

This parameter defines the binary key of the last column. The key is inclusive so if a column matches this key, it is also returned.

Definition at line 118 of file QCassandraColumnPredicate.h.

Referenced by endColumnKey(), endColumnName(), setFinishColumnKey(), and toPredicate().

This parameter can be used to search the column from the last to the first instead of the first to the last.

Definition at line 119 of file QCassandraColumnPredicate.h.

Referenced by reversed(), setReversed(), and toPredicate().

This parameter defines the binary key of the first column. The key is inclusive so if a column matches this key, it is also returned.

Definition at line 117 of file QCassandraColumnPredicate.h.

Referenced by setStartColumnKey(), startColumnKey(), startColumnName(), and toPredicate().


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.