public abstract class DataStoreBase<K,T extends PersistentBase> extends Object implements DataStore<K,T>, org.apache.hadoop.conf.Configurable, org.apache.hadoop.io.Writable, Closeable
DataStores.| Modifier and Type | Field and Description |
|---|---|
protected boolean |
autoCreateSchema |
protected BeanFactory<K,T> |
beanFactory |
protected org.apache.hadoop.conf.Configuration |
conf |
protected org.apache.avro.specific.SpecificDatumReader<T> |
datumReader |
protected org.apache.avro.specific.SpecificDatumWriter<T> |
datumWriter |
protected Map<String,org.apache.avro.Schema.Field> |
fieldMap
A map of field names to Field objects containing schema's fields
|
protected Class<K> |
keyClass |
static org.slf4j.Logger |
LOG |
protected Class<T> |
persistentClass |
protected Properties |
properties |
protected org.apache.avro.Schema |
schema
The schema of the persistent class
|
| Constructor and Description |
|---|
DataStoreBase() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object obj) |
T |
get(K key)
Returns the object corresponding to the given key fetching all the fields.
|
BeanFactory<K,T> |
getBeanFactory()
Returns the BeanFactory used by the DataStore
|
org.apache.hadoop.conf.Configuration |
getConf() |
protected String[] |
getFields() |
protected String[] |
getFieldsToQuery(String[] fields)
Checks whether the fields argument is null, and if so
returns all the fields of the Persistent object, else returns the
argument.
|
Class<K> |
getKeyClass()
Returns the class of the keys
|
protected org.apache.hadoop.conf.Configuration |
getOrCreateConf() |
Class<T> |
getPersistentClass()
Returns the class of the persistent objects
|
protected String |
getSchemaName(String mappingSchemaName,
Class<?> persistentClass)
Returns the name of the schema to use for the persistent class.
|
void |
initialize(Class<K> keyClass,
Class<T> persistentClass,
Properties properties)
Initializes this DataStore.
|
K |
newKey()
Returns a new instance of the key object.
|
T |
newPersistent()
Returns a new instance of the managed persistent object.
|
void |
readFields(DataInput in) |
void |
setBeanFactory(BeanFactory<K,T> beanFactory)
Sets the
BeanFactory to use by the DataStore. |
void |
setConf(org.apache.hadoop.conf.Configuration conf) |
void |
setKeyClass(Class<K> keyClass)
Sets the class of the keys
|
void |
setPersistentClass(Class<T> persistentClass)
Sets the class of the persistent objects
|
void |
truncateSchema()
Deletes all the data associated with the schema, but keeps the
schema (table or similar) intact.
|
void |
write(DataOutput out) |
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitclose, createSchema, delete, deleteByQuery, deleteSchema, execute, flush, get, getPartitions, getSchemaName, newQuery, put, schemaExistsprotected BeanFactory<K,T extends PersistentBase> beanFactory
protected Class<T extends PersistentBase> persistentClass
protected org.apache.avro.Schema schema
protected Map<String,org.apache.avro.Schema.Field> fieldMap
protected org.apache.hadoop.conf.Configuration conf
protected boolean autoCreateSchema
protected Properties properties
protected org.apache.avro.specific.SpecificDatumReader<T extends PersistentBase> datumReader
protected org.apache.avro.specific.SpecificDatumWriter<T extends PersistentBase> datumWriter
public static final org.slf4j.Logger LOG
public void initialize(Class<K> keyClass, Class<T> persistentClass, Properties properties)
DataStoreinitialize in interface DataStore<K,T extends PersistentBase>keyClass - the class of the keyspersistentClass - the class of the persistent objectsproperties - extra metadatapublic void setPersistentClass(Class<T> persistentClass)
DataStoresetPersistentClass in interface DataStore<K,T extends PersistentBase>persistentClass - class of persistent objectspublic Class<T> getPersistentClass()
DataStoregetPersistentClass in interface DataStore<K,T extends PersistentBase>public Class<K> getKeyClass()
DataStoregetKeyClass in interface DataStore<K,T extends PersistentBase>public void setKeyClass(Class<K> keyClass)
DataStoresetKeyClass in interface DataStore<K,T extends PersistentBase>keyClass - the class of keyspublic K newKey()
DataStorenewKey in interface DataStore<K,T extends PersistentBase>public T newPersistent()
DataStorenewPersistent in interface DataStore<K,T extends PersistentBase>public void setBeanFactory(BeanFactory<K,T> beanFactory)
DataStoreBeanFactory to use by the DataStore.setBeanFactory in interface DataStore<K,T extends PersistentBase>beanFactory - the BeanFactory to usepublic BeanFactory<K,T> getBeanFactory()
DataStoregetBeanFactory in interface DataStore<K,T extends PersistentBase>public T get(K key)
DataStoreget in interface DataStore<K,T extends PersistentBase>key - the key of the objectprotected String[] getFieldsToQuery(String[] fields)
protected String[] getFields()
public org.apache.hadoop.conf.Configuration getConf()
getConf in interface org.apache.hadoop.conf.Configurablepublic void setConf(org.apache.hadoop.conf.Configuration conf)
setConf in interface org.apache.hadoop.conf.Configurableprotected org.apache.hadoop.conf.Configuration getOrCreateConf()
public void readFields(DataInput in)
readFields in interface org.apache.hadoop.io.Writablepublic void write(DataOutput out)
write in interface org.apache.hadoop.io.Writablepublic void truncateSchema()
DataStoretruncateSchema in interface DataStore<K,T extends PersistentBase>protected String getSchemaName(String mappingSchemaName, Class<?> persistentClass)
Configuration is used. If null,
the schema name in the defined properties is returned. If null then
the provided mappingSchemaName is returned. If this is null too,
the class name, without the package, of the persistent class is returned.mappingSchemaName - the name of the schema as read from the mapping filepersistentClass - persistent classCopyright © 2010-2014 The Apache Software Foundation. All Rights Reserved.