K - the class of keys in the datastoreT - the class of persistent objects in the datastorepublic interface DataStore<K,T extends Persistent>
DataStoreFactory.
DataStores implementations should be thread safe.
Note: Results of updates (put(Object, Persistent),
delete(Object) and deleteByQuery(Query) operations) are
guaranteed to be visible to subsequent get / execute operations ONLY
after a subsequent call to flush(). Additionally, exception
handling is largely DataStore specific and is not largely dealt
with from within this interface.
| Modifier and Type | Method and Description |
|---|---|
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.
|
T |
get(K key)
Returns the object corresponding to the given key fetching all the fields.
|
T |
get(K key,
String[] fields)
Returns the object corresponding to the given key.
|
BeanFactory<K,T> |
getBeanFactory()
Returns the BeanFactory used by the DataStore
|
Class<K> |
getKeyClass()
Returns the class of the keys
|
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. |
Class<T> |
getPersistentClass()
Returns the class of the persistent objects
|
String |
getSchemaName()
Returns the schema name given to this DataStore
|
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.
|
Query<K,T> |
newQuery()
Constructs and returns a new Query.
|
void |
put(K key,
T obj)
Inserts the persistent object with the given key.
|
boolean |
schemaExists()
Returns whether the schema that holds the data exists in the datastore.
|
void |
setBeanFactory(BeanFactory<K,T> beanFactory)
Sets the
BeanFactory to use by the DataStore. |
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 initialize(Class<K> keyClass, Class<T> persistentClass, Properties properties)
keyClass - the class of the keyspersistentClass - the class of the persistent objectsproperties - extra metadataIOExceptionvoid setKeyClass(Class<K> keyClass)
keyClass - the class of keysvoid setPersistentClass(Class<T> persistentClass)
persistentClass - class of persistent objectsClass<T> getPersistentClass()
String getSchemaName()
void createSchema()
IOExceptionvoid deleteSchema()
IOExceptionvoid truncateSchema()
IOExceptionboolean schemaExists()
IOExceptionK newKey()
IOExceptionT newPersistent()
IOExceptionT get(K key)
key - the key of the objectIOExceptionT get(K key, String[] fields)
key - the key of the objectfields - the fields required in the object. Pass null, to retrieve all fieldsIOExceptionvoid put(K key, T obj)
IOExceptionboolean delete(K key)
key - the key of the objectIOExceptionlong deleteByQuery(Query<K,T> query)
query - matching records to this query will be deletedIOExceptionResult<K,T> execute(Query<K,T> query)
query - the query to execute.Result object.IOExceptionList<PartitionQuery<K,T>> getPartitions(Query<K,T> query) throws IOException
PartitionQuerys,
which will execute on local data.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)IOExceptionvoid flush()
IOExceptionvoid setBeanFactory(BeanFactory<K,T> beanFactory)
BeanFactory to use by the DataStore.beanFactory - the BeanFactory to useBeanFactory<K,T> getBeanFactory()
void close()
IOExceptionCopyright © 2010-2014 The Apache Software Foundation. All Rights Reserved.