mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2026-05-17 08:36:55 +03:00
The encoding.DecompressZSTD* consistently updates the vm_zstd_block_decompress_calls_total metric.
Also make the follwing improvements after the commit 10f7cd2ffc:
- Add encoding.DecompressZSTDLimited() function and use it instead of zstd.DecompressLimited,
so it properly updates vm_zstd_block_decompress_calls_total metric.
- Clarify description for the encoding.DecompressZSTD* and zstd.Decompress* functions.
30 lines
893 B
Go
30 lines
893 B
Go
//go:build cgo
|
|
|
|
package zstd
|
|
|
|
import (
|
|
"github.com/valyala/gozstd"
|
|
)
|
|
|
|
// Decompress appends decompressed src to dst and returns the result.
|
|
//
|
|
// This function must be called only for the trusted src.
|
|
// Otherwise use DecompressLimited function.
|
|
func Decompress(dst, src []byte) ([]byte, error) {
|
|
return gozstd.Decompress(dst, src)
|
|
}
|
|
|
|
// Decompress appends decompressed src to dst and returns the result.
|
|
//
|
|
// If the decompressed result exceeds maxDataSizeBytes, then error is returned.
|
|
func DecompressLimited(dst, src []byte, maxDataSizeBytes int) ([]byte, error) {
|
|
return gozstd.DecompressLimited(dst, src, maxDataSizeBytes)
|
|
}
|
|
|
|
// CompressLevel appends compressed src to dst and returns the result.
|
|
//
|
|
// The given compressionLevel is used for the compression.
|
|
func CompressLevel(dst, src []byte, compressionLevel int) []byte {
|
|
return gozstd.CompressLevel(dst, src, compressionLevel)
|
|
}
|