A dummy interface for cassandra.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.settings
lib
src
test/org/pescuma/dummycassandra
.classpath
.gitignore
.project
.travis.yml
README.md
build.xml

README.md

dummy-cassandra

A dummy interface for Cassandra. It is aimed at a simple API and doesn't intend to be complete.

Built upon the shoulders of Hector.

Build Status

Features

  • Simple interface
  • All queries are paginated
  • Define once the column families and they will be created if necessary

Usage

  1. Create the cluster

    CassandraCluster cluster = new CassandraCluster("test-cluster", "localhost");
  2. Create the keyspaces

    CassandraKeyspace keyspace = cluster.addKeyspace("MyKeyspace");
  3. Create the column families and super-column families

    keyspace.addColumnFamily("ColumnFamilyName", CassandraType.UTF8, CassandraType.UTF8, CassandraType.UTF8);
    
    keyspace.addSuperColumnFamily("SuperColumnFamilyName", CassandraType.UTF8, CassandraType.UTF8, CassandraType.UTF8, CassandraType.Counter);
  4. Connect to the cluster and create the column families if needed

    cluster.connect();
  5. Insert data

    keyspace.getColumnFamily("ColumnFamilyName").getRow("row-id").insertColumn("column-name", "column-value");
    
    keyspace.getSuperColumnFamily("SuperColumnFamilyName").getRow("row-id").getSuperColumn("super-column-id").incrementCounter("column-name", 1);
  6. Read data

    (String) keyspace.getColumnFamily("ColumnFamilyName").getRow("row-id").getColumn("column-name");
    
    (Long) keyspace.getSuperColumnFamily("SuperColumnFamilyName").getRow("row-id").getSuperColumn("super-column-id").getColumn("column-name");
  7. List rows / columns

    keyspace.getColumnFamily("ColumnFamilyName").getRowKeys();
    keyspace.getColumnFamily("ColumnFamilyName").getRow("row-id").getColumnCount();
    keyspace.getColumnFamily("ColumnFamilyName").getRow("row-id").getColumnNames();
    
    keyspace.getSuperColumnFamily("SuperColumnFamilyName").getRowKeys();
    keyspace.getSuperColumnFamily("SuperColumnFamilyName").getRow("row-id").getSuperColumnCount();
    keyspace.getSuperColumnFamily("SuperColumnFamilyName").getRow("row-id").getSuperColumnKeys();
    keyspace.getSuperColumnFamily("SuperColumnFamilyName").getRow("row-id").getSuperColumn("super-column-id").getColumnCount();
    keyspace.getSuperColumnFamily("SuperColumnFamilyName").getRow("row-id").getSuperColumn("super-column-id").getColumnNames();
  8. List a range of columns

    keyspace.getColumnFamily("ColumnFamilyName").getRow("row-id").getColumnNames("start", "end");
    
    keyspace.getSuperColumnFamily("SuperColumnFamilyName").getRow("row-id").getSuperColumnKeys("start", "end");
    keyspace.getSuperColumnFamily("SuperColumnFamilyName").getRow("row-id").getSuperColumn("super-column-id").getColumnNames("start", "end");

    Quering a range of rows won't be implemented because, depending on the partitioner, the range makes no sense and won't work as expected.

  9. Delete data

    keyspace.getColumnFamily("ColumnFamilyName").getRow("row-id").deleteColumn("column-name");
    	
    keyspace.getSuperColumnFamily("SuperColumnFamilyName").getRow("row-id").getSuperColumn("super-column-id").deleteColumn("column-name");

Dependencies

To download dependencies

ant deps

TODO

  • Tests
  • Delete rows / super-columns
  • Indexes

License

MIT. Check LICENSE file.