Be cautious about using it in production!
NAME Cassandra::Simple
VERSION version 0.2
DESCRIPTION Easy to use, Perl oriented client interface to Apache Cassandra.
This module attempts to abstract the underlying Thrift methods as much
as possible to allow any Perl developer a small learning curve when
using Cassandra.
SYNOPSYS my ($keyspace, $column_family) = qw/simple simple/;
my $conn = Cassandra::Simple->new(keyspace => $keyspace,);
$conn->create_column_family( column_family => $column_family);
$conn->insert(column_family => $column_family, key => 'KeyA', columns => { 'ColumnA' => 'AA' , 'ColumnB' => 'AB' } );
$conn->get(column_family => $column_family, key => 'KeyA');
$conn->get(column_family => $column_family, key => 'KeyA', columns => [ qw/ColumnA/ ]);
$conn->get(column_family => $column_family, key => 'KeyA', column_count => 1, column_reversed => 1);
$conn->batch_insert(column_family => $column_family, rows => { 'KeyB' => [ [ 'ColumnA' => 'BA' ] , [ 'ColumnB' => 'BB' ] ], 'KeyC' => [ [ 'ColumnA' => 'CA' ] , [ 'ColumnD' => 'CD' ] ] });
$conn->multiget(column_family => $column_family, 'keys' => [qw/KeyA KeyC/]);
$conn->get_range(column_family => $column_family, start => 'KeyA', finish => 'KeyB', column_count => 1 );
$conn->get_range(column_family => $column_family);
$conn->get_indexed_slices(column_family => $column_family, expression_list => [ [ 'ColumnA' => 'BA' ] ]);
$conn->remove(column_family => $column_family, 'keys' => [ 'KeyA' ], columns => [ 'ColumnA' ]);
$conn->remove(column_family => $column_family, 'keys' => [ 'KeyA' ]);
$conn->remove(column_family => $column_family);
$conn->get_count(column_family => $column_family, key => 'KeyA');
$conn->multiget_count(column_family => $column_family, 'keys' => [ 'KeyB', 'KeyC' ]);
get Arguments:
column_family, key, columns, column_start, column_finish,
column_count, column_reversed, super_column, consistency_level
Returns an HASH of the form "{ column => value, column => value }"
multiget Arguments:
column_family, keys, columns, column_start, column_finish,
column_count, column_reversed, super_column, consistency_level
Returns an HASH of the form "{ key => { column => value, column => value
}, key => { column => value, column => value } }"
get_count Arguments:
column_family, key, columns, column_start, column_finish,
super_column, consistency_level
Returns the count as an int
multiget_count Arguments:
column_family, keys, columns, column_start, column_finish,
super_column, consistency_level
Returns a mapping of "key -> count"
get_range Arguments:
column_family, start, finish, columns, column_start, column_finish,
column_reversed, column_count, row_count, super_column,
consistency_level
Returns an *HASH* of the form "{ key => { column => value, column =>
value }, key => { column => value, column => value } }"
get_indexed_slices Arguments:
column_family, expression_list, start, row_count, columns,
column_start, column_finish, column_reversed, column_count,
consistency_level
The *expression_list* is an *ARRAYREF* of *ARRAYREF* containing
"$column[, $operator], $value". $operator can be '=', '<', '>', '<=' or
'>='.
Returns an *HASH* of the form "{ key => { column => value, column =>
value }, key => { column => value, column => value } }"
insert Arguments:
column_family, key, columns, timestamp, ttl, consistency_level
The $columns is an *HASHREF* of the form "{ column => value, column =>
value }"
insert_super Arguments:
column_family, key, columns, timestamp, ttl, consistency_level
The $columns is an *HASH* of the form "{ super_column => { column =>
value, column => value } }"
batch_insert Arguments:
column_family, rows, timestamp, ttl, consistency_level
$rows is an *HASH* of the form "{ key => { column => value , column =>
value }, key => { column => value , column => value } }"
add Arguments:
column_family, key, column, value, super_column, consistency_level
Increment or decrement counter $column by $value. $value is 1 by
default.
batch_add Arguments:
column_family, rows, consistency_level
$rows is an *HASH* of the form "{ key => { column => value , column =>
value }, key => { column => value , column => value } }"
remove_counter Remove counter $column on $key.
Arguments:
column_family, key, column, super_column, consistency_level_write
remove Arguments:
column_family, keys, columns, super_column, write_consistency_level
$keys is a key or an *ARRAY* of keys to be deleted.
A removal whitout keys truncates the whole column_family.
The timestamp used for remove is returned.
list_keyspace_cfs Arguments:
Returns an HASH of "{ column_family_name => column_family_type }" where
column family type is either "Standard" or "Super"
create_column_family Arguments:
keyspace, column_family, "cfdef"
"cfdef" is any Column Family Definition option (column_type,
comparator_type, etc.).
create_keyspace Arguments:
keyspace, strategy, strategy_options
list_keyspaces Arguments:
drop_keyspace Arguments:
keyspace
create_index Arguments:
keyspace, column_family, columns, validation_class
Creates an index on $columns of $column_family. $columns is an ARRAY of
column names to be indexed. $validation_class only applies when $column
doesn't yet exist, and even then it is optional (defaults to
*BytesType*).
ring Arguments:
keyspace
Lists the addresses of all nodes on the cluster associated with the
keyspace "<$keyspace">.
BUGS Bugs should be reported on github at https://github.com/fmgoncalves/p5-cassandra-simple.
TODO Thrift Type Checking and Packing/Unpacking
The defined types (or defaults) for each column family are known and
should therefore be complied with. Introducing Composite Types has
forcefully introduced this functionality to an extent, but there should
be a refactoring to make this ubiquitous to the client.
Error Handling
Exceptions raised when calling Cassandra code should be reported in
error form with appropriate description.
Unit Tests
Sort of done in the examples folder
<https://github.com/fmgoncalves/p5-cassandra-simple/tree/master/exampl
es>
Tombstones
get, get_range and get_indexed_slices should probably filter out
tombstones, even if it means returning less than the requested count.
Ideally it would retry until it got enough results.
Methods
The following are Thrift methods left unimplemented.
Not all of these will be implemented, since some aren't useful to the
common developer.
Priority will be given to live schema updating methods.
describe_cluster_name
string describe_cluster_name()
describe_keyspace
KsDef describe_keyspace(string keyspace)
describe_partitioner
string describe_partitioner()
describe_snitch
string describe_snitch()
describe_version
string describe_version()
system_drop_column_family
string system_drop_column_family(ColumnFamily column_family)
ACKNOWLEDGEMENTS Implementation loosely based on Cassandra::Lite.
<http://search.cpan.org/~gslin/Cassandra-Lite-0.0.4/lib/Cassandra/Lite
.pm>
API based on Pycassa.
<http://pycassa.github.com/pycassa/>
AUTHOR Filipe Gonçalves "[email protected]"
COPYRIGHT AND LICENSE This software is copyright (c) 2012 by Filipe Gonçalves.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.