public class FilteringScore<S extends Storable>
extends java.lang.Object
An index matches a desired filtering if the arrangement of properties and
its relational operator matches. A matching =
operator is
an identity match. A range match is determined by a matching operator of
>
, >=
, <
, or <=
. Filters with a !=
operator are
ignored. Although not all index properties need to be used, the first must
be and no gaps are allowed.
A FilteringScore measures the number of filter properties that are matched and the number that are remaining. If there are remainder properties, then the user of the evaluated index will need to perform an additional filtering operation to achieve the desired results.
In general, a FilteringScore is better than another if it has more matched properties and fewer remainder properties. Matching more identity properties is given preference over matching range properties. Index clustering is also considered for score comparison.
OrderingScore
,
CompositeScore
Modifier and Type | Method and Description |
---|---|
boolean |
canMergeRemainderFilter(FilteringScore<S> other)
Returns true if the given score uses an index exactly the same as this
one.
|
static <S extends Storable> |
evaluate(OrderedProperty<S>[] indexProperties,
boolean unique,
boolean clustered,
Filter<S> filter)
Evaluates the given index properties for its filtering capabilities
against the given filter.
|
static <S extends Storable> |
evaluate(StorableIndex<S> index,
Filter<S> filter)
Evaluates the given index for its filtering capabilities against the
given filter.
|
static java.util.Comparator<FilteringScore<?>> |
fullComparator()
Returns a comparator which determines which FilteringScores are
better.
|
int |
getArrangementScore()
Returns a value which indicates how well the index property order
matches the property filter specification order.
|
int |
getCoveringCount()
Returns number of covering property filters which are supported by the
evaluated index.
|
Filter<S> |
getCoveringFilter()
Returns the composite covering filter supported by the evaluated index,
or null if the covering count is zero.
|
java.util.List<? extends Filter<S>> |
getCoveringFilters()
Returns the covering filters which are supported by the evaluated index,
which is a subset of the remainder filters.
|
Filter<S> |
getCoveringRemainderFilter()
Returns the composite remainder filter without including the covering
filter.
|
java.util.List<PropertyFilter<S>> |
getExclusiveRangeEndFilters()
Returns the range end property filters supported by the evaluated
index whose operator is only
RelOp.LT . |
java.util.List<PropertyFilter<S>> |
getExclusiveRangeStartFilters()
Returns the range start property filters supported by the evaluated
index whose operator is only
RelOp.GT . |
int |
getHandledCount()
Returns the count of all handled property filters.
|
Filter<S> |
getHandledFilter()
Returns the composite handled filter, or null if no matches at all.
|
int |
getIdentityCount()
Returns number of consecutive left-aligned index properties which match
property filters with an operator of
RelOp.EQ . |
Filter<S> |
getIdentityFilter()
Returns the composite identity filter, or null if no identity property
filters.
|
java.util.List<PropertyFilter<S>> |
getIdentityFilters()
Returns the identity property filters supported by the evaluated
index.
|
java.util.List<PropertyFilter<S>> |
getInclusiveRangeEndFilters()
Returns the range end property filters supported by the evaluated
index whose operator is only
RelOp.LE . |
java.util.List<PropertyFilter<S>> |
getInclusiveRangeStartFilters()
Returns the range start property filters supported by the evaluated
index whose operator is only
RelOp.GE . |
int |
getIndexPropertyCount()
Returns the amount of properties in the evaluated index.
|
java.lang.Comparable |
getPreferenceScore()
Returns a value which indicates user index preference, based on the
original ordering of elements in the filter.
|
java.util.List<PropertyFilter<S>> |
getRangeEndFilters()
Returns the range end property filters supported by the evaluated
index.
|
java.util.List<PropertyFilter<S>> |
getRangeStartFilters()
Returns the range start property filters supported by the evaluated
index.
|
int |
getRemainderCount()
Returns number of property filters not supported by the evaluated index.
|
Filter<S> |
getRemainderFilter()
Returns the composite remainder filter not supported by the evaluated
index, or null if no remainder.
|
java.util.List<? extends Filter<S>> |
getRemainderFilters()
Returns the filters not supported by the evaluated index.
|
boolean |
hasAnyMatches()
Returns true if the identity count is greater than zero or if there is a
range match.
|
boolean |
hasRangeEnd()
|
boolean |
hasRangeMatch()
Returns true if there is both a range start and range end.
|
boolean |
hasRangeStart()
|
boolean |
isIndexClustered()
Returns true if evaluated index is clustered.
|
boolean |
isIndexUnique()
Returns true if evaluated index is unique.
|
boolean |
isKeyMatch()
Returns true if evaluated index is unique and each of its properties has
an identity match.
|
Filter<S> |
mergeRemainderFilter(FilteringScore<S> other)
Merges the remainder filter of this score with the one given using an
'or' operation.
|
static java.util.Comparator<FilteringScore<?>> |
rangeComparator()
Returns a partial comparator which determines which FilteringScores are
better by examining only identity and range matches.
|
boolean |
shouldReverseRange()
Returns true if there is a range start or end match, but natural order
of matching property is descending.
|
java.lang.String |
toString() |
FilteringScore<S> |
withRemainderFilter(Filter<S> filter)
Returns a new FilteringScore with the remainder replaced and covering
matches recalculated.
|
public static <S extends Storable> FilteringScore<S> evaluate(StorableIndex<S> index, Filter<S> filter)
index
- index to evaluatefilter
- filter which cannot contain any logical 'or' operations.java.lang.IllegalArgumentException
- if index is null or filter is not supportedpublic static <S extends Storable> FilteringScore<S> evaluate(OrderedProperty<S>[] indexProperties, boolean unique, boolean clustered, Filter<S> filter)
indexProperties
- index properties to evaluateunique
- true if index is uniqueclustered
- true if index is clusteredfilter
- filter which cannot contain any logical 'or' operations.java.lang.IllegalArgumentException
- if index is null or filter is not supportedpublic static java.util.Comparator<FilteringScore<?>> rangeComparator()
<0
if first score is better,
0
if equal, or >0
if second is better.public static java.util.Comparator<FilteringScore<?>> fullComparator()
<0
if first score is better, 0
if equal, or
>0
if second is better.public boolean isIndexClustered()
public boolean isIndexUnique()
public int getIndexPropertyCount()
public int getIdentityCount()
RelOp.EQ
.public java.util.List<PropertyFilter<S>> getIdentityFilters()
RelOp.EQ
.public Filter<S> getIdentityFilter()
public boolean hasRangeStart()
public java.util.List<PropertyFilter<S>> getRangeStartFilters()
public java.util.List<PropertyFilter<S>> getExclusiveRangeStartFilters()
RelOp.GT
. This list is a subset of
those returned by getRangeStartFilters()
.public java.util.List<PropertyFilter<S>> getInclusiveRangeStartFilters()
RelOp.GE
. This list is a subset of
those returned by getRangeStartFilters()
.public boolean hasRangeEnd()
public java.util.List<PropertyFilter<S>> getRangeEndFilters()
public java.util.List<PropertyFilter<S>> getExclusiveRangeEndFilters()
RelOp.LT
. This list is a subset of
those returned by getRangeEndFilters()
.public java.util.List<PropertyFilter<S>> getInclusiveRangeEndFilters()
RelOp.LE
. This list is a subset of
those returned by getRangeEndFilters()
.public int getHandledCount()
public Filter<S> getHandledFilter()
public boolean hasRangeMatch()
public boolean hasAnyMatches()
public int getArrangementScore()
public java.lang.Comparable getPreferenceScore()
public int getRemainderCount()
public java.util.List<? extends Filter<S>> getRemainderFilters()
public Filter<S> getRemainderFilter()
public int getCoveringCount()
public java.util.List<? extends Filter<S>> getCoveringFilters()
public Filter<S> getCoveringFilter()
public Filter<S> getCoveringRemainderFilter()
public boolean isKeyMatch()
public boolean shouldReverseRange()
public boolean canMergeRemainderFilter(FilteringScore<S> other)
public Filter<S> mergeRemainderFilter(FilteringScore<S> other)
public FilteringScore<S> withRemainderFilter(Filter<S> filter)
public java.lang.String toString()
toString
in class java.lang.Object
Copyright © 2006-2013 Amazon Technologies, Inc.. All Rights Reserved.