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 ownComparableSupplierto 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 classComparableUtils.ByAggregatedValueComparablestatic classComparableUtils.ByCountAndLongValueComparableUsed forbyCount(CountFacetRecorder, LongValueFacetCutter)result.static classComparableUtils.ByCountComparablestatic classComparableUtils.ByLongValueComparablestatic classComparableUtils.ByOrdinalComparableUsed 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)ComparableSupplierto sort ordinals by long aggregation (descending) with tie-break by count (descending) or by ordinal (ascending) using providedCountFacetRecorderandLongAggregationsFacetRecorder.static ComparableSupplier<ComparableUtils.ByCountComparable>byCount(CountFacetRecorder recorder)ComparableSupplierto sort ordinals by count (descending) with ord as a tie-break (ascending) using providedCountFacetRecorder.static ComparableSupplier<ComparableUtils.ByCountAndLongValueComparable>byCount(CountFacetRecorder countFacetRecorder, LongValueFacetCutter longValueFacetCutter)ComparableSupplierto sort ordinals by count (descending) fromCountFacetRecorderwith tie-break by long value (ascending) fromLongValueFacetCutter.static ComparableSupplier<ComparableUtils.ByLongValueComparable>byLongValue(LongValueFacetCutter longValueFacetCutter)ComparableSupplierto sort ordinals by long value fromLongValueFacetCutter(descending).static ComparableSupplier<ComparableUtils.ByOrdinalComparable>byOrdinal()ComparableSupplierto 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()
ComparableSupplierto sort by ords (ascending).
-
byCount
public static ComparableSupplier<ComparableUtils.ByCountComparable> byCount(CountFacetRecorder recorder)
ComparableSupplierto 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)
ComparableSupplierto sort ordinals by long aggregation (descending) with tie-break by count (descending) or by ordinal (ascending) using providedCountFacetRecorderandLongAggregationsFacetRecorder.
-
byLongValue
public static ComparableSupplier<ComparableUtils.ByLongValueComparable> byLongValue(LongValueFacetCutter longValueFacetCutter)
ComparableSupplierto sort ordinals by long value fromLongValueFacetCutter(descending).
-
byCount
public static ComparableSupplier<ComparableUtils.ByCountAndLongValueComparable> byCount(CountFacetRecorder countFacetRecorder, LongValueFacetCutter longValueFacetCutter)
ComparableSupplierto sort ordinals by count (descending) fromCountFacetRecorderwith 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
TopnOrdinalIteratorinstead.- Parameters:
ordinals- array of ordinals to sortcomparableSupplier- defines sort order- Throws:
IOException
-
-