Book Image

Cassandra High Performance Cookbook

By : Edward Capriolo
Book Image

Cassandra High Performance Cookbook

By: Edward Capriolo

Overview of this book

<p>Apache Cassandra is a fault-tolerant, distributed data store which offers linear scalability allowing it to be a storage platform for large high volume websites. <br /><br />This book provides detailed recipes that describe how to use the features of Cassandra and improve its performance. Recipes cover topics ranging from setting up Cassandra for the first time to complex multiple data center installations. The recipe format presents the information in a concise actionable form.<br /><br />The book describes in detail how features of Cassandra can be tuned and what the possible effects of tuning can be. Recipes include how to access data stored in Cassandra and use third party tools to help you out. The book also describes how to monitor and do capacity planning to ensure it is performing at a high level. Towards the end, it takes you through the use of libraries and third party applications with Cassandra and Cassandra integration with Hadoop.</p>
Table of Contents (20 chapters)
Cassandra High Performance Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Storing and searching edge graph data in Cassandra


Graph databases are used to store structures based on data from graph theory. Graph databases have a concept of nodes that are entries and edges that connect one node to another. Typically, graph databases are used to determine data that is closely related, as in the following image:

This recipe shows how to use, store, and traverse a simple graph database.

Getting ready

Create a keyspace and column family to store the graph data and insert some sample data into it.

[default@unknown] connect localhost/9160;                 
[default@unknown] create keyspace graph;  
[default@unknown] use graph; 
[default@graph] create column family graph; 
[default@graph] set graph['a']['b']=''; 
[default@graph] set graph['a']['c']=''; 
[default@graph] set graph['c']['d']=''; 
[default@graph] set graph['d']['a']=''; 
[default@graph] set graph['c']['e']=''; 

How to do it...

  1. Create <hpc_build>/src/hpcas/c06/Graph.java:

    package hpcas.c06;
    
    import hpcas.c03...