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 class
SortedListCollector.SortedDoubleListCollector
static class
SortedListCollector.SortedFloatListCollector
static class
SortedListCollector.SortedIntListCollector
static class
SortedListCollector.SortedListData<D extends Comparable<D>>
static class
SortedListCollector.SortedLongListCollector
static class
SortedListCollector.SortedStringListCollector
-
Field Summary
Fields Modifier and Type Field Description static String
name
-
Fields inherited from class org.apache.solr.analytics.function.reduction.data.ReductionDataCollector
collectionTargets, ioData, lastingTargets
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
SortedListCollector(AnalyticsValueStream param, String specificationName)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
apply(SortedListCollector.SortedListData<T> data)
Apply the collected info to the given reduction data.void
calcMedian()
Informs the collector that the median needs to be computed.void
calcOrdinal(int ordinal)
Informs the collector that the following ordinal needs to be computed.void
calcPercentile(double percentile)
Informs the collector that the following percentile needs to be computed.T
exportNext()
Return the next value in the list.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.String
getExpressionStr()
The unique expression string of the reduction data collector, given all inputs and parameters.String
getName()
Get the name of the reduction data collector.protected void
importNext(T value)
Merges the current list with the incoming value.SortedListCollector.SortedListData<T>
newData()
A clean slate to start a new reduction.void
setData(ReductionData data)
This is where the given indices are put in their sorted positions.void
setMergedData(ReductionData data)
Put the given indices in their sorted positionsint
size()
int
startExport()
The list to be exported is unsorted.protected void
startImport(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:ReductionDataCollector
A clean slate to start a new reduction.- Specified by:
newData
in classReductionDataCollector<SortedListCollector.SortedListData<T extends Comparable<T>>>
- Returns:
- the new reduction data
-
apply
protected void apply(SortedListCollector.SortedListData<T> data)
Description copied from class:ReductionDataCollector
Apply the collected info to the given reduction data. Should always be called after aReductionDataCollector.collect()
call.- Specified by:
apply
in 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:
setMergedData
in 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:
setData
in 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:ReductionDataCollector
Get the name of the reduction data collector. This is the same across all instances of the data collector.- Specified by:
getName
in classReductionDataCollector<SortedListCollector.SortedListData<T extends Comparable<T>>>
- Returns:
- the name
-
getExpressionStr
public String getExpressionStr()
Description copied from class:ReductionDataCollector
The unique expression string of the reduction data collector, given all inputs and parameters. Used duringReductionDataCollector
syncing. Since the string should be unique, only one of expression is kept.- Specified by:
getExpressionStr
in classReductionDataCollector<SortedListCollector.SortedListData<T extends Comparable<T>>>
- Returns:
- the expression string
-
-