Methods summary
public
|
#
__construct( phpcassa\Connection\ConnectionPool $pool, string $column_family, boolean $autopack_names = true, boolean $autopack_values = true, cassandra\ConsistencyLevel $read_consistency_level = phpcassa\ConsistencyLevel::ONE, cassandra\ConsistencyLevel $write_consistency_level = phpcassa\ConsistencyLevel::ONE, integer $buffer_size = phpcassa\AbstractColumnFamily::DEFAULT_BUFFER_SIZE )
Constructs a ColumnFamily.
Constructs a ColumnFamily.
Parameters
- $pool
phpcassa\Connection\ConnectionPool
$pool the pool to use when querying Cassandra
- $column_family
string $column_family the name of the column family in Cassandra
- $autopack_names
boolean $autopack_names whether or not to automatically convert column names to and from
their binary representation in Cassandra based on their comparator type
- $autopack_values
boolean $autopack_values whether or not to automatically convert column values to and
from their binary representation in Cassandra based on their validator type
- $read_consistency_level
cassandra\ConsistencyLevel
$read_consistency_level the default consistency level for read operations on
this column family
- $write_consistency_level
cassandra\ConsistencyLevel
$write_consistency_level the default consistency level for write operations on
this column family
- $buffer_size
integer $buffer_size When calling get_range , the intermediate results need
to be buffered if we are fetching many rows, otherwise the Cassandra server will
overallocate memory and fail. This is the size of that buffer in number of rows.
|
public
|
#
set_autopack_names( boolean $pack_names )
Parameters
- $pack_names
boolean $pack_names whether or not column names are automatically packed/unpacked
|
public
|
#
set_autopack_values( boolean $pack_values )
Parameters
- $pack_values
boolean $pack_values whether or not column values are automatically packed/unpacked
|
public
|
#
set_autopack_keys( boolean $pack_keys )
Parameters
- $pack_keys
boolean $pack_keys whether or not keys are automatically packed/unpacked Available since
Cassandra 0.8.0.
|
public
mixed
|
#
get( string $key, phpcassa\ColumnSlice $column_slice = null, mixed[] $column_names = null, cassandra\ConsistencyLevel $consistency_level = null )
Fetch a row from this column family.
Fetch a row from this column family.
Parameters
- $key
string $key row key to fetch
- $column_slice
phpcassa\ColumnSlice
a slice of columns to fetch, or null
- $column_names
mixed[] $column_names limit the columns or super columns fetched to this list
- $consistency_level
cassandra\ConsistencyLevel
$consistency_level affects the guaranteed number of nodes that must respond
before the operation returns
Returns
mixed array(column_name => column_value)
|
public
mixed
|
#
multiget( string[] $keys, phpcassa\ColumnSlice $column_slice = null, mixed[] $column_names = null, cassandra\ConsistencyLevel $consistency_level = null, integer $buffer_size = 16 )
Fetch a set of rows from this column family.
Fetch a set of rows from this column family.
Parameters
- $keys
string[] $keys row keys to fetch
- $column_slice
phpcassa\ColumnSlice
a slice of columns to fetch, or null
- $column_names
mixed[] $column_names limit the columns or super columns fetched to this list
- $consistency_level
cassandra\ConsistencyLevel
$consistency_level affects the guaranteed number of nodes that must respond
before the operation returns
- $buffer_size
integer $buffer_size the number of keys to multiget at a single time. If your rows are
large, having a high buffer size gives poor performance; if your rows are small,
consider increasing this value.
Returns
mixed array(key => array(column_name => column_value))
|
public
integer
|
#
get_count( string $key, phpcassa\ColumnSlice $column_slice = null, mixed[] $column_names = null, cassandra\ConsistencyLevel $consistency_level = null )
Count the number of columns in a row.
Count the number of columns in a row.
Parameters
- $key
string $key row to be counted
- $column_slice
phpcassa\ColumnSlice
a slice of columns to count, or null
- $column_names
mixed[] $column_names limit the possible columns or super columns counted to this list
- $consistency_level
cassandra\ConsistencyLevel
$consistency_level affects the guaranteed number of nodes that must respond
before the operation returns
Returns
integer
|
public
mixed
|
#
multiget_count( string[] $keys, phpcassa\ColumnSlice $column_slice = null, mixed[] $column_names = null, cassandra\ConsistencyLevel $consistency_level = null )
Count the number of columns in a set of rows.
Count the number of columns in a set of rows.
Parameters
- $keys
string[] $keys rows to be counted
- $column_slice
phpcassa\ColumnSlice
a slice of columns to count, or null
- $column_names
mixed[] $column_names limit the possible columns or super columns counted to this list
- $consistency_level
cassandra\ConsistencyLevel
$consistency_level affects the guaranteed number of nodes that must respond
before the operation returns
Returns
mixed array(row_key => row_count)
|
public
phpcassa\Iterator\RangeColumnFamilyIterator
|
#
get_range( mixed $key_start = "", mixed $key_finish = "", integer $row_count = phpcassa\AbstractColumnFamily::DEFAULT_ROW_COUNT , phpcassa\ColumnSlice $column_slice = null, mixed[] $column_names = null, cassandra\ConsistencyLevel $consistency_level = null, integer $buffer_size = null )
Get an iterator over a range of rows.
Get an iterator over a range of rows.
Parameters
- $key_start
mixed $key_start fetch rows with a key >= this
- $key_finish
mixed $key_finish fetch rows with a key <= this
- $row_count
integer $row_count limit the number of rows returned to this amount
- $column_slice
phpcassa\ColumnSlice
a slice of columns to fetch, or null
- $column_names
mixed[] $column_names limit the columns or super columns fetched to this list
- $consistency_level
cassandra\ConsistencyLevel
$consistency_level affects the guaranteed number of nodes that must respond
before the operation returns
- $buffer_size
integer $buffer_size When calling get_range , the intermediate results need
to be buffered if we are fetching many rows, otherwise the Cassandra server will
overallocate memory and fail. This is the size of that buffer in number of rows.
Returns
|
public
phpcassa\Iterator\RangeColumnFamilyIterator
|
#
get_range_by_token( string $token_start = "", string $token_finish = "", integer $row_count = phpcassa\AbstractColumnFamily::DEFAULT_ROW_COUNT , phpcassa\ColumnSlice $column_slice = null, mixed[] $column_names = null, cassandra\ConsistencyLevel $consistency_level = null, integer $buffer_size = null )
Get an iterator over a token range.
Get an iterator over a token range.
Example usages of get_range_by_token() : 1. You can iterate part of the ring.
This helps to start several processes, that scans the ring in parallel in
fashion similar to Hadoop. Then full ring scan will take only 1 / <number of
processes>
2. You can iterate "local" token range for each Cassandra node. You can start
one process on each cassandra node, that iterates only on token range for this
node. In this case you minimize the network traffic between nodes.
3. Combinations of the above.
Parameters
- $token_start
string $token_start fetch rows with a token >= this
- $token_finish
string $token_finish fetch rows with a token <= this
- $row_count
integer $row_count limit the number of rows returned to this amount
- $column_slice
phpcassa\ColumnSlice
a slice of columns to fetch, or null
- $column_names
mixed[] $column_names limit the columns or super columns fetched to this list
- $consistency_level
cassandra\ConsistencyLevel
$consistency_level affects the guaranteed number of nodes that must respond
before the operation returns
- $buffer_size
integer $buffer_size When calling get_range , the intermediate results need
to be buffered if we are fetching many rows, otherwise the Cassandra server will
overallocate memory and fail. This is the size of that buffer in number of rows.
Returns
|
public
phpcassa\Iterator\IndexedColumnFamilyIterator
|
#
get_indexed_slices( phpcassa\Index\IndexClause $index_clause, phpcassa\ColumnSlice $column_slice = null, mixed[] $column_names = null, mixed $consistency_level = null, mixed $buffer_size = null )
Fetch a set of rows from this column family based on an index clause.
Fetch a set of rows from this column family based on an index clause.
Parameters
- $index_clause
phpcassa\Index\IndexClause
$index_clause limits the keys that are returned based on expressions that
compare the value of a column to a given value. At least one of the expressions
in the IndexClause must be on an indexed column.
- $column_slice
phpcassa\ColumnSlice
a slice of columns to fetch, or null
- $column_names
mixed[] $column_names limit the columns or super columns fetched to this list number of
nodes that must respond before the operation returns
- $consistency_level
- $buffer_size
Returns
|
public
integer
|
#
insert( string $key, mixed[] $columns, integer $timestamp = null, integer $ttl = null, cassandra\ConsistencyLevel $consistency_level = null )
Insert or update columns in a row.
Insert or update columns in a row.
Parameters
- $key
string $key the row to insert or update the columns in
- $columns
mixed[] $columns array(column_name => column_value) the columns to insert or update
- $timestamp
integer $timestamp the timestamp to use for this insertion. Leaving this as null will
result in a timestamp being generated for you
- $ttl
integer $ttl time to live for the columns; after ttl seconds they will be deleted
- $consistency_level
cassandra\ConsistencyLevel
$consistency_level affects the guaranteed number of nodes that must respond
before the operation returns
Returns
integer the timestamp for the operation
|
public
integer
|
#
batch_insert( array $rows, integer $timestamp = null, integer $ttl = null, cassandra\ConsistencyLevel $consistency_level = null )
Insert or update columns in multiple rows. Note that this operation is only
atomic per row.
Insert or update columns in multiple rows. Note that this operation is only
atomic per row.
Parameters
- $rows
array $rows an array of keys, each of which maps to an array of columns. This looks
like array(key => array(column_name => column_value))
- $timestamp
integer $timestamp the timestamp to use for these insertions. Leaving this as null will
result in a timestamp being generated for you
- $ttl
integer $ttl time to live for the columns; after ttl seconds they will be deleted
- $consistency_level
cassandra\ConsistencyLevel
$consistency_level affects the guaranteed number of nodes that must respond
before the operation returns
Returns
integer the timestamp for the operation
|
public
a
|
#
batch( phpcassa\ConsistencyLevel $consistency_level = null )
Create a new phpcassa\Batch\CfMutator instance targetting this column
family.
Create a new phpcassa\Batch\CfMutator instance targetting this column
family.
Parameters
- $consistency_level
phpcassa\ConsistencyLevel $consistency_level the consistency level the batch mutator will write at; if
left as NULL, this defaults to phpcassa\ColumnFamily::write_consistency_level.
Returns
a phpcassa\Batch\CfMutator instance
|
public
integer
|
#
remove( string $key, mixed[] $column_names = null, cassandra\ConsistencyLevel $consistency_level = null )
Delete a row or a set of columns or supercolumns from a row.
Delete a row or a set of columns or supercolumns from a row.
Parameters
- $key
string $key the row to remove columns from
- $column_names
mixed[] $column_names the columns or supercolumns to remove. If null, the entire row
will be removed.
- $consistency_level
cassandra\ConsistencyLevel
$consistency_level affects the guaranteed number of nodes that must respond
before the operation returns
Returns
integer the timestamp for the operation
|
public
|
#
remove_counter( string $key, mixed $column, cassandra\ConsistencyLevel $consistency_level = null )
Remove a counter at the specified location.
Remove a counter at the specified location.
Note that counters have limited support for deletes: if you remove a counter,
you must wait to issue any following update until the delete has reached all the
nodes and all of them have been fully compacted.
Available in Cassandra 0.8.0 and later.
Parameters
- $key
string $key the key for the row
- $column
mixed $column the column name of the counter
- $consistency_level
cassandra\ConsistencyLevel
$consistency_level affects the guaranteed number of nodes that must respond
before the operation returns
|
public
|
#
truncate( )
Mark the entire column family as deleted.
Mark the entire column family as deleted.
From the user's perspective a successful call to truncate will result
complete data deletion from cfname. Internally, however, disk space will not be
immediatily released, as with all deletes in cassandra, this one only marks the
data as deleted.
The operation succeeds only if all hosts in the cluster at available and will
throw an UnavailableException if some hosts are down.
|
Constants summary
integer |
DEFAULT_ROW_COUNT
|
100 |
#
The default limit to the number of rows retrieved in queries.
The default limit to the number of rows retrieved in queries.
|
integer |
DEFAULT_BUFFER_SIZE
|
100 |
|
integer |
DICTIONARY_FORMAT
|
1 |
#
Data that is returned will be stored in a "dictionary" format, where array
keys correspond to row keys, super column names, or column names. Data that is
inserted should match this format.
Data that is returned will be stored in a "dictionary" format, where array
keys correspond to row keys, super column names, or column names. Data that is
inserted should match this format.
When using non-scalar types or floats with this format, array keys must be
serialized and unserialized. This is typically a good reason to use one of the
other formats.
This format is what phpcassa has historically used. This may be used for both
ColumnFamily::insert_format and ColumnFamily::return_format.
|
integer |
ARRAY_FORMAT
|
2 |
#
Data that is returned will be stored in normal, non-mapping arrays. For
example, a column will be represented as array($name, $value), and a row
returned with multiget() will be represented as array($rowkey,
array(array($colname1, $colval1), array($colname2, $colval2))).
Data that is returned will be stored in normal, non-mapping arrays. For
example, a column will be represented as array($name, $value), and a row
returned with multiget() will be represented as array($rowkey,
array(array($colname1, $colval1), array($colname2, $colval2))).
Data that is inserted should match this format. Serialization is not needed
with this format.
This may be used for both ColumnFamily::insert_format and
ColumnFamily::return_format.
|
integer |
OBJECT_FORMAT
|
3 |
#
Data will be returned in a object-based format, roughly matching what Thrift
returns directly. This means that results will contain: Column objects, which
have $name, $value, $timestamp, and $ttl attributes; CounterColumn objects,
which have $name and $value attributes; SuperColumn objects, which have $name
and $columns attributes, where $columns is an array of Column or CounterColumn
objects.
Data will be returned in a object-based format, roughly matching what Thrift
returns directly. This means that results will contain: Column objects, which
have $name, $value, $timestamp, and $ttl attributes; CounterColumn objects,
which have $name and $value attributes; SuperColumn objects, which have $name
and $columns attributes, where $columns is an array of Column or CounterColumn
objects.
This format can currently only be used for ColumnFamily::return_format, not
ColumnFamily::insert_format.
Unserialization is not required for this format.
|
Properties summary
public
mixed
|
$autopack_names
|
|
#
Whether column names should be packed and unpacked automatically. Default is
true.
Whether column names should be packed and unpacked automatically. Default is
true.
|
public
mixed
|
$autopack_values
|
|
#
Whether column values should be packed and unpacked automatically. Default is
true.
Whether column values should be packed and unpacked automatically. Default is
true.
|
public
mixed
|
$autopack_keys
|
|
#
Whether keys should be packed and unpacked automatically. Default is
true.
Whether keys should be packed and unpacked automatically. Default is
true.
|
public
cassandra\ConsistencyLevel
|
$read_consistency_level
|
phpcassa\ConsistencyLevel::ONE |
#
the default read consistency level
the default read consistency level
|
public
cassandra\ConsistencyLevel
|
$write_consistency_level
|
phpcassa\ConsistencyLevel::ONE |
#
the default write consistency level
the default write consistency level
|
public
integer
|
$return_format
|
phpcassa\AbstractColumnFamily::DICTIONARY_FORMAT
|
#
The format that data will be returned in.
The format that data will be returned in.
Valid values include DICTIONARY_FORMAT, ARRAY_FORMAT, and OBJECT_FORMAT.
|
public
integer
|
$insert_format
|
phpcassa\AbstractColumnFamily::DICTIONARY_FORMAT
|
#
The format that data should be inserted in.
The format that data should be inserted in.
Valid values include DICTIONARY_FORMAT and ARRAY_FORMAT.
|
public
integer
|
$buffer_size
|
100 |
#
When calling get_range , the intermediate results need
to be buffered if we are fetching many rows, otherwise the Cassandra
server will overallocate memory and fail. This is the size of
that buffer in number of rows. The default is 100.
When calling get_range , the intermediate results need to be
buffered if we are fetching many rows, otherwise the Cassandra server will
overallocate memory and fail. This is the size of that buffer in number of rows.
The default is 100.
|