Class ReductionDataCollector<T extends ReductionData>
- java.lang.Object
-
- org.apache.solr.analytics.function.reduction.data.ReductionDataCollector<T>
-
- Type Parameters:
T- the type of reduction data being collected
- Direct Known Subclasses:
CountCollector,MaxCollector,MinCollector,SortedListCollector,SumCollector,UniqueCollector
public abstract class ReductionDataCollector<T extends ReductionData> extends Object
Manager of a specific instance ofReductionDatacollection.
-
-
Field Summary
Fields Modifier and Type Field Description protected ArrayList<T>collectionTargetsprotected TioDataprotected ArrayList<T>lastingTargets
-
Constructor Summary
Constructors Modifier Constructor Description protectedReductionDataCollector()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddCollectTarget(ReductionData data)Add a reduction data to target during collection.voidaddLastingCollectTarget(ReductionData data)Add a reduction data to target during collection.protected abstract voidapply(T data)Apply the collected info to the given reduction data.voidclearLastingCollectTargets()Clear the lasting collection targets.protected voidcollect()Collect the information from current Solr Document.voidcollectAndApply()Collect the info for the current Solr Document and apply the results to the given collection targets.voiddataIO(ReductionData data)Set the reduction data to use in exporting and merging.abstract StringgetExpressionStr()The unique expression string of the reduction data collector, given all inputs and parameters.abstract StringgetName()Get the name of the reduction data collector.abstract TnewData()A clean slate to start a new reduction.TnewDataIO()Create a new reduction data to use in exporting and merging.TnewDataTarget()Create a new reduction data to target during collection.abstract voidsetData(ReductionData data)Finalize the reduction with the collected data stored in the parameter.abstract voidsetMergedData(ReductionData data)Finalize the reduction with the merged data stored in the parameter.abstract voidsubmitReservations(Consumer<ReductionDataReservation<?,?>> consumer)Submits the data reservations needed for this data collector.
-
-
-
Field Detail
-
lastingTargets
protected ArrayList<T extends ReductionData> lastingTargets
-
collectionTargets
protected ArrayList<T extends ReductionData> collectionTargets
-
ioData
protected T extends ReductionData ioData
-
-
Method Detail
-
submitReservations
public abstract void submitReservations(Consumer<ReductionDataReservation<?,?>> consumer)
Submits the data reservations needed for this data collector.- Parameters:
consumer- the consumer which the reservations are submitted to
-
newData
public abstract T newData()
A clean slate to start a new reduction.- Returns:
- the new reduction data
-
addLastingCollectTarget
public void addLastingCollectTarget(ReductionData data)
Add a reduction data to target during collection. The given target is valid until the lasting targets are cleared.- Parameters:
data- the data to target
-
clearLastingCollectTargets
public void clearLastingCollectTargets()
Clear the lasting collection targets. After this is called the current lasting targets will not be affected by futurecollectAndApply()calls.
-
newDataTarget
public T newDataTarget()
Create a new reduction data to target during collection. The given target is only valid for one call tocollectAndApply().- Returns:
- the reduction data created
-
addCollectTarget
public void addCollectTarget(ReductionData data)
Add a reduction data to target during collection. The given target is only valid for one call tocollectAndApply().- Parameters:
data- the data to target
-
collectAndApply
public void collectAndApply()
Collect the info for the current Solr Document and apply the results to the given collection targets.After application, all non-lasting targets are removed.
-
collect
protected void collect()
Collect the information from current Solr Document.
-
apply
protected abstract void apply(T data)
Apply the collected info to the given reduction data. Should always be called after acollect()call.- Parameters:
data- reduction data to apply collected info to
-
newDataIO
public T newDataIO()
Create a new reduction data to use in exporting and merging.- Returns:
- the created reduction data
-
dataIO
public void dataIO(ReductionData data)
Set the reduction data to use in exporting and merging.- Parameters:
data- the data to use
-
setMergedData
public abstract void setMergedData(ReductionData data)
Finalize the reduction with the merged data stored in the parameter. Once the reduction is finalized, theReductionFunctions that use this data collector act like regularAnalyticsValueclasses that can be accessed through theirget<value-type>methods.(FOR CLOUD)
- Parameters:
data- the merged data to compute a reduction for
-
setData
public abstract void setData(ReductionData data)
Finalize the reduction with the collected data stored in the parameter. Once the reduction is finalized, theReductionFunctions that use this data collector act like regularAnalyticsValueclasses that can be accessed through theirget<value-type>methods.(FOR SINGLE-SHARD)
- Parameters:
data- the collected data to compute a reduction for
-
getName
public abstract String getName()
Get the name of the reduction data collector. This is the same across all instances of the data collector.- Returns:
- the name
-
getExpressionStr
public abstract String getExpressionStr()
The 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.- Returns:
- the expression string
-
-