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
DataStore
s.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, wait
close, createSchema, delete, deleteByQuery, deleteSchema, execute, flush, get, getPartitions, getSchemaName, newQuery, put, schemaExists
protected 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)
DataStore
initialize
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)
DataStore
setPersistentClass
in interface DataStore<K,T extends PersistentBase>
persistentClass
- class of persistent objectspublic Class<T> getPersistentClass()
DataStore
getPersistentClass
in interface DataStore<K,T extends PersistentBase>
public Class<K> getKeyClass()
DataStore
getKeyClass
in interface DataStore<K,T extends PersistentBase>
public void setKeyClass(Class<K> keyClass)
DataStore
setKeyClass
in interface DataStore<K,T extends PersistentBase>
keyClass
- the class of keyspublic K newKey()
DataStore
newKey
in interface DataStore<K,T extends PersistentBase>
public T newPersistent()
DataStore
newPersistent
in interface DataStore<K,T extends PersistentBase>
public void setBeanFactory(BeanFactory<K,T> beanFactory)
DataStore
BeanFactory
to use by the DataStore.setBeanFactory
in interface DataStore<K,T extends PersistentBase>
beanFactory
- the BeanFactory to usepublic BeanFactory<K,T> getBeanFactory()
DataStore
getBeanFactory
in interface DataStore<K,T extends PersistentBase>
public T get(K key)
DataStore
get
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.Configurable
public void setConf(org.apache.hadoop.conf.Configuration conf)
setConf
in interface org.apache.hadoop.conf.Configurable
protected org.apache.hadoop.conf.Configuration getOrCreateConf()
public void readFields(DataInput in)
readFields
in interface org.apache.hadoop.io.Writable
public void write(DataOutput out)
write
in interface org.apache.hadoop.io.Writable
public void truncateSchema()
DataStore
truncateSchema
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.