T - PK - public abstract class DeputyStore<T,PK,S extends Store<T,PK,S>> extends AbstractStore<T,PK,S>
AbstractStore.ExtractorTask<V>, AbstractStore.IndexizationTask<V>, AbstractStore.QueryCallable<V>, AbstractStore.QueryItemCallable<V>, AbstractStore.QueryMultipleCallable<V>, AbstractStore.RemoveTask, AbstractStore.SelectorTask, AbstractStore.UpdateCallable, AbstractStore.ValueSelectorTask<V>| Modifier and Type | Field and Description |
|---|---|
protected AbstractStore<T,PK,S> |
master |
| Constructor and Description |
|---|
DeputyStore(AbstractStore<T,PK,S> master,
ReadWriteLock masterLock)
Creates deputy store.
|
| Modifier and Type | Method and Description |
|---|---|
<V,ST extends T> |
addIndex(Predicate<T,S> predicate,
Extractor<ST,V,S> extractor,
Index.Type type,
boolean ordered,
Comparator<V> comparator)
Adds index to the store to speed-up extraction operations.
|
void |
clear()
Removes all entries from the store.
|
protected Map<S,Map<Extractor<T,? super PK,S>,? super PK>> |
createCache() |
protected Store.Handle<T,PK,S> |
createHandle(T obj,
PK primaryKey,
Map<S,Map<Extractor<T,? super PK,S>,? super PK>> cache,
Predicate<T,S>[] validators)
Creates handle.
|
protected <V,ST extends T> |
createIndex(Predicate<T,S> predicate,
Extractor<ST,V,S> extractor,
Index.Type type,
boolean ordered,
Comparator<V> comparator) |
protected Collection<Store.Handle<T,PK,S>> |
createIndexCollection(boolean unique,
boolean ordered,
Comparator<T> comparator)
Creates collection for index entries
|
protected ReadWriteLock |
createMasterLock() |
S |
createView(Predicate<T,S> selector,
Store.ViewType viewType)
Creates a view - a store which sees only objects matching the given selector.
|
boolean |
equals(Object obj) |
Iterable<T> |
get(Predicate<T,S> selector)
Retrieves objects matching the predicate.
|
<V> Iterable<V> |
get(Predicate<T,S> selector,
Extractor<T,V,S> extractor,
boolean ordered,
Comparator<V> comparator)
Retrieves values from objects matching the predicate.
|
Iterable<T> |
getAll()
Retrieves all objects from the store.
|
T |
getByPrimaryKey(PK primaryKey)
Retrieves object with given primary key.
|
protected ExecutorService |
getExecutorService() |
protected Collection<AbstractIndex<T,? extends T,PK,?,S>> |
getIndices() |
protected AbstractStore<T,PK,S> |
getMaster() |
protected Collection<Store.Handle<T,PK,S>> |
getNoPkStore()
Store for the mode without primary key or pkStore values collection.
|
protected Map<PK,Store.Handle<T,PK,S>> |
getPkStore() |
Extractor<T,PK,S> |
getPrimaryKeyExtractor()
If primary key is set, then the store shall use equals on the
value returned from the primaryKeyExtractor
instead of equals on the object to compare objects for removal and update (put).
|
int |
hashCode() |
Iterator<T> |
iterator() |
protected void |
onRemoved(int removed)
Invoked when some handles have been removed.
|
Store.Handle<T,PK,S> |
put(T obj) |
int |
query(Predicate<T,S> selector,
Store.QueryTask<T,PK,S> query)
Processes objects matching the predicate.
|
int |
queryAll(Store.QueryTask<T,PK,S> query)
Processes all objects in the store.
|
Lock |
readLock() |
int |
remove(Predicate<T,S> selector)
Removes objects matching the predicate.
|
boolean |
remove(T obj)
Removes specified object from the store.
|
boolean |
removeByPrimaryKey(PK primaryKey)
Removes object by primary key.
|
String |
toString() |
int |
update(Predicate<T,S> selector,
Store.UpdateTask<T,PK,S> updater)
Updates objects matching the predicate.
|
Lock |
writeLock() |
createDeputy, createHandle, createLiveView, getHandles, getMultiple, put, query, queryMultiple, updateIndicesclone, finalize, getClass, notify, notifyAll, wait, wait, waitcreateUnmodifiableFacadepublic DeputyStore(AbstractStore<T,PK,S> master, ReadWriteLock masterLock)
master - Master store.masterLock - Lock which delegates to master lock and can be used
from multiple threads/processes, i.e. the lock owner is not the current
thread but the master store.public Iterable<T> getAll()
Storepublic T getByPrimaryKey(PK primaryKey)
Storepublic Iterable<T> get(Predicate<T,S> selector)
Storepublic <V> Iterable<V> get(Predicate<T,S> selector, Extractor<T,V,S> extractor, boolean ordered, Comparator<V> comparator)
Storeget in interface Store<T,PK,S extends Store<T,PK,S>>get in class AbstractStore<T,PK,S extends Store<T,PK,S>>selector - Object selector.extractor - Value extractor. If null, then object itself is returned.ordered - If true, then returned result is ordered by comparator or by natural order if
comparator is null.comparator - Comparator to use for ordering.public void clear()
Storepublic boolean remove(T obj)
Storepublic boolean removeByPrimaryKey(PK primaryKey)
Storepublic int remove(Predicate<T,S> selector)
Storepublic int update(Predicate<T,S> selector, Store.UpdateTask<T,PK,S> updater)
Storepublic <V,ST extends T> Index<T,ST,PK,V,S> addIndex(Predicate<T,S> predicate, Extractor<ST,V,S> extractor, Index.Type type, boolean ordered, Comparator<V> comparator)
StoreaddIndex in interface Store<T,PK,S extends Store<T,PK,S>>addIndex in class AbstractStore<T,PK,S extends Store<T,PK,S>>V - Value type extracted by extractor for ordering.ST - Type of index elements, which can be a sub-type of store element type.
index creation parameters.predicate - Only store items matching the predicate are indexed.extractor - Extractor of the index key.ordered - If true index is ordered.comparator - Comparator to use for ordering. If null, then natural order is used.public Extractor<T,PK,S> getPrimaryKeyExtractor()
Storepublic int queryAll(Store.QueryTask<T,PK,S> query)
Storepublic int query(Predicate<T,S> selector, Store.QueryTask<T,PK,S> query)
Storepublic S createView(Predicate<T,S> selector, Store.ViewType viewType)
Storeprotected Map<PK,Store.Handle<T,PK,S>> getPkStore()
getPkStore in class AbstractStore<T,PK,S extends Store<T,PK,S>>protected Collection<Store.Handle<T,PK,S>> getNoPkStore()
AbstractStoregetNoPkStore in class AbstractStore<T,PK,S extends Store<T,PK,S>>protected ExecutorService getExecutorService()
getExecutorService in class AbstractStore<T,PK,S extends Store<T,PK,S>>protected Store.Handle<T,PK,S> createHandle(T obj, PK primaryKey, Map<S,Map<Extractor<T,? super PK,S>,? super PK>> cache, Predicate<T,S>[] validators)
AbstractStorecreateHandle in class AbstractStore<T,PK,S extends Store<T,PK,S>>protected Collection<Store.Handle<T,PK,S>> createIndexCollection(boolean unique, boolean ordered, Comparator<T> comparator)
AbstractStorecreateIndexCollection in class AbstractStore<T,PK,S extends Store<T,PK,S>>unique - Collection should be unique (set)ordered - Collection should be ordered by the comparator or by natural order.protected Map<S,Map<Extractor<T,? super PK,S>,? super PK>> createCache()
createCache in class AbstractStore<T,PK,S extends Store<T,PK,S>>protected ReadWriteLock createMasterLock()
createMasterLock in class AbstractStore<T,PK,S extends Store<T,PK,S>>protected void onRemoved(int removed)
AbstractStoreprotected Collection<AbstractIndex<T,? extends T,PK,?,S>> getIndices()
getIndices in class AbstractStore<T,PK,S extends Store<T,PK,S>>protected <V,ST extends T> AbstractIndex<T,ST,PK,V,S> createIndex(Predicate<T,S> predicate, Extractor<ST,V,S> extractor, Index.Type type, boolean ordered, Comparator<V> comparator)
createIndex in class AbstractStore<T,PK,S extends Store<T,PK,S>>protected AbstractStore<T,PK,S> getMaster()