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

org.apache.gora.accumulo.store
Class AccumuloStore<K,T extends Persistent>

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

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


Field Summary
protected static String DEFAULT_MAPPING_FILE
           
protected static String INSTANCE_NAME_PROPERTY
           
protected static String MOCK_PROPERTY
           
protected static String PASSWORD_PROPERTY
           
protected static String USERNAME_PROPERTY
           
protected static String ZOOKEEPERS_NAME_PROPERTY
           
 
Fields inherited from class org.apache.gora.store.impl.DataStoreBase
autoCreateSchema, beanFactory, conf, datumReader, datumWriter, fieldMap, keyClass, persistentClass, properties, schema
 
Constructor Summary
AccumuloStore()
           
 
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()
          Forces the write caches to be flushed.
 K fromBytes(Class<K> clazz, byte[] val)
           
static
<K> K
fromBytes(Encoder encoder, Class<K> clazz, byte[] val)
           
static Object fromBytes(Encoder encoder, org.apache.avro.Schema schema, byte[] data)
           
 Object fromBytes(org.apache.avro.Schema schema, byte[] data)
           
 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
 void initialize(Class<K> keyClass, Class<T> persistentClass, Properties properties)
          Initializes this DataStore.
 Query<K,T> newQuery()
          Constructs and returns a new Query.
 org.apache.accumulo.core.data.ByteSequence populate(Iterator<Map.Entry<org.apache.accumulo.core.data.Key,org.apache.accumulo.core.data.Value>> iter, T persistent)
           
 void put(K key, T val)
          Inserts the persistent object with the given key.
protected  AccumuloMapping readMapping(String filename)
           
 boolean schemaExists()
          Returns whether the schema that holds the data exists in the datastore.
static byte[] toBytes(Encoder encoder, Object o)
           
 byte[] toBytes(Object o)
           
 
Methods inherited from class org.apache.gora.store.impl.DataStoreBase
equals, get, getBeanFactory, getConf, getFieldsToQuery, getKeyClass, getOrCreateConf, getPersistentClass, getSchemaName, 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

MOCK_PROPERTY

protected static final String MOCK_PROPERTY
See Also:
Constant Field Values

INSTANCE_NAME_PROPERTY

protected static final String INSTANCE_NAME_PROPERTY
See Also:
Constant Field Values

ZOOKEEPERS_NAME_PROPERTY

protected static final String ZOOKEEPERS_NAME_PROPERTY
See Also:
Constant Field Values

USERNAME_PROPERTY

protected static final String USERNAME_PROPERTY
See Also:
Constant Field Values

PASSWORD_PROPERTY

protected static final String PASSWORD_PROPERTY
See Also:
Constant Field Values

DEFAULT_MAPPING_FILE

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

AccumuloStore

public AccumuloStore()
Method Detail

fromBytes

public Object fromBytes(org.apache.avro.Schema schema,
                        byte[] data)

fromBytes

public static Object fromBytes(Encoder encoder,
                               org.apache.avro.Schema schema,
                               byte[] data)

fromBytes

public K fromBytes(Class<K> clazz,
                   byte[] val)

fromBytes

public static <K> K fromBytes(Encoder encoder,
                              Class<K> clazz,
                              byte[] val)

toBytes

public byte[] toBytes(Object o)

toBytes

public static byte[] toBytes(Encoder encoder,
                             Object o)

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

readMapping

protected AccumuloMapping readMapping(String filename)
                               throws IOException
Throws:
IOException

getSchemaName

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

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.

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

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

populate

public org.apache.accumulo.core.data.ByteSequence populate(Iterator<Map.Entry<org.apache.accumulo.core.data.Key,org.apache.accumulo.core.data.Value>> iter,
                                                           T persistent)
                                                    throws IOException
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.

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 val)
         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.

Throws:
IOException

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

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

newQuery

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

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.

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

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.

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.

Throws:
IOException


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