com.amazon.carbonado.qe
Class CompositeScore<S extends Storable>

java.lang.Object
  extended by com.amazon.carbonado.qe.CompositeScore<S>

public class CompositeScore<S extends Storable>
extends Object

Evaluates an index for how well it matches a query's desired filtering and ordering. A composite score is not a single absolute value – instead it has a relative weight when compared to other scores.

Author:
Brian S O'Neill
See Also:
FilteringScore, OrderingScore

Method Summary
 boolean canMergeRemainder(CompositeScore<S> other)
          Returns true if the filtering score can merge its remainder filter and the ordering score can merge its remainder orderings.
static
<S extends Storable>
CompositeScore<S>
evaluate(OrderedProperty<S>[] indexProperties, boolean unique, boolean clustered, Filter<S> filter, OrderingList<S> ordering)
          Evaluates the given index properties for its filtering and ordering capabilities against the given filter and order-by properties.
static
<S extends Storable>
CompositeScore<S>
evaluate(StorableIndex<S> index, Filter<S> filter, OrderingList<S> ordering)
          Evaluates the given index for its filtering and ordering capabilities against the given filter and order-by properties.
static Comparator<CompositeScore<?>> fullComparator()
          Returns a comparator which determines which CompositeScores are better.
static Comparator<CompositeScore<?>> fullComparator(QueryHints hints)
          Returns a comparator which determines which CompositeScores are better.
 FilteringScore<S> getFilteringScore()
          Returns the score on how well the evaluated index performs the desired filtering.
 OrderingScore<S> getOrderingScore()
          Returns the score on how well the evaluated index performs the desired ordering.
static Comparator<CompositeScore<?>> localForeignComparator()
          Returns a partial comparator suited for comparing local indexes to foreign indexes.
static Comparator<CompositeScore<?>> localForeignComparator(QueryHints hints)
          Returns a partial comparator suited for comparing local indexes to foreign indexes.
 Filter<S> mergeRemainderFilter(CompositeScore<S> other)
          Merges the remainder filter of this score with the one given using an 'or' operation.
 OrderingList<S> mergeRemainderOrdering(CompositeScore<S> other)
          Merges the remainder orderings of this score with the one given.
 String toString()
           
 CompositeScore<S> withRemainderFilter(Filter<S> filter)
          Returns a new CompositeScore with the filtering remainder replaced and covering matches recalculated.
 CompositeScore<S> withRemainderOrdering(OrderingList<S> ordering)
          Returns a new CompositeScore with the ordering remainder replaced.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

evaluate

public static <S extends Storable> CompositeScore<S> evaluate(StorableIndex<S> index,
                                                              Filter<S> filter,
                                                              OrderingList<S> ordering)
Evaluates the given index for its filtering and ordering capabilities against the given filter and order-by properties.

Parameters:
index - index to evaluate
filter - optional filter which cannot contain any logical 'or' operations.
ordering - optional properties which define desired ordering
Throws:
IllegalArgumentException - if index is null or filter is not supported

evaluate

public static <S extends Storable> CompositeScore<S> evaluate(OrderedProperty<S>[] indexProperties,
                                                              boolean unique,
                                                              boolean clustered,
                                                              Filter<S> filter,
                                                              OrderingList<S> ordering)
Evaluates the given index properties for its filtering and ordering capabilities against the given filter and order-by properties.

Parameters:
indexProperties - index properties to evaluate
unique - true if index is unique
clustered - true if index is clustered
filter - optional filter which cannot contain any logical 'or' operations.
ordering - optional properties which define desired ordering
Throws:
IllegalArgumentException - if index is null or filter is not supported

localForeignComparator

public static Comparator<CompositeScore<?>> localForeignComparator()
Returns a partial comparator suited for comparing local indexes to foreign indexes. It determines which CompositeScores are better by examining identity matches, range matches and ordering. It does not matter if the scores were evaluated for different indexes or storable types. The comparator returns <0 if first score is better, 0 if equal, or >0 if second is better.


localForeignComparator

public static Comparator<CompositeScore<?>> localForeignComparator(QueryHints hints)
Returns a partial comparator suited for comparing local indexes to foreign indexes. It determines which CompositeScores are better by examining identity matches, range matches and ordering. It does not matter if the scores were evaluated for different indexes or storable types. The comparator returns <0 if first score is better, 0 if equal, or >0 if second is better.

Parameters:
hints - optional hints

fullComparator

public static Comparator<CompositeScore<?>> fullComparator()
Returns a comparator which determines which CompositeScores are better. It compares identity matches, range matches, ordering, open range matches, property arrangement and index cost estimate. It does not matter if the scores were evaluated for different indexes or storable types. The comparator returns <0 if first score is better, 0 if equal, or >0 if second is better.


fullComparator

public static Comparator<CompositeScore<?>> fullComparator(QueryHints hints)
Returns a comparator which determines which CompositeScores are better. It compares identity matches, range matches, ordering, open range matches, property arrangement and index cost estimate. It does not matter if the scores were evaluated for different indexes or storable types. The comparator returns <0 if first score is better, 0 if equal, or >0 if second is better.

Parameters:
hints - optional hints

getFilteringScore

public FilteringScore<S> getFilteringScore()
Returns the score on how well the evaluated index performs the desired filtering.


getOrderingScore

public OrderingScore<S> getOrderingScore()
Returns the score on how well the evaluated index performs the desired ordering.


canMergeRemainder

public boolean canMergeRemainder(CompositeScore<S> other)
Returns true if the filtering score can merge its remainder filter and the ordering score can merge its remainder orderings.


mergeRemainderFilter

public Filter<S> mergeRemainderFilter(CompositeScore<S> other)
Merges the remainder filter of this score with the one given using an 'or' operation. Call canMergeRemainder first to verify if the merge makes any sense.


mergeRemainderOrdering

public OrderingList<S> mergeRemainderOrdering(CompositeScore<S> other)
Merges the remainder orderings of this score with the one given. Call canMergeRemainder first to verify if the merge makes any sense.


withRemainderFilter

public CompositeScore<S> withRemainderFilter(Filter<S> filter)
Returns a new CompositeScore with the filtering remainder replaced and covering matches recalculated. Other matches are not recalculated.

Since:
1.2

withRemainderOrdering

public CompositeScore<S> withRemainderOrdering(OrderingList<S> ordering)
Returns a new CompositeScore with the ordering remainder replaced. Handled count is not recalculated.

Since:
1.2

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2006-2009 Amazon Technologies, Inc.. All Rights Reserved.