Implement transformNull

This commit is contained in:
Alexander Zobnin
2021-05-27 16:47:18 +03:00
parent 2a5b12e43a
commit ef7681f689
2 changed files with 29 additions and 5 deletions

View File

@@ -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 {
return func(point TimePoint) TimePoint {
return transformShiftTime(point, interval)
@@ -41,3 +47,10 @@ func transformShiftTime(point TimePoint, interval time.Duration) TimePoint {
point.Time = shiftedTime
return point
}
func transformNull(point TimePoint, nullValue float64) TimePoint {
if point.Value == nil {
point.Value = &nullValue
}
return point
}