This repository is the original C* Path project written in Java. It is also in the process of being ported to Scala at C* Path.
Support for reading and writing structured objects in Cassandra. Structured objects can be accessed whole or in part by hierarchical paths.
For more information see the blog post at the eBuddy Tech Blog. There is also a presentation about C* Path from Cassandra Summit Europe 2013.
On writeToPath
, the object is first converted into maps, lists, and simple objects with the help of
Jackson JSON Processor (the fasterxml.com version).
How objects are converted can be customized by using annotations supported by Jackson. These structures are then
decomposed into key-value pairs where the keys are paths.
On readFromPath
, the reverse process is used to recompose the key-value pairs back into a structured object or POJO.
Paths can be used to access structured data at different levels within the structure. A Path can also contain a special element that refers to an index within a list (or array or collection).
Note: Special support for Sets of simple values is also planned but not yet implemented. In the meantime sets can be modeled as maps.
###Example:
Class1 {
Class2 a = new Class2();
}
Class2 {
List<Class3> b = Arrays.asList(new Class3(42), new Class3(43));
}
Class3 {
int c;
Class3(int c) { this.c = c }
}
new Class1()
would be decomposed into the following key-value pairs:
a/b/@0/c/ -> 42
a/b/@1/c/ -> 43
The artifacts are published at Maven Central. To include C* Path in your project, use one of the following dependencies. Generally either the CQL or thrift dependency is used, but not both.
To include CQL module:
<dependency>
<groupId>com.ebuddy.cassandra</groupId>
<artifactId>cql-data-access</artifactId>
<version>2.4.2</version>
</dependency>
Or include the Thrift module:
<dependency>
<groupId>com.ebuddy.cassandra</groupId>
<artifactId>thrift-data-access</artifactId>
<version>2.4.2</version>
</dependency>
The main interface StructuredDataAccessSupport
and helper classes.
Implementation of StructuredDataAccessSupport
for CQL3. Uses the
Datastax Java Driver for transport and low level operations.
To use structured data in a CQL3 table, the following data modeling rules apply:
- The table should have one path column that is the first clustering key, i.e. the second column in the primary key after the partition key.
- There should be one other column for the values.
- The path and value columns should be typed as a textual type.
Implementations of StructuredDataAccessSupport
for standard column family access, using the
Hector client library (and therefore Thrift) for transport and
low level operations.
Shared code used by both thrift and cql modules.