Files
qb/database/metric.go

72 lines
1.7 KiB
Go
Raw Normal View History

2026-02-10 14:02:11 +00:00
package database
import (
octopus "gordenko.dev/dima/qb"
"gordenko.dev/dima/qb/conbuf"
)
// METRIC
type _metric struct {
MetricType octopus.MetricType
FracDigits byte
RootPageNo uint32
LastPageNo uint32
SinceValue float64
Since uint32
UntilValue float64
Until uint32
TimestampsBuf *conbuf.ContinuousBuffer
ValuesBuf *conbuf.ContinuousBuffer
Timestamps octopus.TimestampCompressor
Values octopus.ValueCompressor
}
func (s *_metric) ReinitBy(timestamp uint32, value float64) {
2026-05-10 00:59:47 +00:00
// s.TimestampsBuf = conbuf.New(nil)
// s.ValuesBuf = conbuf.New(nil)
// //
// s.Timestamps = chunkenc.NewReverseTimeDeltaOfDeltaCompressor(
// s.TimestampsBuf, 0)
2026-02-10 14:02:11 +00:00
2026-05-10 00:59:47 +00:00
// if s.MetricType == octopus.Cumulative {
// s.Values = chunkenc.NewReverseCumulativeDeltaCompressor(
// s.ValuesBuf, 0, s.FracDigits)
// } else {
// s.Values = chunkenc.NewReverseInstantDeltaCompressor(
// s.ValuesBuf, 0, s.FracDigits)
// }
2026-02-10 14:02:11 +00:00
2026-05-10 00:59:47 +00:00
// s.Timestamps.Append(timestamp)
// s.Values.Append(value)
2026-02-10 14:02:11 +00:00
2026-05-10 00:59:47 +00:00
// s.Since = timestamp
// s.SinceValue = value
// s.Until = timestamp
// s.UntilValue = value
2026-02-10 14:02:11 +00:00
}
func (s *_metric) DeleteMeasures() {
s.TimestampsBuf = conbuf.New(nil)
s.ValuesBuf = conbuf.New(nil)
2026-05-10 00:59:47 +00:00
// fix
// s.Timestamps = chunkenc.NewReverseTimeDeltaOfDeltaCompressor(
// s.TimestampsBuf, 0)
2026-02-10 14:02:11 +00:00
2026-05-10 00:59:47 +00:00
// if s.MetricType == octopus.Cumulative {
// s.Values = chunkenc.NewReverseCumulativeDeltaCompressor(
// s.ValuesBuf, 0, s.FracDigits)
// } else {
// s.Values = chunkenc.NewReverseInstantDeltaCompressor(
// s.ValuesBuf, 0, s.FracDigits)
// }
// END OF FIX
2026-02-10 14:02:11 +00:00
s.RootPageNo = 0
s.LastPageNo = 0
s.Since = 0
s.SinceValue = 0
s.Until = 0
s.UntilValue = 0
}