wp
This commit is contained in:
@@ -34,15 +34,12 @@ type TimeDeltaCompressor struct {
|
||||
// а lastDelta і h треба прочитати із payload (якщо є)
|
||||
|
||||
// Кодує значення справа наліво функціями TailPut*. Читає значення зліва направо функціями Get*
|
||||
func NewTimeDeltaCompressor(buf []byte) *TimeDeltaCompressor {
|
||||
return &TimeDeltaCompressor{
|
||||
func NewTimeDeltaCompressor(buf []byte, payloadSize int) *TimeDeltaCompressor {
|
||||
s := &TimeDeltaCompressor{
|
||||
buf: buf,
|
||||
}
|
||||
}
|
||||
|
||||
func (s *TimeDeltaCompressor) RestoreState(payloadSize int, lastTimestamp uint32) {
|
||||
if payloadSize > 0 {
|
||||
s.lastUnixtime = lastTimestamp
|
||||
//s.lastUnixtime = lastTimestamp
|
||||
s.pos = len(s.buf) - payloadSize
|
||||
if payloadSize > 4 {
|
||||
s.h = s.buf[s.pos]
|
||||
@@ -53,8 +50,14 @@ func (s *TimeDeltaCompressor) RestoreState(payloadSize int, lastTimestamp uint32
|
||||
s.lastDelta = uint32(u64)
|
||||
}
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
// FIX - restire lastUnixtime
|
||||
// func (s *TimeDeltaCompressor) RestoreState() {
|
||||
|
||||
// }
|
||||
|
||||
// retrun
|
||||
func (s *TimeDeltaCompressor) Evaluate(unixtime uint32) (compressionWay int, requiredSpace int) {
|
||||
requiredSpace = len(s.buf) - s.pos
|
||||
|
||||
Reference in New Issue
Block a user