Skip to content

Commit

Permalink
trivial update of CassandraStore to annotate methods
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/gora/trunk@1505206 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
Lewis John McGibbney committed Jul 20, 2013
1 parent f1917c4 commit 87e64a5
Showing 1 changed file with 33 additions and 2 deletions.
Expand Up @@ -59,7 +59,15 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* {@link org.apache.gora.cassandra.store.CassandraStore} is the primary class
* responsible for directing Gora CRUD operations into Cassandra. We (delegate) rely
* heavily on {@ link org.apache.gora.cassandra.store.CassandraClient} for many operations
* such as initialization, creating and deleting schemas (Cassandra Keyspaces), etc.
*/
public class CassandraStore<K, T extends PersistentBase> extends DataStoreBase<K, T> {

/** Logging implementation */
public static final Logger LOG = LoggerFactory.getLogger(CassandraStore.class);

private CassandraClient<K, T> cassandraClient = new CassandraClient<K, T>();
Expand All @@ -77,10 +85,17 @@ public class CassandraStore<K, T extends PersistentBase> extends DataStoreBase<K
*/
private Map<K, T> buffer = Collections.synchronizedMap(new LinkedHashMap<K, T>());

/** The default constructor for CassandraStore */
public CassandraStore() throws Exception {
// this.cassandraClient.initialize();
}


/**
* Initialize is called when then the call to
* {@link org.apache.gora.store.DataStoreFactory#createDataStore(Class<D> dataStoreClass, Class<K> keyClass, Class<T> persistent, org.apache.hadoop.conf.Configuration conf)}
* is made. In this case, we merely delegate the store initialization to the
* {@link org.apache.gora.cassandra.store.CassandraClient#initialize(Class<K> keyClass, Class<T> persistentClass)}.
*/
public void initialize(Class<K> keyClass, Class<T> persistent, Properties properties) {
try {
super.initialize(keyClass, persistent, properties);
Expand Down Expand Up @@ -121,6 +136,12 @@ public void deleteSchema() {
this.cassandraClient.dropKeyspace();
}

/**
* When executing Gora Queries in Cassandra we query the Cassandra keyspace by families.
* When add sub/supercolumns, Gora keys are mapped to Cassandra partition keys only.
* This is because we follow the Cassandra logic where column family data is
* partitioned across nodes based on row Key.
*/
@Override
public Result<K, T> execute(Query<K, T> query) {

Expand Down Expand Up @@ -153,7 +174,12 @@ public Result<K, T> execute(Query<K, T> query) {

return cassandraResult;
}


/**
* When we add subcolumns, Gora keys are mapped to Cassandra partition keys only.
* This is because we follow the Cassandra logic where column family data is
* partitioned across nodes based on row Key.
*/
private void addSubColumns(String family, CassandraQuery<K, T> cassandraQuery,
CassandraResultSet cassandraResultSet) {
// select family columns that are included in the query
Expand Down Expand Up @@ -182,6 +208,11 @@ private void addSubColumns(String family, CassandraQuery<K, T> cassandraQuery,
}
}

/**
* When we add supercolumns, Gora keys are mapped to Cassandra partition keys only.
* This is because we follow the Cassandra logic where column family data is
* partitioned across nodes based on row Key.
*/
private void addSuperColumns(String family, CassandraQuery<K, T> cassandraQuery,
CassandraResultSet cassandraResultSet) {

Expand Down

0 comments on commit 87e64a5

Please sign in to comment.