Class SortedListCollector<T extends Comparable<T>>
- java.lang.Object
-
- org.apache.solr.analytics.function.reduction.data.ReductionDataCollector<SortedListCollector.SortedListData<T>>
-
- org.apache.solr.analytics.function.reduction.data.SortedListCollector<T>
-
- Type Parameters:
T- The type of data being processed.
- Direct Known Subclasses:
SortedListCollector.SortedDoubleListCollector,SortedListCollector.SortedFloatListCollector,SortedListCollector.SortedIntListCollector,SortedListCollector.SortedLongListCollector,SortedListCollector.SortedStringListCollector
public abstract class SortedListCollector<T extends Comparable<T>> extends ReductionDataCollector<SortedListCollector.SortedListData<T>>
Collector of sorted lists.Once the sorted list has been collected, it can be reduced by calculating a median, percentiles, or ordinals. All of the above reductions over the same data share one
SortedListCollector.Supported types are:
- Int
- Long
- Float
- Double
- Date (through longs)
- String
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSortedListCollector.SortedDoubleListCollectorstatic classSortedListCollector.SortedFloatListCollectorstatic classSortedListCollector.SortedIntListCollectorstatic classSortedListCollector.SortedListData<D extends Comparable<D>>static classSortedListCollector.SortedLongListCollectorstatic classSortedListCollector.SortedStringListCollector
-
Field Summary
Fields Modifier and Type Field Description static Stringname-
Fields inherited from class org.apache.solr.analytics.function.reduction.data.ReductionDataCollector
collectionTargets, ioData, lastingTargets
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedSortedListCollector(AnalyticsValueStream param, String specificationName)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidapply(SortedListCollector.SortedListData<T> data)Apply the collected info to the given reduction data.voidcalcMedian()Informs the collector that the median needs to be computed.voidcalcOrdinal(int ordinal)Informs the collector that the following ordinal needs to be computed.voidcalcPercentile(double percentile)Informs the collector that the following percentile needs to be computed.TexportNext()Return the next value in the list.Tget(int index)Once the data has been set by eithersetData(org.apache.solr.analytics.function.reduction.data.ReductionData)orsetMergedData(org.apache.solr.analytics.function.reduction.data.ReductionData), this returns the value at the given sorted index.StringgetExpressionStr()The unique expression string of the reduction data collector, given all inputs and parameters.StringgetName()Get the name of the reduction data collector.protected voidimportNext(T value)Merges the current list with the incoming value.SortedListCollector.SortedListData<T>newData()A clean slate to start a new reduction.voidsetData(ReductionData data)This is where the given indices are put in their sorted positions.voidsetMergedData(ReductionData data)Put the given indices in their sorted positionsintsize()intstartExport()The list to be exported is unsorted.protected voidstartImport(int size)Starts the import of the shard data.-
Methods inherited from class org.apache.solr.analytics.function.reduction.data.ReductionDataCollector
addCollectTarget, addLastingCollectTarget, clearLastingCollectTargets, collect, collectAndApply, dataIO, newDataIO, newDataTarget, submitReservations
-
-
-
-
Field Detail
-
name
public static final String name
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
SortedListCollector
protected SortedListCollector(AnalyticsValueStream param, String specificationName)
-
-
Method Detail
-
size
public int size()
-
calcMedian
public void calcMedian()
Informs the collector that the median needs to be computed.
-
calcPercentile
public void calcPercentile(double percentile)
Informs the collector that the following percentile needs to be computed.- Parameters:
percentile- requested percentile
-
calcOrdinal
public void calcOrdinal(int ordinal)
Informs the collector that the following ordinal needs to be computed.- Parameters:
ordinal- requested ordinal
-
get
public T get(int index)
Once the data has been set by eithersetData(org.apache.solr.analytics.function.reduction.data.ReductionData)orsetMergedData(org.apache.solr.analytics.function.reduction.data.ReductionData), this returns the value at the given sorted index.Only the indices specified by
calcMedian,calcPercentile(double), andcalcOrdinal(int)will contain valid data. All other indices may return unsorted data.- Parameters:
index- the index of the sorted data to return
-
newData
public SortedListCollector.SortedListData<T> newData()
Description copied from class:ReductionDataCollectorA clean slate to start a new reduction.- Specified by:
newDatain classReductionDataCollector<SortedListCollector.SortedListData<T extends Comparable<T>>>- Returns:
- the new reduction data
-
apply
protected void apply(SortedListCollector.SortedListData<T> data)
Description copied from class:ReductionDataCollectorApply the collected info to the given reduction data. Should always be called after aReductionDataCollector.collect()call.- Specified by:
applyin classReductionDataCollector<SortedListCollector.SortedListData<T extends Comparable<T>>>- Parameters:
data- reduction data to apply collected info to
-
startImport
protected void startImport(int size)
Starts the import of the shard data.- Parameters:
size- the size of the incoming shard list
-
importNext
protected void importNext(T value)
Merges the current list with the incoming value.- Parameters:
value- the next imported value to add
-
startExport
public int startExport()
The list to be exported is unsorted. The lists of all shards will be combined with thestartImport(int)andimportNext(T)methods.- Returns:
- the size of the list being exported.
-
exportNext
public T exportNext()
Return the next value in the list.- Returns:
- the next sorted value
-
setMergedData
public void setMergedData(ReductionData data)
Put the given indices in their sorted positions- Specified by:
setMergedDatain classReductionDataCollector<SortedListCollector.SortedListData<T extends Comparable<T>>>- Parameters:
data- the merged data to compute a reduction for
-
setData
public void setData(ReductionData data)
This is where the given indices are put in their sorted positions.Only the given indices are guaranteed to be in sorted order.
- Specified by:
setDatain classReductionDataCollector<SortedListCollector.SortedListData<T extends Comparable<T>>>- Parameters:
data- the collected data to compute a reduction for
-
getName
public String getName()
Description copied from class:ReductionDataCollectorGet the name of the reduction data collector. This is the same across all instances of the data collector.- Specified by:
getNamein classReductionDataCollector<SortedListCollector.SortedListData<T extends Comparable<T>>>- Returns:
- the name
-
getExpressionStr
public String getExpressionStr()
Description copied from class:ReductionDataCollectorThe unique expression string of the reduction data collector, given all inputs and parameters. Used duringReductionDataCollectorsyncing. Since the string should be unique, only one of expression is kept.- Specified by:
getExpressionStrin classReductionDataCollector<SortedListCollector.SortedListData<T extends Comparable<T>>>- Returns:
- the expression string
-
-