This commit is contained in:
2026-06-11 01:46:25 +00:00
parent 9ec86282ad
commit 09f270aa6f
5 changed files with 770 additions and 335 deletions

View File

@@ -86,9 +86,14 @@ type EvaluationReport struct {
CompressionWay int
TotalSpace int
AdditionalSpace int
Offset int
BytesCount int
Delta uint64
}
// можна виділити буфер максимального розміру, що може бути змінено під час кодування
// закодувати на етапі evaluate значення і повернути buf + offset. Причому буфер може бути
// спільний на всі metrics
func (s *CumulativeDeltaCompressor) Evaluate(value float64) (compressionWay int, requiredSpace int) {
delta := uint64((value-s.baseValue)*s.coef + eps) // fix - if delta 0, no eps
requiredSpace = s.pos
@@ -97,9 +102,13 @@ func (s *CumulativeDeltaCompressor) Evaluate(value float64) (compressionWay int,
// run
if delta == s.lastDelta && s.h < 127 {
compressionWay = incrementRun
// offset = s.pos
// bytesCount = 1
} else {
compressionWay = endSeries
requiredSpace += bin.CountVarUint64(uint64(delta)) + hSize
// offset = s.pos + 1
// bytesCount = bin.CountVarUint64(uint64(delta)) + hSize
}
} else {
// literal
@@ -107,6 +116,8 @@ func (s *CumulativeDeltaCompressor) Evaluate(value float64) (compressionWay int,
if s.h < 255 {
compressionWay = incrementLiteral
requiredSpace += bin.CountVarUint64(uint64(delta))
// offset = s.pos
// bytesCount = bin.CountVarUint64(uint64(delta)) // hSize просто переміщається
} else {
compressionWay = endSeries
requiredSpace += bin.CountVarUint64(uint64(delta)) + hSize
@@ -114,6 +125,7 @@ func (s *CumulativeDeltaCompressor) Evaluate(value float64) (compressionWay int,
} else {
compressionWay = startRun
if s.h > 128 {
// offset = s.pos - 1 - bin.CountVarUint64(uint64(delta))
requiredSpace += hSize // h - end of run
}
}