This commit is contained in:
2026-05-31 20:01:28 +00:00
parent e7ec6083cb
commit db5ecd3dfd
28 changed files with 2090 additions and 2155 deletions

View File

@@ -4,23 +4,23 @@ import (
"errors"
"fmt"
octopus "gordenko.dev/dima/qb"
"gordenko.dev/dima/qb"
"gordenko.dev/dima/qb/bin"
"gordenko.dev/dima/qb/enc"
)
type BackwardCursor struct {
metricType octopus.MetricType
metricType qb.MetricType
fracDigits byte
atree *Atree
pageNo uint32
pageData []byte
timestampDecompressor octopus.TimestampDecompressor
valueDecompressor octopus.ValueDecompressor
timestampDecompressor qb.TimestampDecompressor
valueDecompressor qb.ValueDecompressor
}
type BackwardCursorOptions struct {
MetricType octopus.MetricType
MetricType qb.MetricType
FracDigits byte
PageNo uint32
PageData []byte
@@ -29,12 +29,12 @@ type BackwardCursorOptions struct {
func NewBackwardCursor(opt BackwardCursorOptions) (*BackwardCursor, error) {
switch opt.MetricType {
case octopus.Instant, octopus.Cumulative:
case qb.Instant, qb.Cumulative:
// ok
default:
return nil, fmt.Errorf("MetricType option has wrong value: %d", opt.MetricType)
}
if opt.FracDigits > octopus.MaxFracDigits {
if opt.FracDigits > qb.MaxFracDigits {
return nil, errors.New("FracDigits option is required")
}
if opt.Atree == nil {
@@ -137,11 +137,11 @@ func (s *BackwardCursor) makeDecompressors() error {
vbuf := s.pageData[timestampsPayloadSize : timestampsPayloadSize+valuesPayloadSize]
switch s.metricType {
case octopus.Instant:
case qb.Instant:
s.valueDecompressor = enc.NewReverseInstantDeltaDecompressor(
vbuf, s.fracDigits)
case octopus.Cumulative:
case qb.Cumulative:
s.valueDecompressor = enc.NewReverseCumulativeDeltaDecompressor(
vbuf, s.fracDigits)
@@ -151,8 +151,8 @@ func (s *BackwardCursor) makeDecompressors() error {
return nil
}
func makeDecompressors(pageData []byte, metricType octopus.MetricType, fracDigits byte) (
octopus.TimestampDecompressor, octopus.ValueDecompressor, error,
func makeDecompressors(pageData []byte, metricType qb.MetricType, fracDigits byte) (
qb.TimestampDecompressor, qb.ValueDecompressor, error,
) {
timestampsPayloadSize := bin.GetUint16(pageData[timestampsSizeIdx:])
valuesPayloadSize := bin.GetUint16(pageData[valuesSizeIdx:])
@@ -170,13 +170,13 @@ func makeDecompressors(pageData []byte, metricType octopus.MetricType, fracDigit
vbuf := pageData[timestampsPayloadSize : timestampsPayloadSize+valuesPayloadSize]
var valueDecompressor octopus.ValueDecompressor
var valueDecompressor qb.ValueDecompressor
switch metricType {
case octopus.Instant:
case qb.Instant:
valueDecompressor = enc.NewReverseInstantDeltaDecompressor(
vbuf, fracDigits)
case octopus.Cumulative:
case qb.Cumulative:
valueDecompressor = enc.NewReverseCumulativeDeltaDecompressor(
vbuf, fracDigits)