2019-07-10 09:57:27 +00:00
|
|
|
package promql
|
|
|
|
|
|
|
|
import (
|
|
|
|
"math"
|
|
|
|
"strings"
|
|
|
|
"sync"
|
2019-12-08 22:52:31 +00:00
|
|
|
|
2020-04-28 12:28:22 +00:00
|
|
|
"github.com/VictoriaMetrics/metricsql"
|
2019-07-10 09:57:27 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// callbacks for optimized incremental calculations for aggregate functions
|
2019-12-25 19:35:47 +00:00
|
|
|
// over rollups over metricsql.MetricExpr.
|
2019-07-10 09:57:27 +00:00
|
|
|
//
|
|
|
|
// These calculations save RAM for aggregates over big number of time series.
|
|
|
|
var incrementalAggrFuncCallbacksMap = map[string]*incrementalAggrFuncCallbacks{
|
|
|
|
"sum": {
|
|
|
|
updateAggrFunc: updateAggrSum,
|
2019-07-12 12:51:02 +00:00
|
|
|
mergeAggrFunc: mergeAggrSum,
|
2019-07-10 09:57:27 +00:00
|
|
|
finalizeAggrFunc: finalizeAggrCommon,
|
|
|
|
},
|
|
|
|
"min": {
|
|
|
|
updateAggrFunc: updateAggrMin,
|
2019-07-12 12:51:02 +00:00
|
|
|
mergeAggrFunc: mergeAggrMin,
|
2019-07-10 09:57:27 +00:00
|
|
|
finalizeAggrFunc: finalizeAggrCommon,
|
|
|
|
},
|
|
|
|
"max": {
|
|
|
|
updateAggrFunc: updateAggrMax,
|
2019-07-12 12:51:02 +00:00
|
|
|
mergeAggrFunc: mergeAggrMax,
|
2019-07-10 09:57:27 +00:00
|
|
|
finalizeAggrFunc: finalizeAggrCommon,
|
|
|
|
},
|
|
|
|
"avg": {
|
|
|
|
updateAggrFunc: updateAggrAvg,
|
2019-07-12 12:51:02 +00:00
|
|
|
mergeAggrFunc: mergeAggrAvg,
|
2019-07-10 09:57:27 +00:00
|
|
|
finalizeAggrFunc: finalizeAggrAvg,
|
|
|
|
},
|
|
|
|
"count": {
|
|
|
|
updateAggrFunc: updateAggrCount,
|
2019-07-12 12:51:02 +00:00
|
|
|
mergeAggrFunc: mergeAggrCount,
|
2019-07-10 09:57:27 +00:00
|
|
|
finalizeAggrFunc: finalizeAggrCount,
|
|
|
|
},
|
|
|
|
"sum2": {
|
|
|
|
updateAggrFunc: updateAggrSum2,
|
2019-07-12 12:51:02 +00:00
|
|
|
mergeAggrFunc: mergeAggrSum2,
|
2019-07-10 09:57:27 +00:00
|
|
|
finalizeAggrFunc: finalizeAggrCommon,
|
|
|
|
},
|
|
|
|
"geomean": {
|
|
|
|
updateAggrFunc: updateAggrGeomean,
|
2019-07-12 12:51:02 +00:00
|
|
|
mergeAggrFunc: mergeAggrGeomean,
|
2019-07-10 09:57:27 +00:00
|
|
|
finalizeAggrFunc: finalizeAggrGeomean,
|
|
|
|
},
|
2020-05-12 16:45:42 +00:00
|
|
|
"any": {
|
|
|
|
updateAggrFunc: updateAggrAny,
|
|
|
|
mergeAggrFunc: mergeAggrAny,
|
|
|
|
finalizeAggrFunc: finalizeAggrCommon,
|
|
|
|
},
|
2019-07-10 09:57:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type incrementalAggrFuncContext struct {
|
2019-12-25 19:35:47 +00:00
|
|
|
ae *metricsql.AggrFuncExpr
|
2019-07-10 09:57:27 +00:00
|
|
|
|
2019-07-12 12:51:02 +00:00
|
|
|
mLock sync.Mutex
|
|
|
|
m map[uint]map[string]*incrementalAggrContext
|
2019-07-10 09:57:27 +00:00
|
|
|
|
|
|
|
callbacks *incrementalAggrFuncCallbacks
|
|
|
|
}
|
|
|
|
|
2019-12-25 19:35:47 +00:00
|
|
|
func newIncrementalAggrFuncContext(ae *metricsql.AggrFuncExpr, callbacks *incrementalAggrFuncCallbacks) *incrementalAggrFuncContext {
|
2019-07-10 09:57:27 +00:00
|
|
|
return &incrementalAggrFuncContext{
|
|
|
|
ae: ae,
|
2019-07-12 12:51:02 +00:00
|
|
|
m: make(map[uint]map[string]*incrementalAggrContext),
|
2019-07-10 09:57:27 +00:00
|
|
|
callbacks: callbacks,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-12 12:51:02 +00:00
|
|
|
func (iafc *incrementalAggrFuncContext) updateTimeseries(ts *timeseries, workerID uint) {
|
|
|
|
iafc.mLock.Lock()
|
|
|
|
m := iafc.m[workerID]
|
|
|
|
if m == nil {
|
|
|
|
m = make(map[string]*incrementalAggrContext, 1)
|
|
|
|
iafc.m[workerID] = m
|
|
|
|
}
|
|
|
|
iafc.mLock.Unlock()
|
|
|
|
|
2019-07-10 09:57:27 +00:00
|
|
|
removeGroupTags(&ts.MetricName, &iafc.ae.Modifier)
|
|
|
|
bb := bbPool.Get()
|
|
|
|
bb.B = marshalMetricNameSorted(bb.B[:0], &ts.MetricName)
|
2019-07-12 12:51:02 +00:00
|
|
|
iac := m[string(bb.B)]
|
2019-07-10 09:57:27 +00:00
|
|
|
if iac == nil {
|
2020-05-12 16:06:54 +00:00
|
|
|
if iafc.ae.Limit > 0 && len(m) >= iafc.ae.Limit {
|
|
|
|
// Skip this time series, since the limit on the number of output time series has been already reached.
|
|
|
|
return
|
|
|
|
}
|
2019-07-10 09:57:27 +00:00
|
|
|
tsAggr := ×eries{
|
|
|
|
Values: make([]float64, len(ts.Values)),
|
|
|
|
Timestamps: ts.Timestamps,
|
|
|
|
denyReuse: true,
|
|
|
|
}
|
|
|
|
tsAggr.MetricName.CopyFrom(&ts.MetricName)
|
|
|
|
iac = &incrementalAggrContext{
|
|
|
|
ts: tsAggr,
|
|
|
|
values: make([]float64, len(ts.Values)),
|
|
|
|
}
|
2019-07-12 12:51:02 +00:00
|
|
|
m[string(bb.B)] = iac
|
2019-07-10 09:57:27 +00:00
|
|
|
}
|
|
|
|
bbPool.Put(bb)
|
2019-07-12 12:51:02 +00:00
|
|
|
iafc.callbacks.updateAggrFunc(iac, ts.Values)
|
2019-07-10 09:57:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (iafc *incrementalAggrFuncContext) finalizeTimeseries() []*timeseries {
|
2019-07-12 12:51:02 +00:00
|
|
|
// There is no need in iafc.mLock.Lock here, since finalizeTimeseries must be called
|
2019-07-10 09:57:27 +00:00
|
|
|
// without concurrent goroutines touching iafc.
|
2019-07-12 12:51:02 +00:00
|
|
|
mGlobal := make(map[string]*incrementalAggrContext)
|
|
|
|
mergeAggrFunc := iafc.callbacks.mergeAggrFunc
|
|
|
|
for _, m := range iafc.m {
|
|
|
|
for k, iac := range m {
|
|
|
|
iacGlobal := mGlobal[k]
|
|
|
|
if iacGlobal == nil {
|
2020-05-12 16:06:54 +00:00
|
|
|
if iafc.ae.Limit > 0 && len(mGlobal) >= iafc.ae.Limit {
|
|
|
|
// Skip this time series, since the limit on the number of output time series has been already reached.
|
|
|
|
continue
|
|
|
|
}
|
2019-07-12 12:51:02 +00:00
|
|
|
mGlobal[k] = iac
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
mergeAggrFunc(iacGlobal, iac)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
tss := make([]*timeseries, 0, len(mGlobal))
|
2019-07-10 09:57:27 +00:00
|
|
|
finalizeAggrFunc := iafc.callbacks.finalizeAggrFunc
|
2019-07-12 12:51:02 +00:00
|
|
|
for _, iac := range mGlobal {
|
2019-07-10 09:57:27 +00:00
|
|
|
finalizeAggrFunc(iac)
|
|
|
|
tss = append(tss, iac.ts)
|
|
|
|
}
|
|
|
|
return tss
|
|
|
|
}
|
|
|
|
|
|
|
|
type incrementalAggrFuncCallbacks struct {
|
|
|
|
updateAggrFunc func(iac *incrementalAggrContext, values []float64)
|
2019-07-12 12:51:02 +00:00
|
|
|
mergeAggrFunc func(dst, src *incrementalAggrContext)
|
2019-07-10 09:57:27 +00:00
|
|
|
finalizeAggrFunc func(iac *incrementalAggrContext)
|
|
|
|
}
|
|
|
|
|
|
|
|
func getIncrementalAggrFuncCallbacks(name string) *incrementalAggrFuncCallbacks {
|
|
|
|
name = strings.ToLower(name)
|
|
|
|
return incrementalAggrFuncCallbacksMap[name]
|
|
|
|
}
|
|
|
|
|
|
|
|
type incrementalAggrContext struct {
|
|
|
|
ts *timeseries
|
|
|
|
values []float64
|
|
|
|
}
|
|
|
|
|
|
|
|
func finalizeAggrCommon(iac *incrementalAggrContext) {
|
|
|
|
counts := iac.values
|
|
|
|
dstValues := iac.ts.Values
|
|
|
|
_ = dstValues[len(counts)-1]
|
|
|
|
for i, v := range counts {
|
|
|
|
if v == 0 {
|
|
|
|
dstValues[i] = nan
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func updateAggrSum(iac *incrementalAggrContext, values []float64) {
|
|
|
|
dstValues := iac.ts.Values
|
|
|
|
dstCounts := iac.values
|
|
|
|
_ = dstValues[len(values)-1]
|
|
|
|
_ = dstCounts[len(values)-1]
|
|
|
|
for i, v := range values {
|
|
|
|
if math.IsNaN(v) {
|
|
|
|
continue
|
|
|
|
}
|
2019-07-12 12:51:02 +00:00
|
|
|
if dstCounts[i] == 0 {
|
|
|
|
dstValues[i] = v
|
|
|
|
dstCounts[i] = 1
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
dstValues[i] += v
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func mergeAggrSum(dst, src *incrementalAggrContext) {
|
|
|
|
srcValues := src.ts.Values
|
|
|
|
dstValues := dst.ts.Values
|
|
|
|
srcCounts := src.values
|
|
|
|
dstCounts := dst.values
|
|
|
|
_ = srcCounts[len(srcValues)-1]
|
|
|
|
_ = dstCounts[len(srcValues)-1]
|
|
|
|
_ = dstValues[len(srcValues)-1]
|
|
|
|
for i, v := range srcValues {
|
|
|
|
if srcCounts[i] == 0 {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
if dstCounts[i] == 0 {
|
|
|
|
dstValues[i] = v
|
|
|
|
dstCounts[i] = 1
|
|
|
|
continue
|
|
|
|
}
|
2019-07-10 09:57:27 +00:00
|
|
|
dstValues[i] += v
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func updateAggrMin(iac *incrementalAggrContext, values []float64) {
|
|
|
|
dstValues := iac.ts.Values
|
|
|
|
dstCounts := iac.values
|
|
|
|
_ = dstValues[len(values)-1]
|
|
|
|
_ = dstCounts[len(values)-1]
|
|
|
|
for i, v := range values {
|
|
|
|
if math.IsNaN(v) {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
if dstCounts[i] == 0 {
|
|
|
|
dstValues[i] = v
|
|
|
|
dstCounts[i] = 1
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
if v < dstValues[i] {
|
|
|
|
dstValues[i] = v
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-12 12:51:02 +00:00
|
|
|
func mergeAggrMin(dst, src *incrementalAggrContext) {
|
|
|
|
srcValues := src.ts.Values
|
|
|
|
dstValues := dst.ts.Values
|
|
|
|
srcCounts := src.values
|
|
|
|
dstCounts := dst.values
|
|
|
|
_ = srcCounts[len(srcValues)-1]
|
|
|
|
_ = dstCounts[len(srcValues)-1]
|
|
|
|
_ = dstValues[len(srcValues)-1]
|
|
|
|
for i, v := range srcValues {
|
|
|
|
if srcCounts[i] == 0 {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
if dstCounts[i] == 0 {
|
|
|
|
dstValues[i] = v
|
|
|
|
dstCounts[i] = 1
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
if v < dstValues[i] {
|
|
|
|
dstValues[i] = v
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-10 09:57:27 +00:00
|
|
|
func updateAggrMax(iac *incrementalAggrContext, values []float64) {
|
|
|
|
dstValues := iac.ts.Values
|
|
|
|
dstCounts := iac.values
|
|
|
|
_ = dstValues[len(values)-1]
|
|
|
|
_ = dstCounts[len(values)-1]
|
|
|
|
for i, v := range values {
|
|
|
|
if math.IsNaN(v) {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
if dstCounts[i] == 0 {
|
|
|
|
dstValues[i] = v
|
|
|
|
dstCounts[i] = 1
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
if v > dstValues[i] {
|
|
|
|
dstValues[i] = v
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-12 12:51:02 +00:00
|
|
|
func mergeAggrMax(dst, src *incrementalAggrContext) {
|
|
|
|
srcValues := src.ts.Values
|
|
|
|
dstValues := dst.ts.Values
|
|
|
|
srcCounts := src.values
|
|
|
|
dstCounts := dst.values
|
|
|
|
_ = srcCounts[len(srcValues)-1]
|
|
|
|
_ = dstCounts[len(srcValues)-1]
|
|
|
|
_ = dstValues[len(srcValues)-1]
|
|
|
|
for i, v := range srcValues {
|
|
|
|
if srcCounts[i] == 0 {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
if dstCounts[i] == 0 {
|
|
|
|
dstValues[i] = v
|
|
|
|
dstCounts[i] = 1
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
if v > dstValues[i] {
|
|
|
|
dstValues[i] = v
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-10 09:57:27 +00:00
|
|
|
func updateAggrAvg(iac *incrementalAggrContext, values []float64) {
|
|
|
|
// Do not use `Rapid calculation methods` at https://en.wikipedia.org/wiki/Standard_deviation,
|
|
|
|
// since it is slower and has no obvious benefits in increased precision.
|
|
|
|
dstValues := iac.ts.Values
|
|
|
|
dstCounts := iac.values
|
|
|
|
_ = dstValues[len(values)-1]
|
|
|
|
_ = dstCounts[len(values)-1]
|
|
|
|
for i, v := range values {
|
|
|
|
if math.IsNaN(v) {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
if dstCounts[i] == 0 {
|
|
|
|
dstValues[i] = v
|
|
|
|
dstCounts[i] = 1
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
dstValues[i] += v
|
|
|
|
dstCounts[i]++
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-12 12:51:02 +00:00
|
|
|
func mergeAggrAvg(dst, src *incrementalAggrContext) {
|
|
|
|
srcValues := src.ts.Values
|
|
|
|
dstValues := dst.ts.Values
|
|
|
|
srcCounts := src.values
|
|
|
|
dstCounts := dst.values
|
|
|
|
_ = srcCounts[len(srcValues)-1]
|
|
|
|
_ = dstCounts[len(srcValues)-1]
|
|
|
|
_ = dstValues[len(srcValues)-1]
|
|
|
|
for i, v := range srcValues {
|
|
|
|
if srcCounts[i] == 0 {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
if dstCounts[i] == 0 {
|
|
|
|
dstValues[i] = v
|
|
|
|
dstCounts[i] = srcCounts[i]
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
dstValues[i] += v
|
|
|
|
dstCounts[i] += srcCounts[i]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-10 09:57:27 +00:00
|
|
|
func finalizeAggrAvg(iac *incrementalAggrContext) {
|
|
|
|
dstValues := iac.ts.Values
|
|
|
|
counts := iac.values
|
|
|
|
_ = dstValues[len(counts)-1]
|
|
|
|
for i, v := range counts {
|
|
|
|
if v == 0 {
|
|
|
|
dstValues[i] = nan
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
dstValues[i] /= v
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func updateAggrCount(iac *incrementalAggrContext, values []float64) {
|
|
|
|
dstValues := iac.ts.Values
|
|
|
|
_ = dstValues[len(values)-1]
|
|
|
|
for i, v := range values {
|
|
|
|
if math.IsNaN(v) {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
dstValues[i]++
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-12 12:51:02 +00:00
|
|
|
func mergeAggrCount(dst, src *incrementalAggrContext) {
|
|
|
|
srcValues := src.ts.Values
|
|
|
|
dstValues := dst.ts.Values
|
|
|
|
_ = dstValues[len(srcValues)-1]
|
|
|
|
for i, v := range srcValues {
|
|
|
|
dstValues[i] += v
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-10 09:57:27 +00:00
|
|
|
func finalizeAggrCount(iac *incrementalAggrContext) {
|
2019-07-25 19:02:03 +00:00
|
|
|
dstValues := iac.ts.Values
|
|
|
|
for i, v := range dstValues {
|
|
|
|
if v == 0 {
|
|
|
|
dstValues[i] = nan
|
|
|
|
}
|
|
|
|
}
|
2019-07-10 09:57:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func updateAggrSum2(iac *incrementalAggrContext, values []float64) {
|
|
|
|
dstValues := iac.ts.Values
|
|
|
|
dstCounts := iac.values
|
|
|
|
_ = dstValues[len(values)-1]
|
|
|
|
_ = dstCounts[len(values)-1]
|
|
|
|
for i, v := range values {
|
|
|
|
if math.IsNaN(v) {
|
|
|
|
continue
|
|
|
|
}
|
2019-07-12 12:51:02 +00:00
|
|
|
if dstCounts[i] == 0 {
|
|
|
|
dstValues[i] = v * v
|
|
|
|
dstCounts[i] = 1
|
|
|
|
continue
|
|
|
|
}
|
2019-07-10 09:57:27 +00:00
|
|
|
dstValues[i] += v * v
|
2019-07-12 12:51:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func mergeAggrSum2(dst, src *incrementalAggrContext) {
|
|
|
|
srcValues := src.ts.Values
|
|
|
|
dstValues := dst.ts.Values
|
|
|
|
srcCounts := src.values
|
|
|
|
dstCounts := dst.values
|
|
|
|
_ = srcCounts[len(srcValues)-1]
|
|
|
|
_ = dstCounts[len(srcValues)-1]
|
|
|
|
_ = dstValues[len(srcValues)-1]
|
|
|
|
for i, v := range srcValues {
|
|
|
|
if srcCounts[i] == 0 {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
if dstCounts[i] == 0 {
|
|
|
|
dstValues[i] = v
|
|
|
|
dstCounts[i] = 1
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
dstValues[i] += v
|
2019-07-10 09:57:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func updateAggrGeomean(iac *incrementalAggrContext, values []float64) {
|
|
|
|
dstValues := iac.ts.Values
|
|
|
|
dstCounts := iac.values
|
|
|
|
_ = dstValues[len(values)-1]
|
|
|
|
_ = dstCounts[len(values)-1]
|
|
|
|
for i, v := range values {
|
|
|
|
if math.IsNaN(v) {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
if dstCounts[i] == 0 {
|
|
|
|
dstValues[i] = v
|
|
|
|
dstCounts[i] = 1
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
dstValues[i] *= v
|
|
|
|
dstCounts[i]++
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-12 12:51:02 +00:00
|
|
|
func mergeAggrGeomean(dst, src *incrementalAggrContext) {
|
|
|
|
srcValues := src.ts.Values
|
|
|
|
dstValues := dst.ts.Values
|
|
|
|
srcCounts := src.values
|
|
|
|
dstCounts := dst.values
|
|
|
|
_ = srcCounts[len(srcValues)-1]
|
|
|
|
_ = dstCounts[len(srcValues)-1]
|
|
|
|
_ = dstValues[len(srcValues)-1]
|
|
|
|
for i, v := range srcValues {
|
|
|
|
if srcCounts[i] == 0 {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
if dstCounts[i] == 0 {
|
|
|
|
dstValues[i] = v
|
|
|
|
dstCounts[i] = srcCounts[i]
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
dstValues[i] *= v
|
|
|
|
dstCounts[i] += srcCounts[i]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-10 09:57:27 +00:00
|
|
|
func finalizeAggrGeomean(iac *incrementalAggrContext) {
|
|
|
|
dstValues := iac.ts.Values
|
|
|
|
counts := iac.values
|
|
|
|
_ = dstValues[len(counts)-1]
|
|
|
|
for i, v := range counts {
|
|
|
|
if v == 0 {
|
|
|
|
dstValues[i] = nan
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
dstValues[i] = math.Pow(dstValues[i], 1/v)
|
|
|
|
}
|
|
|
|
}
|
2020-05-12 16:45:42 +00:00
|
|
|
|
|
|
|
func updateAggrAny(iac *incrementalAggrContext, values []float64) {
|
|
|
|
dstValues := iac.ts.Values
|
|
|
|
dstCounts := iac.values
|
|
|
|
if dstCounts[0] > 0 {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
dstCounts[0] = 1
|
|
|
|
dstValues = append(dstValues[:0], values...)
|
|
|
|
}
|
|
|
|
|
|
|
|
func mergeAggrAny(dst, src *incrementalAggrContext) {
|
|
|
|
srcValues := src.ts.Values
|
|
|
|
dstValues := dst.ts.Values
|
|
|
|
srcCounts := src.values
|
|
|
|
dstCounts := dst.values
|
|
|
|
if dstCounts[0] > 0 {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
dstCounts[0] = srcCounts[0]
|
|
|
|
dstValues = append(dstValues[:0], srcValues...)
|
|
|
|
}
|