You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
71 lines
1.6 KiB
71 lines
1.6 KiB
package database
|
|
|
|
import (
|
|
octopus "gordenko.dev/dima/diploma"
|
|
"gordenko.dev/dima/diploma/chunkenc"
|
|
"gordenko.dev/dima/diploma/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) {
|
|
s.TimestampsBuf = conbuf.New(nil)
|
|
s.ValuesBuf = conbuf.New(nil)
|
|
//
|
|
s.Timestamps = chunkenc.NewReverseTimeDeltaOfDeltaCompressor(
|
|
s.TimestampsBuf, 0)
|
|
|
|
if s.MetricType == octopus.Cumulative {
|
|
s.Values = chunkenc.NewReverseCumulativeDeltaCompressor(
|
|
s.ValuesBuf, 0, s.FracDigits)
|
|
} else {
|
|
s.Values = chunkenc.NewReverseInstantDeltaCompressor(
|
|
s.ValuesBuf, 0, s.FracDigits)
|
|
}
|
|
|
|
s.Timestamps.Append(timestamp)
|
|
s.Values.Append(value)
|
|
|
|
s.Since = timestamp
|
|
s.SinceValue = value
|
|
s.Until = timestamp
|
|
s.UntilValue = value
|
|
}
|
|
|
|
func (s *_metric) DeleteMeasures() {
|
|
s.TimestampsBuf = conbuf.New(nil)
|
|
s.ValuesBuf = conbuf.New(nil)
|
|
//
|
|
s.Timestamps = chunkenc.NewReverseTimeDeltaOfDeltaCompressor(
|
|
s.TimestampsBuf, 0)
|
|
|
|
if s.MetricType == octopus.Cumulative {
|
|
s.Values = chunkenc.NewReverseCumulativeDeltaCompressor(
|
|
s.ValuesBuf, 0, s.FracDigits)
|
|
} else {
|
|
s.Values = chunkenc.NewReverseInstantDeltaCompressor(
|
|
s.ValuesBuf, 0, s.FracDigits)
|
|
}
|
|
|
|
s.RootPageNo = 0
|
|
s.LastPageNo = 0
|
|
s.Since = 0
|
|
s.SinceValue = 0
|
|
s.Until = 0
|
|
s.UntilValue = 0
|
|
}
|
|
|