Class MetadataEngine<O>
- java.lang.Object
-
- com.googlecode.cqengine.metadata.MetadataEngine<O>
-
public class MetadataEngine<O> extends Object
Provides access to metadata for attributes, obtained from indexes which have been added to the collection. Example metadata:- frequency distributions (counts of the occurrences of each distinct value of an attribute in the collection)
- count the number of objects in the collection whose attribute has a specific value
- obtain all of the distinct values of an attribute
The
getAttributeMetadata(Attribute)
method returns anAttributeMetadata
accessor object, which can provide access to basic metadata as discussed above for a given attribute, in unsorted order. This requires in advance, an index which implements theKeyStatisticsAttributeIndex
interface, to be added to the collection on the given attribute. Most indexes implement that interface.The
getSortedAttributeMetadata(Attribute)
method returns aSortedAttributeMetadata
accessor object, which can provide access to additional metadata and in sorted order. It allows attribute values to be traversed in ascending or descending order, and it supports range queries. This requires in advance, an index which implements theSortedKeyStatisticsAttributeIndex
interface, to be added to the collection on the given attribute. That interface is implemented by many indexes.This object can be accessed by calling
IndexedCollection.getMetadataEngine()
.
-
-
Constructor Summary
Constructors Constructor Description MetadataEngine(IndexedCollection<O> indexedCollection, Supplier<QueryOptions> openResourcesHandler, Consumer<QueryOptions> closeResourcesHandler)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <A> AttributeMetadata<A,O>
getAttributeMetadata(Attribute<O,A> attribute)
Returns anAttributeMetadata
accessor object, which can provide access to basic metadata for a given attribute, in unsorted order.<A extends Comparable<A>>
SortedAttributeMetadata<A,O>getSortedAttributeMetadata(Attribute<O,A> attribute)
Returns aSortedAttributeMetadata
accessor object, which can provide access to metadata in sorted order for a given attribute.
-
-
-
Constructor Detail
-
MetadataEngine
public MetadataEngine(IndexedCollection<O> indexedCollection, Supplier<QueryOptions> openResourcesHandler, Consumer<QueryOptions> closeResourcesHandler)
-
-
Method Detail
-
getAttributeMetadata
public <A> AttributeMetadata<A,O> getAttributeMetadata(Attribute<O,A> attribute)
Returns anAttributeMetadata
accessor object, which can provide access to basic metadata for a given attribute, in unsorted order.This requires in advance, an index which implements the
KeyStatisticsAttributeIndex
interface, to be added to the collection on the given attribute.- Parameters:
attribute
- The attribute for which metadata is required- Returns:
- an
AttributeMetadata
accessor object - Throws:
IllegalStateException
- if no suitable index has been added to the collection
-
getSortedAttributeMetadata
public <A extends Comparable<A>> SortedAttributeMetadata<A,O> getSortedAttributeMetadata(Attribute<O,A> attribute)
Returns aSortedAttributeMetadata
accessor object, which can provide access to metadata in sorted order for a given attribute. It allows attribute values to be traversed in ascending or descending order, and it supports range queries.This requires in advance, an index which implements the
SortedKeyStatisticsAttributeIndex
interface, to be added to the collection on the given attribute.- Parameters:
attribute
- The attribute for which metadata is required- Returns:
- an
AttributeMetadata
accessor object - Throws:
IllegalStateException
- if no suitable index has been added to the collection
-
-