Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Decode ¶
func Decode(t Type, src []byte, buf DecodeBuffer) (ret []byte, err error)
Decode returns the decoded form of src for the given compression type.
The buf allows passing various buffer implementations that make decoding more efficient. See NewSyncDecodeBuffer and NewConcurrentDecodeBuffer for further details. For non-zstd compression types, it is valid to pass nil buf.
Decode is concurrency-safe, however note the concurrency limits for the buffer of your choice.
func Encode ¶
func Encode(t Type, src []byte, buf EncodeBuffer) (ret []byte, err error)
Encode returns the encoded form of src for the given compression type. For None or empty message the encoding is not attempted.
The buf allows passing various buffer implementations that make encoding more efficient. See NewSyncEncodeBuffer and NewConcurrentEncodeBuffer for further details. For non-zstd compression types, it is valid to pass nil buf.
Encode is concurrency-safe, however note the concurrency limits for the buffer of your choice.
Types ¶
type DecodeBuffer ¶
type DecodeBuffer interface {
// contains filtered or unexported methods
}
func NewConcurrentDecodeBuffer ¶
func NewConcurrentDecodeBuffer() DecodeBuffer
NewConcurrentDecodeBuffer returns a buffer that can be used concurrently. NOTE: For Zstd compression a concurrency limit, equal to GOMAXPROCS is implied.
func NewSyncDecodeBuffer ¶
func NewSyncDecodeBuffer() DecodeBuffer
NewSyncDecodeBuffer returns synchronous buffer that can only be used on one decoding goroutine at once. Notably, the decoded byte slice returned by Decode is valid only until the next Decode call.
type EncodeBuffer ¶
type EncodeBuffer interface {
// contains filtered or unexported methods
}
func NewConcurrentEncodeBuffer ¶
func NewConcurrentEncodeBuffer() EncodeBuffer
NewConcurrentEncodeBuffer returns a buffer that can be used concurrently. NOTE: For Zstd compression, a concurrency limit equal to GOMAXPROCS is implied.
func NewSyncEncodeBuffer ¶
func NewSyncEncodeBuffer() EncodeBuffer
NewSyncEncodeBuffer returns synchronous buffer that can only be used on one encoding goroutine at once. Notably, the encoded byte slice returned by Encode is valid only until the next Encode call.
type Type ¶
type Type = string
Type represents a valid compression type supported by this package.
const ( // None represents no compression case. // None is the default when Type is empty. None Type = "none" // Snappy represents snappy block format. Snappy Type = "snappy" // Zstd represents "speed" mode of Zstd (Zstandard https://facebook.github.io/zstd/). // This is roughly equivalent to the default Zstandard mode (level 3). Zstd Type = "zstd" )