Class SumCollector
- java.lang.Object
-
- org.apache.solr.analytics.function.reduction.data.ReductionDataCollector<SumCollector.SumData>
-
- org.apache.solr.analytics.function.reduction.data.SumCollector
-
public class SumCollector extends ReductionDataCollector<SumCollector.SumData>
Collects the sum of the givenDoubleValueStream
parameter.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SumCollector.SumData
-
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 Constructor Description SumCollector(DoubleValueStream param)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
apply(SumCollector.SumData data)
Apply the collected info to the given reduction data.void
collect()
Collect the information from current Solr Document.boolean
exists()
Return whether a sum exists.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.SumCollector.SumData
newData()
A clean slate to start a new reduction.void
setData(ReductionData data)
Finalize the reduction with the collected data stored in the parameter.void
setMergedData(ReductionData data)
Finalize the reduction with the merged data stored in the parameter.void
submitReservations(Consumer<ReductionDataReservation<?,?>> consumer)
Submits the data reservations needed for this data collector.double
sum()
Return the sum of the set data-
Methods inherited from class org.apache.solr.analytics.function.reduction.data.ReductionDataCollector
addCollectTarget, addLastingCollectTarget, clearLastingCollectTargets, collectAndApply, dataIO, newDataIO, newDataTarget
-
-
-
-
Field Detail
-
name
public static final String name
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
SumCollector
public SumCollector(DoubleValueStream param)
-
-
Method Detail
-
sum
public double sum()
Return the sum of the set data- Returns:
- the sum
-
exists
public boolean exists()
Return whether a sum exists. A sum will always exist if there is at least one existing value for the parameter, otherwise the sum does not exist.- Returns:
- whether a sum exists
-
newData
public SumCollector.SumData newData()
Description copied from class:ReductionDataCollector
A clean slate to start a new reduction.- Specified by:
newData
in classReductionDataCollector<SumCollector.SumData>
- Returns:
- the new reduction data
-
collect
public void collect()
Description copied from class:ReductionDataCollector
Collect the information from current Solr Document.- Overrides:
collect
in classReductionDataCollector<SumCollector.SumData>
-
apply
protected void apply(SumCollector.SumData 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<SumCollector.SumData>
- Parameters:
data
- reduction data to apply collected info to
-
submitReservations
public void submitReservations(Consumer<ReductionDataReservation<?,?>> consumer)
Description copied from class:ReductionDataCollector
Submits the data reservations needed for this data collector.- Specified by:
submitReservations
in classReductionDataCollector<SumCollector.SumData>
- Parameters:
consumer
- the consumer which the reservations are submitted to
-
setMergedData
public void setMergedData(ReductionData data)
Description copied from class:ReductionDataCollector
Finalize the reduction with the merged data stored in the parameter. Once the reduction is finalized, theReductionFunction
s that use this data collector act like regularAnalyticsValue
classes that can be accessed through theirget<value-type>
methods. (FOR CLOUD)- Specified by:
setMergedData
in classReductionDataCollector<SumCollector.SumData>
- Parameters:
data
- the merged data to compute a reduction for
-
setData
public void setData(ReductionData data)
Description copied from class:ReductionDataCollector
Finalize the reduction with the collected data stored in the parameter. Once the reduction is finalized, theReductionFunction
s that use this data collector act like regularAnalyticsValue
classes that can be accessed through theirget<value-type>
methods. (FOR SINGLE-SHARD)- Specified by:
setData
in classReductionDataCollector<SumCollector.SumData>
- 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<SumCollector.SumData>
- 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<SumCollector.SumData>
- Returns:
- the expression string
-
-