public final class Results
extends java.lang.Object
Utility functions for working with results.
Modifier and Type | Method and Description |
---|---|
static BasicResult |
basicCopy(Result r)
Create a basic result that has the same ID and score as another result (a basic copy of the result).
|
static Function<Result,BasicResult> |
basicCopyFunction()
Guava function that converts a result to a basic result.
|
static Equivalence<Result> |
basicEquivalence()
An equivalence relation that considers objects to be equal if they are equal after being converted to basic results (that is, their IDs and scores are equal).
|
static BasicResult |
create(long id,
double score)
Create a new result with just and ID and a score.
|
static BasicResult |
fromEntry(java.util.Map.Entry<java.lang.Long,java.lang.Double> entry)
Convert a map entry to a basic result.
|
static Function<java.util.Map.Entry<java.lang.Long,java.lang.Double>,Result> |
fromEntryFunction()
Function to convert map entries to basic results.
|
static Ordering<Result> |
idOrder()
Get an ordering (comparator) that orders results by ID.
|
static KeyExtractor<Result> |
keyExtractor()
Get a key extractor that extracts the result’s ID as its key.
|
static java.util.stream.Collector<Result,?,ResultList> |
listCollector()
A Java 8 collector that makes result lists.
|
static ResultList |
newResultList(java.util.List<? extends Result> results)
Create a new result list.
|
static <R extends Result> |
newResultList(R... results)
Create a new result list.
|
static BasicResultMap |
newResultMap(java.lang.Iterable<? extends Result> results)
Create a new result list.
|
static <R extends Result> |
newResultMap(R... results)
Create a new result list.
|
static RescoredResult |
rescore(Result r,
double s)
Create a rescored result.
|
static RescoredResult |
rescore(Result orig,
Result score)
Create a rescored result with details.
|
static Ordering<Result> |
scoreOrder()
Get an ordering (comparator) that orders results by score.
|
public static BasicResult create(long id, double score)
Create a new result with just and ID and a score.
id
- The ID.score
- The score.public static BasicResult basicCopy(Result r)
Create a basic result that has the same ID and score as another result (a basic copy of the result).
r
- The result to copy.r
. This may be the same object as r
, since basic results are immutable.public static RescoredResult rescore(Result r, double s)
Create a rescored result.
r
- The result to score.s
- The new score.RescoredResult
that wraps r
with a new score of s
.public static RescoredResult rescore(@Nonnull Result orig, @Nullable Result score)
Create a rescored result with details.
orig
- The original result.score
- The new result, or null
for no score (the resulting result will have no score).@Nonnull public static ResultList newResultList(@Nonnull java.util.List<? extends Result> results)
Create a new result list.
results
- The results to include in the list.@SafeVarargs @Nonnull public static <R extends Result> ResultList newResultList(R... results)
Create a new result list.
results
- The results to include in the list.R
- the result type@Nonnull public static BasicResultMap newResultMap(@Nonnull java.lang.Iterable<? extends Result> results)
Create a new result list.
results
- The results to include in the list.@SafeVarargs @Nonnull public static <R extends Result> BasicResultMap newResultMap(R... results)
Create a new result list.
results
- The results to include in the list.R
- the result typepublic static java.util.stream.Collector<Result,?,ResultList> listCollector()
A Java 8 collector that makes result lists.
public static Function<Result,BasicResult> basicCopyFunction()
Guava function that converts a result to a basic result. This is just basicCopy(Result)
exposed as a Guava Function
for use in processing lists, etc.
public static BasicResult fromEntry(java.util.Map.Entry<java.lang.Long,java.lang.Double> entry)
Convert a map entry to a basic result.
entry
- The map entry.public static Function<java.util.Map.Entry<java.lang.Long,java.lang.Double>,Result> fromEntryFunction()
Function to convert map entries to basic results.
public static Equivalence<Result> basicEquivalence()
An equivalence relation that considers objects to be equal if they are equal after being converted to basic results (that is, their IDs and scores are equal).
public static Ordering<Result> idOrder()
Get an ordering (comparator) that orders results by ID.
public static Ordering<Result> scoreOrder()
Get an ordering (comparator) that orders results by score.
public static KeyExtractor<Result> keyExtractor()
Get a key extractor that extracts the result’s ID as its key.