public abstract class AbstractIndex<ST,T extends ST,PK,V,S extends Store<ST,PK,S>> extends Object implements OrderedIndex<ST,T,PK,V,S>
| Modifier and Type | Class and Description |
|---|---|
protected class |
AbstractIndex.UpdateEntry |
Index.Type| Modifier and Type | Field and Description |
|---|---|
protected Runnable |
applyUpdatesTask |
protected Comparator<V> |
comparator |
protected AtomicBoolean |
isCorrupt |
protected boolean |
ordered |
protected AbstractStore<ST,PK,S> |
store |
protected Index.Type |
type |
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractIndex(Predicate<ST,S> predicate,
Extractor<T,V,S> extractor,
Index.Type type,
boolean ordered,
Comparator<V> comparator,
AbstractStore<ST,PK,S> store) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
applyUpdate(Store.Handle<ST,PK,S> changed,
boolean isNew)
This method is invoked within write lock, no need
to acquire own lock.
|
protected void |
checkCorrupt() |
void |
cleanup()
Removes invalid handles from index store.
|
Index<ST,T,PK,V,S> |
createProxy() |
Iterable<T> |
find(V from,
V to,
boolean fromInclusive,
boolean toInclusive)
Finds objects by index range.
|
Comparator<V> |
getComparator() |
protected abstract ExecutorService |
getExecutorService() |
Extractor<T,V,S> |
getExtractor() |
int |
getGranularity() |
protected abstract Map<V,Collection<Store.Handle<ST,PK,S>>> |
getIndexMultiStore() |
protected abstract Map<V,Store.Handle<ST,PK,S>> |
getIndexUniqueStore() |
protected abstract Collection<AbstractIndex.UpdateEntry> |
getPendingUpdates() |
Predicate<ST,S> |
getPredicate() |
S |
getStore() |
protected abstract void |
handleAsynchException(Exception e)
Handles exceptions thrown in asynchronous applyUpdates().
|
boolean |
isOrdered() |
boolean |
isUnique() |
Iterator<T> |
iterator() |
protected abstract Lock |
readLock() |
String |
toString() |
void |
update(Store.Handle<ST,PK,S> changed,
boolean isNew)
Updates index
|
abstract void |
upgrade(Index.Type type,
boolean ordered,
Comparator<V> comparator)
Upgrades index type.
|
protected abstract Lock |
writeLock() |
protected Index.Type type
protected boolean ordered
protected Comparator<V> comparator
protected AtomicBoolean isCorrupt
protected Runnable applyUpdatesTask
protected AbstractIndex(Predicate<ST,S> predicate, Extractor<T,V,S> extractor, Index.Type type, boolean ordered, Comparator<V> comparator, AbstractStore<ST,PK,S> store)
protected abstract Map<V,Store.Handle<ST,PK,S>> getIndexUniqueStore()
protected abstract Map<V,Collection<Store.Handle<ST,PK,S>>> getIndexMultiStore()
public abstract void upgrade(Index.Type type, boolean ordered, Comparator<V> comparator)
type - Asynchronous and lazy indices can be
upgraded to synchronous. All index types can be upgraded
to unique if current index data does not contain duplicates.ordered - unordered index can be upgraded to ordered.public Predicate<ST,S> getPredicate()
public Extractor<T,V,S> getExtractor()
public boolean isUnique()
public boolean isOrdered()
public Comparator<V> getComparator()
protected abstract Collection<AbstractIndex.UpdateEntry> getPendingUpdates()
public void update(Store.Handle<ST,PK,S> changed, boolean isNew)
changed - Changed/added handle.isNew - If true, then handle was added, updated otherwise.protected abstract ExecutorService getExecutorService()
protected void checkCorrupt()
protected void applyUpdate(Store.Handle<ST,PK,S> changed, boolean isNew)
changed - public int getGranularity()
protected abstract void handleAsynchException(Exception e)
e - public void cleanup()
public Iterable<T> find(V from, V to, boolean fromInclusive, boolean toInclusive)
OrderedIndexpublic Index<ST,T,PK,V,S> createProxy()