This commit is contained in:
2026-06-10 06:18:45 +03:00
parent 4089ca40c9
commit 9ec86282ad
47 changed files with 3493 additions and 4502 deletions

View File

@@ -48,18 +48,15 @@ type CumulativeDeltaCompressor struct {
}
// Після відновлення із снапшота
func NewCumulativeDeltaCompressor(buf []byte, fracDigits byte) *CumulativeDeltaCompressor {
func NewCumulativeDeltaCompressor(fracDigits byte, buf []byte, payloadSize int) *CumulativeDeltaCompressor {
var coef float64 = 1
if fracDigits > 0 {
coef = math.Pow(10, float64(fracDigits))
}
return &CumulativeDeltaCompressor{
s := &CumulativeDeltaCompressor{
buf: buf,
coef: coef,
}
}
func (s *CumulativeDeltaCompressor) RestoreState(payloadSize int) {
if payloadSize > 0 {
s.pos = payloadSize - 1 // завжди показує на h
// base value на початку
@@ -74,16 +71,27 @@ func (s *CumulativeDeltaCompressor) RestoreState(payloadSize int) {
log.Fatalf("bug: get last delta: %s", err)
}
}
return s
}
// func (s *CumulativeDeltaCompressor) RestoreState() {
// }
// func (s *CumulativeDeltaCompressor) Size() int {
// return s.pos
// }
type EvaluationReport struct {
CompressionWay int
TotalSpace int
AdditionalSpace int
Delta uint64
}
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
// fix - requiredSpace - all space
if s.pos > 0 {
if s.h < 128 {
// run