mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-22 22:30:23 +00:00
b044363a31
Bumps the github-dependencies group with 4 updates in the / directory: [github.com/aws/aws-sdk-go-v2/service/sts](https://github.com/aws/aws-sdk-go-v2), [github.com/kubernetes-csi/csi-lib-utils](https://github.com/kubernetes-csi/csi-lib-utils), [github.com/onsi/ginkgo/v2](https://github.com/onsi/ginkgo) and [github.com/prometheus/client_golang](https://github.com/prometheus/client_golang). Updates `github.com/aws/aws-sdk-go-v2/service/sts` from 1.30.3 to 1.30.4 - [Release notes](https://github.com/aws/aws-sdk-go-v2/releases) - [Commits](https://github.com/aws/aws-sdk-go-v2/compare/v1.30.3...v1.30.4) Updates `github.com/kubernetes-csi/csi-lib-utils` from 0.18.1 to 0.19.0 - [Release notes](https://github.com/kubernetes-csi/csi-lib-utils/releases) - [Commits](https://github.com/kubernetes-csi/csi-lib-utils/compare/v0.18.1...v0.19.0) Updates `github.com/onsi/ginkgo/v2` from 2.19.1 to 2.20.0 - [Release notes](https://github.com/onsi/ginkgo/releases) - [Changelog](https://github.com/onsi/ginkgo/blob/master/CHANGELOG.md) - [Commits](https://github.com/onsi/ginkgo/compare/v2.19.1...v2.20.0) Updates `github.com/prometheus/client_golang` from 1.19.1 to 1.20.1 - [Release notes](https://github.com/prometheus/client_golang/releases) - [Changelog](https://github.com/prometheus/client_golang/blob/v1.20.1/CHANGELOG.md) - [Commits](https://github.com/prometheus/client_golang/compare/v1.19.1...v1.20.1) --- updated-dependencies: - dependency-name: github.com/aws/aws-sdk-go-v2/service/sts dependency-type: direct:production update-type: version-update:semver-patch dependency-group: github-dependencies - dependency-name: github.com/kubernetes-csi/csi-lib-utils dependency-type: direct:production update-type: version-update:semver-minor dependency-group: github-dependencies - dependency-name: github.com/onsi/ginkgo/v2 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: github-dependencies - dependency-name: github.com/prometheus/client_golang dependency-type: direct:production update-type: version-update:semver-minor dependency-group: github-dependencies ... Signed-off-by: dependabot[bot] <support@github.com>
117 lines
2.9 KiB
Go
117 lines
2.9 KiB
Go
// Copyright 2019+ Klaus Post. All rights reserved.
|
|
// License information can be found in the LICENSE file.
|
|
// Based on work by Yann Collet, released under BSD License.
|
|
|
|
package zstd
|
|
|
|
import (
|
|
"github.com/klauspost/compress/huff0"
|
|
)
|
|
|
|
// history contains the information transferred between blocks.
|
|
type history struct {
|
|
// Literal decompression
|
|
huffTree *huff0.Scratch
|
|
|
|
// Sequence decompression
|
|
decoders sequenceDecs
|
|
recentOffsets [3]int
|
|
|
|
// History buffer...
|
|
b []byte
|
|
|
|
// ignoreBuffer is meant to ignore a number of bytes
|
|
// when checking for matches in history
|
|
ignoreBuffer int
|
|
|
|
windowSize int
|
|
allocFrameBuffer int // needed?
|
|
error bool
|
|
dict *dict
|
|
}
|
|
|
|
// reset will reset the history to initial state of a frame.
|
|
// The history must already have been initialized to the desired size.
|
|
func (h *history) reset() {
|
|
h.b = h.b[:0]
|
|
h.ignoreBuffer = 0
|
|
h.error = false
|
|
h.recentOffsets = [3]int{1, 4, 8}
|
|
h.decoders.freeDecoders()
|
|
h.decoders = sequenceDecs{br: h.decoders.br}
|
|
h.freeHuffDecoder()
|
|
h.huffTree = nil
|
|
h.dict = nil
|
|
//printf("history created: %+v (l: %d, c: %d)", *h, len(h.b), cap(h.b))
|
|
}
|
|
|
|
func (h *history) freeHuffDecoder() {
|
|
if h.huffTree != nil {
|
|
if h.dict == nil || h.dict.litEnc != h.huffTree {
|
|
huffDecoderPool.Put(h.huffTree)
|
|
h.huffTree = nil
|
|
}
|
|
}
|
|
}
|
|
|
|
func (h *history) setDict(dict *dict) {
|
|
if dict == nil {
|
|
return
|
|
}
|
|
h.dict = dict
|
|
h.decoders.litLengths = dict.llDec
|
|
h.decoders.offsets = dict.ofDec
|
|
h.decoders.matchLengths = dict.mlDec
|
|
h.decoders.dict = dict.content
|
|
h.recentOffsets = dict.offsets
|
|
h.huffTree = dict.litEnc
|
|
}
|
|
|
|
// append bytes to history.
|
|
// This function will make sure there is space for it,
|
|
// if the buffer has been allocated with enough extra space.
|
|
func (h *history) append(b []byte) {
|
|
if len(b) >= h.windowSize {
|
|
// Discard all history by simply overwriting
|
|
h.b = h.b[:h.windowSize]
|
|
copy(h.b, b[len(b)-h.windowSize:])
|
|
return
|
|
}
|
|
|
|
// If there is space, append it.
|
|
if len(b) < cap(h.b)-len(h.b) {
|
|
h.b = append(h.b, b...)
|
|
return
|
|
}
|
|
|
|
// Move data down so we only have window size left.
|
|
// We know we have less than window size in b at this point.
|
|
discard := len(b) + len(h.b) - h.windowSize
|
|
copy(h.b, h.b[discard:])
|
|
h.b = h.b[:h.windowSize]
|
|
copy(h.b[h.windowSize-len(b):], b)
|
|
}
|
|
|
|
// ensureBlock will ensure there is space for at least one block...
|
|
func (h *history) ensureBlock() {
|
|
if cap(h.b) < h.allocFrameBuffer {
|
|
h.b = make([]byte, 0, h.allocFrameBuffer)
|
|
return
|
|
}
|
|
|
|
avail := cap(h.b) - len(h.b)
|
|
if avail >= h.windowSize || avail > maxCompressedBlockSize {
|
|
return
|
|
}
|
|
// Move data down so we only have window size left.
|
|
// We know we have less than window size in b at this point.
|
|
discard := len(h.b) - h.windowSize
|
|
copy(h.b, h.b[discard:])
|
|
h.b = h.b[:h.windowSize]
|
|
}
|
|
|
|
// append bytes to history without ever discarding anything.
|
|
func (h *history) appendKeep(b []byte) {
|
|
h.b = append(h.b, b...)
|
|
}
|