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

org.apache.gora.hbase.store
Class HBaseStore<K,T extends Persistent>

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

public class HBaseStore<K,T extends Persistent>
extends DataStoreBase<K,T>
implements org.apache.hadoop.conf.Configurable

DataStore for HBase. Thread safe.


Field Summary
static String DEFAULT_MAPPING_FILE
           
static org.apache.commons.logging.Log log
           
static String PARSE_MAPPING_FILE_KEY
           
 
Fields inherited from class org.apache.gora.store.impl.DataStoreBase
beanFactory, datumReader, datumWriter, fieldMap, keyClass, persistentClass, properties, schema
 
Constructor Summary
HBaseStore()
           
 
Method Summary
 void close()
          Close the DataStore.
 org.apache.hadoop.hbase.client.ResultScanner createScanner(Query<K,T> query)
           
 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.
 void delete(T obj)
           
 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()
          Forces the write caches to be flushed.
 T get(K key, String[] fields)
          Returns the object corresponding to the given key.
 org.apache.hadoop.conf.Configuration getConf()
           
 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
 void initialize(Class<K> keyClass, Class<T> persistentClass, Properties properties)
          Initializes this DataStore.
 T newInstance(org.apache.hadoop.hbase.client.Result result, String[] fields)
           
 Query<K,T> newQuery()
          Constructs and returns a new Query.
 void put(K key, T persistent)
          Inserts the persistent object with the given key.
 boolean schemaExists()
          Returns whether the schema that holds the data exists in the datastore.
 void setConf(org.apache.hadoop.conf.Configuration conf)
           
 
Methods inherited from class org.apache.gora.store.impl.DataStoreBase
equals, get, getBeanFactory, getFieldsToQuery, getKeyClass, getOrCreateConf, getPersistentClass, getSchemaName, newKey, newPersistent, readFields, setBeanFactory, 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.apache.commons.logging.Log log

PARSE_MAPPING_FILE_KEY

public static final String PARSE_MAPPING_FILE_KEY
See Also:
Constant Field Values

DEFAULT_MAPPING_FILE

public static final String DEFAULT_MAPPING_FILE
See Also:
Constant Field Values
Constructor Detail

HBaseStore

public HBaseStore()
Method Detail

initialize

public void initialize(Class<K> keyClass,
                       Class<T> persistentClass,
                       Properties properties)
                throws IOException
Description copied from interface: DataStore
Initializes this DataStore.

Specified by:
initialize in interface DataStore<K,T extends Persistent>
Overrides:
initialize in class DataStoreBase<K,T extends Persistent>
Parameters:
keyClass - the class of the keys
persistentClass - the class of the persistent objects
properties - extra metadata
Throws:
IOException

getSchemaName

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

Specified by:
getSchemaName in interface DataStore<K,T extends Persistent>
Returns:
schema name

createSchema

public void createSchema()
                  throws IOException
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.

Specified by:
createSchema in interface DataStore<K,T extends Persistent>
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.

Specified by:
deleteSchema in interface DataStore<K,T extends Persistent>
Throws:
IOException

schemaExists

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

Specified by:
schemaExists in interface DataStore<K,T extends Persistent>
Returns:
whether schema exists
Throws:
IOException

get

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

Specified by:
get in interface DataStore<K,T extends Persistent>
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

put

public void put(K key,
                T persistent)
         throws IOException
Description copied from interface: DataStore
Inserts the persistent object with the given key. If an object with the same key already exists it will silently be replaced. See also the note on visibility.

Specified by:
put in interface DataStore<K,T extends Persistent>
Throws:
IOException

delete

public void delete(T obj)

delete

public boolean delete(K key)
               throws IOException
Deletes the object with the given key.

Specified by:
delete in interface DataStore<K,T extends Persistent>
Parameters:
key - the key of the object
Returns:
always true
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.

Specified by:
deleteByQuery in interface DataStore<K,T extends Persistent>
Parameters:
query - matching records to this query will be deleted
Returns:
number of deleted records
Throws:
IOException

flush

public void flush()
           throws IOException
Description copied from interface: DataStore
Forces the write caches to be flushed. DataStore implementations may optimize their writing by deferring the actual put / delete operations until this moment. See also the note on visibility.

Specified by:
flush in interface DataStore<K,T extends Persistent>
Throws:
IOException

newQuery

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

Specified by:
newQuery in interface DataStore<K,T extends Persistent>
Returns:
a new Query.

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.

Specified by:
getPartitions in interface DataStore<K,T extends Persistent>
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

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.

Specified by:
execute in interface DataStore<K,T extends Persistent>
Parameters:
query - the query to execute.
Returns:
the results as a Result object.
Throws:
IOException

createScanner

public org.apache.hadoop.hbase.client.ResultScanner createScanner(Query<K,T> query)
                                                           throws IOException
Throws:
IOException

newInstance

public T newInstance(org.apache.hadoop.hbase.client.Result result,
                     String[] fields)
                                 throws IOException
Throws:
IOException

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.

Specified by:
close in interface Closeable
Specified by:
close in interface DataStore<K,T extends Persistent>
Throws:
IOException

getConf

public org.apache.hadoop.conf.Configuration getConf()
Specified by:
getConf in interface DataStore<K,T extends Persistent>
Specified by:
getConf in interface org.apache.hadoop.conf.Configurable
Overrides:
getConf in class DataStoreBase<K,T extends Persistent>

setConf

public void setConf(org.apache.hadoop.conf.Configuration conf)
Specified by:
setConf in interface DataStore<K,T extends Persistent>
Specified by:
setConf in interface org.apache.hadoop.conf.Configurable
Overrides:
setConf in class DataStoreBase<K,T extends Persistent>


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