Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Cassandra::Simple Perl Module - Easy to use, Perl oriented client interface to Apache Cassandra.

tree: 544ecc30a6

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 examples
Octocat-spinner-32 lib
Octocat-spinner-32 README
README
NAME
    Cassandra::Simple

VERSION
    version 0.1

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( $keyspace, $column_family);

            $conn->insert($column_family, 'KeyA', [ [ 'ColumnA' => 'AA' ], [ 'ColumnB' => 'AB' ] ] );

            $conn->get($column_family, 'KeyA');
            $conn->get($column_family, 'KeyA', { columns => [ qw/ColumnA/ ] });
            $conn->get($column_family, 'KeyA', { column_count => 1, column_reversed => 1 });

            $conn->batch_insert($column_family, { 'KeyB' => [ [ 'ColumnA' => 'BA' ] , [ 'ColumnB' => 'BB' ] ], 'KeyC' => [ [ 'ColumnA' => 'CA' ] , [ 'ColumnD' => 'CD' ] ] });

            $conn->multiget($column_family, [qw/KeyA KeyC/]);

            $conn->get_range($column_family, { start=> 'KeyA', finish => 'KeyB', column_count => 1 });
            $conn->get_range($column_family);

            $conn->get_indexed_slices($column_family, { expression_list => [ [ 'ColumnA' => 'BA' ] ] });

            $conn->remove($column_family, [ 'KeyA' ], { columns => [ 'ColumnA' ]});
            $conn->remove($column_family, [ 'KeyA' ]);
            $conn->remove($column_family);

            $conn->get_count($column_family, 'KeyA');
            $conn->multiget_count($column_family, [ 'KeyB', 'KeyC' ]);

  get
    Usage: "get($column_family, $key[, opt])"

    $opt is a *HASH* and can have the following keys:

      columns, column_start, column_finish, column_count, column_reversed,
      super_column, consistency_level_read

    Returns an HASH of the form "{ column => value, column => value }"

  multiget
    Usage: "multiget($column_family, $keys[, opt])"

    $keys should be an *ARRAYREF* of keys to fetch.

    All parameters in $opt are the same as in "get()"

    Returns an HASH of the form "{ key => { column => value, column => value
    }, key => { column => value, column => value } }"

  get_count
    Usage: "get_count($column_family, $key[, opt])"

    $opt is a *HASH* and can have the following keys:

      columns, column_start, column_finish, super_column,
      consistency_level_read

    Returns the count as an int

  multiget_count
    Usage: "multiget_count($column_family, $keys[, opt])"

    $keys should be an *ARRAYREF* of keys.

    All parameters in $opt are the same as in "get_count()"

    Returns a mapping of "key -> count"

  get_range
    Usage: "get_range( $column_family[, opt])"

    $opt is a *HASH* and can have the following keys:

      start, finish, columns, column_start, column_finish, column_reversed,
      column_count, row_count, super_column, consistency_level_read

    Returns an *HASH* of the form "{ key => { column => value, column =>
    value }, key => { column => value, column => value } }"

  get_indexed_slices
    Usage: "get_indexed_slices($column_family, $index_clause[, opt])"

    $index_clause is an *HASH* containing the following keys:

      expression_list, start_key, row_count

      The *expression_list* is an *ARRAYREF* of the form "[ [ column =>
      value ] ]"

    $opt is an *HASH* and can have the following keys:

      columns, column_start, column_finish, column_reversed, column_count,
      consistency_level_read

    Returns an *HASH* of the form "{ key => { column => value, column =>
    value }, key => { column => value, column => value } }"

  insert
    Usage: "insert($column_family, $key, $columns[, opt])"

    The $columns is an *HASHREF* of the form "{ column => value, column =>
    value }"

    $opt is an *HASH* and can have the following keys:

      timestamp, ttl, consistency_level_write

  insert_super
    Usage: "insert_super($column_family, $key, $columns[, opt])"

    The $columns is an *HASH* of the form "{ super_column => { column =>
    value, column => value } }"

    $opt is an *HASH* and can have the following keys:

      timestamp, ttl, consistency_level_write

  batch_insert
    Usage: "batch_insert($column_family, $rows[, opt])"

    $rows is an *HASH* of the form "{ key => { column => value , column =>
    value }, key => { column => value , column => value } }"

    $opt is an *HASH* and can have the following keys:

      timestamp, ttl, consistency_level_write

  remove
    Usage: "remove($column_family[, $keys][, opt])"

    $keys is a key or an *ARRAY* of keys to be deleted.

    A removal whitout keys truncates the whole column_family.

    $opt is an *HASH* and can have the following keys:

      columns, super_column, write_consistency_level

    The timestamp used for remove is returned.

  list_keyspace_cfs
    Usage: "list_keyspace_cfs($keyspace)"

    Returns an HASH of "{ column_family_name => column_family_type }" where
    column family type is either "Standard" or "Super"

  create_column_family
    Usage "create_column_family($keyspace, $column_family[, $cfdef])"

    Creates a new column family $column_family in keyspace $keyspace. $cfdef
    is an HASH containing Column Family Definition options (column_type,
    comparator_type, etc.).

  create_index
    Usage: "create_index($keyspace, $column_family, $column,
    [$validation_class])"

    Creates an index on $column of $column_family.

    $validation_class only applies when $column doesn't yet exist, and even
    then it is optional (defaults to *BytesType*).

  ring
    Usage: "ring($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_keyspaces

      list<KsDef> describe_keyspaces()

      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)

      system_add_keyspace

      string system_add_keyspace(KSDef ks_def)

      system_drop_keyspace

      string system_drop_keyspace(string keyspace)

ACKNOWLEDGEMENTS
    Implementation 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 "<the.wa.syndrome@gmail>"

COPYRIGHT AND LICENSE
    This software is copyright (c) 2011 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.

Something went wrong with that request. Please try again.