Need help with cassandra-tutorial?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

128 Stars 62 Forks 60 Commits 2 Opened issues


Basic tutorial for working with Apache Cassandra in Java via the Hector client

Services available


Need anything else?

Contributors list

# 142,825
1 commit


This is a step-by-step tutorial designed to expose folks who might be new to Apache Cassandra to some more real-world examples of usage. This tutorial was initially put together a presentation I made at Data Day Austin in late January of 2011. It has been recently updated for Cassandra SF 2011.

This tutorial assumes you have a release of Apache Cassandra version 0.8.x running on your machine accessible via localhost:9160 (the default). All necessary keyspace creation scripts and data inserts are included.

Tutorial examples are designed to be run by Maven via the maven-exec-plugin. This makes dependency management a breeze (see the pom file!) and removes the need for goofy classpath maintenance scripts and such. An example of command invocation is in the Javadoc comment of each file. For example, to invoke the GetCityForNpanxx class, the following command should be used:

mvn -e exec:java -Dexec.args="get" -Dexec.mainClass="com.datastax.tutorial.TutorialRunner"

To execute the schema creation and import script use the following:

bin/cassandra-cli --host localhost < /path/to/script/npanxx_script.txt

This script creates a keyspace named 'Tutorial' and three column families:

  • StateCity: uses the state and city as a key. Column names are area codes, values are a concatenation of latitude and longitude
  • AreaCode: Uses the area code as a key, with the city ad NPA mapped to the latitude and longitude
  • Npanxx: Key is NPA and NXX concatenation. Column names static in that each row has the same number and type of columns

Have a look at npanxx_script.txt for more details - the contents are fairly straight forward. Even more so when you go through the tutorials.

The sample data used in this tutorial is taken from the North American Numbering Plan

I found my copy via [InfoChimps!](

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.