wp
This commit is contained in:
@@ -7,7 +7,6 @@ import (
|
||||
|
||||
"gordenko.dev/dima/qb"
|
||||
"gordenko.dev/dima/qb/bin"
|
||||
"gordenko.dev/dima/qb/conbuf"
|
||||
)
|
||||
|
||||
type ReverseInstantDeltaCompressor struct {
|
||||
@@ -181,25 +180,26 @@ func (s *ReverseInstantDeltaCompressor) Offset() int {
|
||||
}
|
||||
|
||||
func (s *ReverseInstantDeltaCompressor) Snapshot() ([]byte, int) {
|
||||
if s.state == nil {
|
||||
return s.buf, s.Size()
|
||||
}
|
||||
// ВАЖЛИВО!
|
||||
// Треба відтворити стан останнього чанка
|
||||
var (
|
||||
pos = s.state.Pos
|
||||
chunk = make([]byte, conbuf.ChunkSize)
|
||||
lastChunkIdx = len(s.state.Chunks) - 1
|
||||
qtyToCopy = pos % conbuf.ChunkSize
|
||||
)
|
||||
copy(chunk, s.state.Chunks[lastChunkIdx][:qtyToCopy])
|
||||
chunks := append(s.state.Chunks[:lastChunkIdx], chunk)
|
||||
// if s.state == nil {
|
||||
// return s.buf, s.Size()
|
||||
// }
|
||||
// // ВАЖЛИВО!
|
||||
// // Треба відтворити стан останнього чанка
|
||||
// var (
|
||||
// pos = s.state.Pos
|
||||
// chunk = make([]byte, conbuf.ChunkSize)
|
||||
// lastChunkIdx = len(s.state.Chunks) - 1
|
||||
// qtyToCopy = pos % conbuf.ChunkSize
|
||||
// )
|
||||
// copy(chunk, s.state.Chunks[lastChunkIdx][:qtyToCopy])
|
||||
// chunks := append(s.state.Chunks[:lastChunkIdx], chunk)
|
||||
|
||||
buf := conbuf.New(chunks)
|
||||
pos += buf.ReversePutVarInt64(pos, s.state.LastDelta)
|
||||
buf.SetByte(pos, s.state.H)
|
||||
pos++
|
||||
return chunks, pos
|
||||
// buf := conbuf.New(chunks)
|
||||
// pos += buf.ReversePutVarInt64(pos, s.state.LastDelta)
|
||||
// buf.SetByte(pos, s.state.H)
|
||||
// pos++
|
||||
// return chunks, pos
|
||||
return nil, 0
|
||||
}
|
||||
|
||||
func (s *ReverseInstantDeltaCompressor) CreateDecompressor(fracDigits byte) qb.ValueDecompressor {
|
||||
|
||||
Reference in New Issue
Block a user