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 givenDoubleValueStreamparameter.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSumCollector.SumData
-
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 Constructor Description SumCollector(DoubleValueStream param)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidapply(SumCollector.SumData data)Apply the collected info to the given reduction data.voidcollect()Collect the information from current Solr Document.booleanexists()Return whether a sum exists.StringgetExpressionStr()The unique expression string of the reduction data collector, given all inputs and parameters.StringgetName()Get the name of the reduction data collector.SumCollector.SumDatanewData()A clean slate to start a new reduction.voidsetData(ReductionData data)Finalize the reduction with the collected data stored in the parameter.voidsetMergedData(ReductionData data)Finalize the reduction with the merged data stored in the parameter.voidsubmitReservations(Consumer<ReductionDataReservation<?,?>> consumer)Submits the data reservations needed for this data collector.doublesum()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:ReductionDataCollectorA clean slate to start a new reduction.- Specified by:
newDatain classReductionDataCollector<SumCollector.SumData>- Returns:
- the new reduction data
-
collect
public void collect()
Description copied from class:ReductionDataCollectorCollect the information from current Solr Document.- Overrides:
collectin classReductionDataCollector<SumCollector.SumData>
-
apply
protected void apply(SumCollector.SumData 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<SumCollector.SumData>- Parameters:
data- reduction data to apply collected info to
-
submitReservations
public void submitReservations(Consumer<ReductionDataReservation<?,?>> consumer)
Description copied from class:ReductionDataCollectorSubmits the data reservations needed for this data collector.- Specified by:
submitReservationsin classReductionDataCollector<SumCollector.SumData>- Parameters:
consumer- the consumer which the reservations are submitted to
-
setMergedData
public void setMergedData(ReductionData data)
Description copied from class:ReductionDataCollectorFinalize 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)- Specified by:
setMergedDatain classReductionDataCollector<SumCollector.SumData>- Parameters:
data- the merged data to compute a reduction for
-
setData
public void setData(ReductionData data)
Description copied from class:ReductionDataCollectorFinalize 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)- Specified by:
setDatain classReductionDataCollector<SumCollector.SumData>- 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<SumCollector.SumData>- 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<SumCollector.SumData>- Returns:
- the expression string
-
-