| 1596 | } |
| 1597 | |
| 1598 | func NewSimpleCombiner(req *tempopb.QueryRangeRequest, op SimpleAggregationOp) *SimpleAggregator { |
| 1599 | var initWithNaN bool |
| 1600 | var f func(existingValue float64, newValue float64) float64 |
| 1601 | switch op { |
| 1602 | case minOverTimeAggregation: |
| 1603 | // Simple min aggregator. It calculates the minimum between existing values and a new sample |
| 1604 | f = minOverTime() |
| 1605 | initWithNaN = true |
| 1606 | case maxOverTimeAggregation: |
| 1607 | // Simple max aggregator. It calculates the maximum between existing values and a new sample |
| 1608 | f = maxOverTime() |
| 1609 | initWithNaN = true |
| 1610 | case sumOverTimeAggregation: |
| 1611 | f = sumOverTime() |
| 1612 | initWithNaN = true |
| 1613 | default: |
| 1614 | // Simple addition aggregator. It adds existing values with the new sample. |
| 1615 | f = func(existingValue float64, newValue float64) float64 { return existingValue + newValue } |
| 1616 | initWithNaN = false |
| 1617 | |
| 1618 | } |
| 1619 | return &SimpleAggregator{ |
| 1620 | ss: make(SeriesSet), |
| 1621 | exemplarBuckets: newExemplarBucketSet(req.Exemplars, req.Start, req.End, req.Step, IsInstant(req)), |
| 1622 | intervalMapper: NewIntervalMapperFromReq(req), |
| 1623 | aggregationFunc: f, |
| 1624 | initWithNaN: initWithNaN, |
| 1625 | } |
| 1626 | } |
| 1627 | |
| 1628 | func (b *SimpleAggregator) Combine(in []*tempopb.TimeSeries) { |
| 1629 | nan := math.Float64frombits(normalNaN) |