Class SuffixTreeIndex<A extends CharSequence,O>
- java.lang.Object
-
- com.googlecode.cqengine.index.support.AbstractAttributeIndex<A,O>
-
- com.googlecode.cqengine.index.suffix.SuffixTreeIndex<A,O>
-
- All Implemented Interfaces:
ModificationListener<O>
,AttributeIndex<A,O>
,Index<O>
,OnHeapTypeIndex
public class SuffixTreeIndex<A extends CharSequence,O> extends AbstractAttributeIndex<A,O> implements OnHeapTypeIndex
An index backed by aConcurrentSuffixTree
. 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 protected
SuffixTreeIndex(Attribute<O,A> attribute)
Package-private constructor, used by static factory methods.protected
SuffixTreeIndex(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 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.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.StoredResultSet<O>
createValueSet()
void
destroy(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.void
init(ObjectStore<O> objectStore, QueryOptions queryOptions)
Notifies the listener that the given ObjectStore has just been created.boolean
isMutable()
Indicates if objects can be added to or removed from the index after the index has been built.boolean
isQuantized()
Indicates if the index is quantized, using aQuantizer
.static <A extends CharSequence,O>
SuffixTreeIndex<A,O>onAttribute(Attribute<O,A> attribute)
Creates a newSuffixTreeIndex
on the specified attribute.static <A extends CharSequence,O>
SuffixTreeIndex<A,O>onAttributeUsingNodeFactory(Attribute<O,A> attribute, com.googlecode.concurrenttrees.radix.node.NodeFactory nodeFactory)
Creates a newSuffixTreeIndex
on the specified attribute.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.ResultSet<O>
retrieve(Query<O> query, QueryOptions queryOptions)
Returns aResultSet
which 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.suffix.SuffixTree<StoredResultSet<O>> tree)
protected ResultSet<O>
retrieveIn(In<O,A> in, QueryOptions queryOptions, com.googlecode.concurrenttrees.suffix.SuffixTree<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:Index
Indicates if objects can be added to or removed from the index after the index has been built.- Specified by:
isMutable
in 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:Index
Indicates if the index is quantized, using aQuantizer
.- Specified by:
isQuantized
in interfaceIndex<A extends CharSequence>
- Returns:
- True if the index is quantized, false if not.
-
getEffectiveIndex
public Index<O> getEffectiveIndex()
Description copied from interface:Index
Returns 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:
getEffectiveIndex
in 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:Index
Returns aResultSet
which when iterated will return objects from the index matching the query supplied. UsuallyResultSet
s 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:
retrieve
in 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.suffix.SuffixTree<StoredResultSet<O>> tree)
-
retrieveEqual
protected ResultSet<O> retrieveEqual(Equal<O,A> equal, QueryOptions queryOptions, com.googlecode.concurrenttrees.suffix.SuffixTree<StoredResultSet<O>> tree)
-
createValueSet
public StoredResultSet<O> createValueSet()
- Returns:
- A
StoredSetBasedResultSet
based 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:
addAll
in 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:
removeAll
in 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:
init
in 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:
destroy
in 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:
clear
in interfaceModificationListener<A extends CharSequence>
- Parameters:
queryOptions
- Optional parameters for the update
-
onAttribute
public static <A extends CharSequence,O> SuffixTreeIndex<A,O> onAttribute(Attribute<O,A> attribute)
Creates a newSuffixTreeIndex
on 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
SuffixTreeIndex
on this attribute
-
onAttributeUsingNodeFactory
public static <A extends CharSequence,O> SuffixTreeIndex<A,O> onAttributeUsingNodeFactory(Attribute<O,A> attribute, com.googlecode.concurrenttrees.radix.node.NodeFactory nodeFactory)
Creates a newSuffixTreeIndex
on 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
SuffixTreeIndex
on this attribute
-
-