Class InvertedRadixTreeIndex<A extends CharSequence,O>
- java.lang.Object
-
- com.googlecode.cqengine.index.support.AbstractAttributeIndex<A,O>
-
- com.googlecode.cqengine.index.radixinverted.InvertedRadixTreeIndex<A,O>
-
- All Implemented Interfaces:
ModificationListener<O>,AttributeIndex<A,O>,Index<O>,OnHeapTypeIndex
public class InvertedRadixTreeIndex<A extends CharSequence,O> extends AbstractAttributeIndex<A,O> implements OnHeapTypeIndex
An index backed by aConcurrentInvertedRadixTree. Supports query types:- Author:
- Niall Gallagher
-
-
Field Summary
-
Fields inherited from class com.googlecode.cqengine.index.support.AbstractAttributeIndex
attribute, supportedQueries
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedInvertedRadixTreeIndex(Attribute<O,A> attribute)Package-private constructor, used by static factory methods.protectedInvertedRadixTreeIndex(Attribute<O,A> attribute, com.googlecode.concurrenttrees.radix.node.NodeFactory nodeFactory)Package-private constructor, used by static factory methods.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaddAll(ObjectSet<O> objectSet, QueryOptions queryOptions)Notifies the listener that the specified objects are being added to the collection, and so it can take action and update its internal data structures.voidclear(QueryOptions queryOptions)Notifies the listener that all objects have been removed from the collection, and so it can take action and update its internal data structures.StoredResultSet<O>createValueSet()voiddestroy(QueryOptions queryOptions)This is a no-op for this type of index.Index<O>getEffectiveIndex()Returns the effective index, which Persistence objects will use to determine the identity of the index making persistence requests.voidinit(ObjectStore<O> objectStore, QueryOptions queryOptions)Notifies the listener that the given ObjectStore has just been created.booleanisMutable()Indicates if objects can be added to or removed from the index after the index has been built.booleanisQuantized()Indicates if the index is quantized, using aQuantizer.static <A extends CharSequence,O>
InvertedRadixTreeIndex<A,O>onAttribute(Attribute<O,A> attribute)Creates a newInvertedRadixTreeIndexon the specified attribute.static <A extends CharSequence,O>
InvertedRadixTreeIndex<A,O>onAttributeUsingNodeFactory(Attribute<O,A> attribute, com.googlecode.concurrenttrees.radix.node.NodeFactory nodeFactory)Creates a newInvertedRadixTreeIndexon the specified attribute.booleanremoveAll(ObjectSet<O> objectSet, QueryOptions queryOptions)Notifies the listener that the specified objects are being removed from the collection, and so it can take action and update its internal data structures.ResultSet<O>retrieve(Query<O> query, QueryOptions queryOptions)Returns aResultSetwhich when iterated will return objects from the index matching the query supplied.protected ResultSet<O>retrieveEqual(Equal<O,A> equal, QueryOptions queryOptions, com.googlecode.concurrenttrees.radixinverted.InvertedRadixTree<StoredResultSet<O>> tree)protected ResultSet<O>retrieveIn(In<O,A> in, QueryOptions queryOptions, com.googlecode.concurrenttrees.radixinverted.InvertedRadixTree<StoredResultSet<O>> tree)-
Methods inherited from class com.googlecode.cqengine.index.support.AbstractAttributeIndex
equals, getAttribute, hashCode, supportsQuery
-
-
-
-
Method Detail
-
isMutable
public boolean isMutable()
Description copied from interface:IndexIndicates if objects can be added to or removed from the index after the index has been built.- Specified by:
isMutablein interfaceIndex<A extends CharSequence>- Returns:
- True if objects can be added to or removed from the index after the index has been built, false if the index cannot be modified after it is built
-
isQuantized
public boolean isQuantized()
Description copied from interface:IndexIndicates if the index is quantized, using aQuantizer.- Specified by:
isQuantizedin interfaceIndex<A extends CharSequence>- Returns:
- True if the index is quantized, false if not.
-
getEffectiveIndex
public Index<O> getEffectiveIndex()
Description copied from interface:IndexReturns the effective index, which Persistence objects will use to determine the identity of the index making persistence requests. Most Index implementations will typically return a reference to themselves ('this'). However in advanced cases when one index delegates to another, the implementation of the wrapping index will create a subclass the delegate index, and override this method in the delegate index so that when the delegate index interacts with the persistence, it will identify itself as the outer or "effective" index.- Specified by:
getEffectiveIndexin interfaceIndex<A extends CharSequence>- Returns:
- The effective index, in the case that this index is wrapped by another index.
-
retrieve
public ResultSet<O> retrieve(Query<O> query, QueryOptions queryOptions)
Description copied from interface:IndexReturns aResultSetwhich when iterated will return objects from the index matching the query supplied. UsuallyResultSets are lazy which means that they don't actually do any work, or encapsulate or materialize matching objects, but rather they encapsulate logic to fetch matching objects from the index on-the-fly as the application iterates through theResultSet.- Specified by:
retrievein interfaceIndex<A extends CharSequence>- Parameters:
query- An object which specifies some restriction on an attribute of an objectqueryOptions- Optional parameters for the query- Returns:
- A set of objects with attributes matching the restriction imposed by the query
- See Also:
Index.supportsQuery(Query, QueryOptions)
-
retrieveIn
protected ResultSet<O> retrieveIn(In<O,A> in, QueryOptions queryOptions, com.googlecode.concurrenttrees.radixinverted.InvertedRadixTree<StoredResultSet<O>> tree)
-
retrieveEqual
protected ResultSet<O> retrieveEqual(Equal<O,A> equal, QueryOptions queryOptions, com.googlecode.concurrenttrees.radixinverted.InvertedRadixTree<StoredResultSet<O>> tree)
-
createValueSet
public StoredResultSet<O> createValueSet()
- Returns:
- A
StoredSetBasedResultSetbased on a set backed byConcurrentHashMap, as created viaCollections.newSetFromMap(java.util.Map)
-
addAll
public boolean addAll(ObjectSet<O> objectSet, QueryOptions queryOptions)
Notifies the listener that the specified objects are being added to the collection, and so it can take action and update its internal data structures.- Specified by:
addAllin interfaceModificationListener<A extends CharSequence>- Parameters:
objectSet- The objects being addedqueryOptions- Optional parameters for the update
-
removeAll
public boolean removeAll(ObjectSet<O> objectSet, QueryOptions queryOptions)
Notifies the listener that the specified objects are being removed from the collection, and so it can take action and update its internal data structures.- Specified by:
removeAllin interfaceModificationListener<A extends CharSequence>- Parameters:
objectSet- The objects being removedqueryOptions- Optional parameters for the update
-
init
public void init(ObjectStore<O> objectStore, QueryOptions queryOptions)
Notifies the listener that the given ObjectStore has just been created.- Specified by:
initin interfaceModificationListener<A extends CharSequence>- Parameters:
objectStore- The ObjectStore which persists objectsqueryOptions- Optional parameters for the update
-
destroy
public void destroy(QueryOptions queryOptions)
This is a no-op for this type of index.- Specified by:
destroyin interfaceModificationListener<A extends CharSequence>- Parameters:
queryOptions- Optional parameters for the update
-
clear
public void clear(QueryOptions queryOptions)
Notifies the listener that all objects have been removed from the collection, and so it can take action and update its internal data structures.- Specified by:
clearin interfaceModificationListener<A extends CharSequence>- Parameters:
queryOptions- Optional parameters for the update
-
onAttribute
public static <A extends CharSequence,O> InvertedRadixTreeIndex<A,O> onAttribute(Attribute<O,A> attribute)
Creates a newInvertedRadixTreeIndexon the specified attribute.- Type Parameters:
O- The type of the object containing the attribute- Parameters:
attribute- The attribute on which the index will be built- Returns:
- A
InvertedRadixTreeIndexon this attribute
-
onAttributeUsingNodeFactory
public static <A extends CharSequence,O> InvertedRadixTreeIndex<A,O> onAttributeUsingNodeFactory(Attribute<O,A> attribute, com.googlecode.concurrenttrees.radix.node.NodeFactory nodeFactory)
Creates a newInvertedRadixTreeIndexon the specified attribute.- Type Parameters:
O- The type of the object containing the attribute- Parameters:
attribute- The attribute on which the index will be builtnodeFactory- The NodeFactory to be used by the tree- Returns:
- A
InvertedRadixTreeIndexon this attribute
-
-