public class OrderingScore<S extends Storable>
extends java.lang.Object
An index matches a desired ordering if the arrangement of properties
matches. Not all properties of the index need to be used, however. Also,
gaps in the arrangement are allowed if a property identity filter
matches. A property identity filter is of the form "a = ?"
.
An OrderingScore measures the number of ordering 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 a post-sort operation to achieve the desired results.
In general, an OrderingScore is better than another if it has more matched properties and fewer remainder properties. Index clustering, property count, and natural order is also considered.
FilteringScore
,
CompositeScore
Modifier and Type | Method and Description |
---|---|
boolean |
canMergeRemainderOrdering(OrderingScore<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,
OrderingList<S> ordering)
Evaluates the given index properties for its ordering capabilities
against the given filter and order-by properties.
|
static <S extends Storable> |
evaluate(StorableIndex<S> index,
Filter<S> filter,
OrderingList<S> ordering)
Evaluates the given index for its ordering capabilities against the
given filter and order-by properties.
|
static java.util.Comparator<OrderingScore<?>> |
fullComparator()
Returns a comparator which determines which OrderingScores are
better.
|
OrderingList<S> |
getFreeOrdering()
Returns potential ordering properties that the evaluated index can
handle, if arranged to immediately follow the handled orderings.
|
int |
getHandledCount()
Returns the number of desired orderings the evaluated index
supports.
|
OrderingList<S> |
getHandledOrdering()
Returns the ordering properties that the evaluated index supports.
|
int |
getIndexPropertyCount()
Returns the amount of properties in the evaluated index.
|
int |
getRemainderCount()
Returns the number of desired orderings the evaluated index does not
support.
|
OrderingList<S> |
getRemainderOrdering()
Returns the ordering properties that the evaluated index does not
support.
|
OrderingList<S> |
getUnusedOrdering()
Returns unused ordering properties of the evaluated index because they
were filtered out.
|
boolean |
isIndexClustered()
Returns true if evaluated index is clustered.
|
OrderingList<S> |
mergeRemainderOrdering(OrderingScore<S> other)
Merges the remainder orderings of this score with the one given.
|
boolean |
shouldReverseOrder()
Returns true if evaluated index must be iterated in reverse to achieve
the desired ordering.
|
java.lang.String |
toString() |
OrderingScore<S> |
withRemainderOrdering(OrderingList<S> ordering)
Returns a new OrderingScore with the remainder replaced.
|
public static <S extends Storable> OrderingScore<S> evaluate(StorableIndex<S> index, Filter<S> filter, OrderingList<S> ordering)
index
- index to evaluatefilter
- optional filter which cannot contain any logical 'or' operations.ordering
- optional properties which define desired orderingjava.lang.IllegalArgumentException
- if index is null or filter is not supportedpublic static <S extends Storable> OrderingScore<S> evaluate(OrderedProperty<S>[] indexProperties, boolean unique, boolean clustered, Filter<S> filter, OrderingList<S> ordering)
indexProperties
- index properties to evaluateunique
- true if index is uniqueclustered
- true if index is clusteredfilter
- optional filter which cannot contain any logical 'or' operations.ordering
- optional properties which define desired orderingjava.lang.IllegalArgumentException
- if index is null or filter is not supportedpublic static java.util.Comparator<OrderingScore<?>> fullComparator()
<0
if first
score is better, 0
if equal, or >0
if second is better.public boolean isIndexClustered()
public int getIndexPropertyCount()
public int getHandledCount()
public OrderingList<S> getHandledOrdering()
public int getRemainderCount()
public OrderingList<S> getRemainderOrdering()
public boolean shouldReverseOrder()
public OrderingList<S> getFreeOrdering()
public OrderingList<S> getUnusedOrdering()
public boolean canMergeRemainderOrdering(OrderingScore<S> other)
public OrderingList<S> mergeRemainderOrdering(OrderingScore<S> other)
public OrderingScore<S> withRemainderOrdering(OrderingList<S> ordering)
public java.lang.String toString()
toString
in class java.lang.Object
Copyright © 2006-2013 Amazon Technologies, Inc.. All Rights Reserved.