Implement transformNull
This commit is contained in:
@@ -60,6 +60,7 @@ func init() {
|
|||||||
"groupBy": applyGroupBy,
|
"groupBy": applyGroupBy,
|
||||||
"scale": applyScale,
|
"scale": applyScale,
|
||||||
"offset": applyOffset,
|
"offset": applyOffset,
|
||||||
|
"transformNull": applyTransformNull,
|
||||||
"percentile": applyPercentile,
|
"percentile": applyPercentile,
|
||||||
"timeShift": applyTimeShiftPost,
|
"timeShift": applyTimeShiftPost,
|
||||||
}
|
}
|
||||||
@@ -202,6 +203,16 @@ func applyOffset(series timeseries.TimeSeries, params ...interface{}) (timeserie
|
|||||||
return series.Transform(transformFunc), nil
|
return series.Transform(transformFunc), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func applyTransformNull(series timeseries.TimeSeries, params ...interface{}) (timeseries.TimeSeries, error) {
|
||||||
|
nullValue, err := MustFloat64(params[0])
|
||||||
|
if err != nil {
|
||||||
|
return nil, errParsingFunctionParam(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
transformFunc := timeseries.TransformNull(nullValue)
|
||||||
|
return series.Transform(transformFunc), nil
|
||||||
|
}
|
||||||
|
|
||||||
func applyAggregateBy(series []*timeseries.TimeSeriesData, params ...interface{}) ([]*timeseries.TimeSeriesData, error) {
|
func applyAggregateBy(series []*timeseries.TimeSeriesData, params ...interface{}) ([]*timeseries.TimeSeriesData, error) {
|
||||||
pInterval, err := MustString(params[0])
|
pInterval, err := MustString(params[0])
|
||||||
pAgg, err := MustString(params[1])
|
pAgg, err := MustString(params[1])
|
||||||
|
|||||||
@@ -14,6 +14,12 @@ func TransformOffset(offset float64) TransformFunc {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TransformNull(nullValue float64) TransformFunc {
|
||||||
|
return func(point TimePoint) TimePoint {
|
||||||
|
return transformNull(point, nullValue)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TransformShiftTime(interval time.Duration) TransformFunc {
|
func TransformShiftTime(interval time.Duration) TransformFunc {
|
||||||
return func(point TimePoint) TimePoint {
|
return func(point TimePoint) TimePoint {
|
||||||
return transformShiftTime(point, interval)
|
return transformShiftTime(point, interval)
|
||||||
@@ -41,3 +47,10 @@ func transformShiftTime(point TimePoint, interval time.Duration) TimePoint {
|
|||||||
point.Time = shiftedTime
|
point.Time = shiftedTime
|
||||||
return point
|
return point
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func transformNull(point TimePoint, nullValue float64) TimePoint {
|
||||||
|
if point.Value == nil {
|
||||||
|
point.Value = &nullValue
|
||||||
|
}
|
||||||
|
return point
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user