This project has retired. For details please refer to its Attic page.
CassandraStore (Apache Gora 0.2 API)

org.apache.gora.cassandra.store
Class CassandraStore<K,T extends Persistent>

java.lang.Object
  extended by org.apache.gora.store.impl.DataStoreBase<K,T>
      extended by org.apache.gora.cassandra.store.CassandraStore<K,T>
All Implemented Interfaces:
Closeable, DataStore<K,T>, org.apache.hadoop.conf.Configurable, org.apache.hadoop.io.Writable

public class CassandraStore<K,T extends Persistent>
extends DataStoreBase<K,T>


Field Summary
static org.slf4j.Logger LOG
           
 
Fields inherited from class org.apache.gora.store.impl.DataStoreBase
autoCreateSchema, beanFactory, conf, datumReader, datumWriter, fieldMap, keyClass, persistentClass, properties, schema
 
Constructor Summary
CassandraStore()
           
 
Method Summary
 void close()
          Close the DataStore.
 void createSchema()
          Creates the optional schema or table (or similar) in the datastore to hold the objects.
 boolean delete(K key)
          Deletes the object with the given key
 long deleteByQuery(Query<K,T> query)
          Deletes all the objects matching the query.
 void deleteSchema()
          Deletes the underlying schema or table (or similar) in the datastore that holds the objects.
 Result<K,T> execute(Query<K,T> query)
          Executes the given query and returns the results.
 void flush()
          Flush the buffer.
 T get(K key, String[] fields)
          Returns the object corresponding to the given key.
 List<PartitionQuery<K,T>> getPartitions(Query<K,T> query)
          Partitions the given query and returns a list of PartitionQuerys, which will execute on local data.
 String getSchemaName()
          Returns the schema name given to this DataStore
 Query<K,T> newQuery()
          Constructs and returns a new Query.
 void put(K key, T value)
          Duplicate instance to keep all the objects in memory till flushing.
 boolean schemaExists()
          Returns whether the schema that holds the data exists in the datastore.
 
Methods inherited from class org.apache.gora.store.impl.DataStoreBase
equals, get, getBeanFactory, getConf, getFieldsToQuery, getKeyClass, getOrCreateConf, getPersistentClass, getSchemaName, initialize, newKey, newPersistent, readFields, setBeanFactory, setConf, setKeyClass, setPersistentClass, truncateSchema, write
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

public static final org.slf4j.Logger LOG
Constructor Detail

CassandraStore

public CassandraStore()
               throws Exception
Throws:
Exception
Method Detail

close

public void close()
           throws IOException
Description copied from interface: DataStore
Close the DataStore. This should release any resources held by the implementation, so that the instance is ready for GC. All other DataStore methods cannot be used after this method was called. Subsequent calls of this method are ignored.

Throws:
IOException

createSchema

public void createSchema()
Description copied from interface: DataStore
Creates the optional schema or table (or similar) in the datastore to hold the objects. If the schema is already created previously, or the underlying data model does not support or need this operation, the operation is ignored.


delete

public boolean delete(K key)
               throws IOException
Description copied from interface: DataStore
Deletes the object with the given key

Parameters:
key - the key of the object
Returns:
whether the object was successfully deleted
Throws:
IOException

deleteByQuery

public long deleteByQuery(Query<K,T> query)
                   throws IOException
Description copied from interface: DataStore
Deletes all the objects matching the query. See also the note on visibility.

Parameters:
query - matching records to this query will be deleted
Returns:
number of deleted records
Throws:
IOException

deleteSchema

public void deleteSchema()
                  throws IOException
Description copied from interface: DataStore
Deletes the underlying schema or table (or similar) in the datastore that holds the objects. This also deletes all the data associated with the schema.

Throws:
IOException

execute

public Result<K,T> execute(Query<K,T> query)
                                       throws IOException
Description copied from interface: DataStore
Executes the given query and returns the results.

Parameters:
query - the query to execute.
Returns:
the results as a Result object.
Throws:
IOException

flush

public void flush()
           throws IOException
Flush the buffer. Write the buffered rows.

Throws:
IOException
See Also:
DataStore.flush()

get

public T get(K key,
             String[] fields)
                         throws IOException
Description copied from interface: DataStore
Returns the object corresponding to the given key.

Parameters:
key - the key of the object
fields - the fields required in the object. Pass null, to retrieve all fields
Returns:
the Object corresponding to the key or null if it cannot be found
Throws:
IOException

getPartitions

public List<PartitionQuery<K,T>> getPartitions(Query<K,T> query)
                                                           throws IOException
Description copied from interface: DataStore
Partitions the given query and returns a list of PartitionQuerys, which will execute on local data.

Parameters:
query - the base query to create the partitions for. If the query is null, then the data store returns the partitions for the default query (returning every object)
Returns:
a List of PartitionQuery's
Throws:
IOException

getSchemaName

public String getSchemaName()
Description copied from interface: DataStore
Returns the schema name given to this DataStore

Returns:
schema name

newQuery

public Query<K,T> newQuery()
Description copied from interface: DataStore
Constructs and returns a new Query.

Returns:
a new Query.

put

public void put(K key,
                T value)
         throws IOException
Duplicate instance to keep all the objects in memory till flushing.

Throws:
IOException
See Also:
DataStore.put(java.lang.Object, org.apache.gora.persistency.Persistent)

schemaExists

public boolean schemaExists()
                     throws IOException
Description copied from interface: DataStore
Returns whether the schema that holds the data exists in the datastore.

Returns:
whether schema exists
Throws:
IOException


Copyright © 2010-2013 The Apache Software Foundation. All Rights Reserved.