Package org.apache.lucene.sandbox.facet
Class ComparableUtils
- java.lang.Object
-
- org.apache.lucene.sandbox.facet.ComparableUtils
-
public final class ComparableUtils extends Object
Collection of static methods to provide most common comparables for sandbox faceting. You can also use it as an example for creating your ownComparableSupplier
to enable custom facets top-n and sorting.- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ComparableUtils.ByAggregatedValueComparable
static class
ComparableUtils.ByCountAndLongValueComparable
Used forbyCount(CountFacetRecorder, LongValueFacetCutter)
result.static class
ComparableUtils.ByCountComparable
static class
ComparableUtils.ByLongValueComparable
static class
ComparableUtils.ByOrdinalComparable
Used forbyOrdinal()
result.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ComparableSupplier<ComparableUtils.ByAggregatedValueComparable>
byAggregatedValue(CountFacetRecorder countRecorder, LongAggregationsFacetRecorder longAggregationsFacetRecorder, int aggregationId)
ComparableSupplier
to sort ordinals by long aggregation (descending) with tie-break by count (descending) or by ordinal (ascending) using providedCountFacetRecorder
andLongAggregationsFacetRecorder
.static ComparableSupplier<ComparableUtils.ByCountComparable>
byCount(CountFacetRecorder recorder)
ComparableSupplier
to sort ordinals by count (descending) with ord as a tie-break (ascending) using providedCountFacetRecorder
.static ComparableSupplier<ComparableUtils.ByCountAndLongValueComparable>
byCount(CountFacetRecorder countFacetRecorder, LongValueFacetCutter longValueFacetCutter)
ComparableSupplier
to sort ordinals by count (descending) fromCountFacetRecorder
with tie-break by long value (ascending) fromLongValueFacetCutter
.static ComparableSupplier<ComparableUtils.ByLongValueComparable>
byLongValue(LongValueFacetCutter longValueFacetCutter)
ComparableSupplier
to sort ordinals by long value fromLongValueFacetCutter
(descending).static ComparableSupplier<ComparableUtils.ByOrdinalComparable>
byOrdinal()
ComparableSupplier
to sort by ords (ascending).static <T extends Comparable<T>>
voidsort(int[] ordinals, ComparableSupplier<T> comparableSupplier)
Sort array of ordinals.
-
-
-
Method Detail
-
byOrdinal
public static ComparableSupplier<ComparableUtils.ByOrdinalComparable> byOrdinal()
ComparableSupplier
to sort by ords (ascending).
-
byCount
public static ComparableSupplier<ComparableUtils.ByCountComparable> byCount(CountFacetRecorder recorder)
ComparableSupplier
to sort ordinals by count (descending) with ord as a tie-break (ascending) using providedCountFacetRecorder
.
-
byAggregatedValue
public static ComparableSupplier<ComparableUtils.ByAggregatedValueComparable> byAggregatedValue(CountFacetRecorder countRecorder, LongAggregationsFacetRecorder longAggregationsFacetRecorder, int aggregationId)
ComparableSupplier
to sort ordinals by long aggregation (descending) with tie-break by count (descending) or by ordinal (ascending) using providedCountFacetRecorder
andLongAggregationsFacetRecorder
.
-
byLongValue
public static ComparableSupplier<ComparableUtils.ByLongValueComparable> byLongValue(LongValueFacetCutter longValueFacetCutter)
ComparableSupplier
to sort ordinals by long value fromLongValueFacetCutter
(descending).
-
byCount
public static ComparableSupplier<ComparableUtils.ByCountAndLongValueComparable> byCount(CountFacetRecorder countFacetRecorder, LongValueFacetCutter longValueFacetCutter)
ComparableSupplier
to sort ordinals by count (descending) fromCountFacetRecorder
with tie-break by long value (ascending) fromLongValueFacetCutter
.
-
sort
public static <T extends Comparable<T>> void sort(int[] ordinals, ComparableSupplier<T> comparableSupplier) throws IOException
Sort array of ordinals.To get top-n ordinals use
TopnOrdinalIterator
instead.- Parameters:
ordinals
- array of ordinals to sortcomparableSupplier
- defines sort order- Throws:
IOException
-
-