zstd

package
v1.24.0-dev Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 16, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package zstd provides a high-level API for reading and writing zstd-compressed data. It supports both regular and seekable zstd streams. It's not a new wheel, but a wrapper around the zstd and zstd-seekable-format-go packages.

Index

Constants

This section is empty.

Variables

View Source
var (
	WithEncoderCRC               = zstd.WithEncoderCRC
	WithEncoderConcurrency       = zstd.WithEncoderConcurrency
	WithWindowSize               = zstd.WithWindowSize
	WithEncoderPadding           = zstd.WithEncoderPadding
	WithEncoderLevel             = zstd.WithEncoderLevel
	WithZeroFrames               = zstd.WithZeroFrames
	WithAllLitEntropyCompression = zstd.WithAllLitEntropyCompression
	WithNoEntropyCompression     = zstd.WithNoEntropyCompression
	WithSingleSegment            = zstd.WithSingleSegment
	WithLowerEncoderMem          = zstd.WithLowerEncoderMem
	WithEncoderDict              = zstd.WithEncoderDict
	WithEncoderDictRaw           = zstd.WithEncoderDictRaw
)
View Source
var (
	WithDecoderLowmem      = zstd.WithDecoderLowmem
	WithDecoderConcurrency = zstd.WithDecoderConcurrency
	WithDecoderMaxMemory   = zstd.WithDecoderMaxMemory
	WithDecoderDicts       = zstd.WithDecoderDicts
	WithDecoderDictRaw     = zstd.WithDecoderDictRaw
	WithDecoderMaxWindow   = zstd.WithDecoderMaxWindow
	WithDecodeAllCapLimit  = zstd.WithDecodeAllCapLimit
	WithDecodeBuffersBelow = zstd.WithDecodeBuffersBelow
	IgnoreChecksum         = zstd.IgnoreChecksum
)

Functions

This section is empty.

Types

type EncoderLevel

type EncoderLevel = zstd.EncoderLevel
const (
	SpeedFastest           EncoderLevel = zstd.SpeedFastest
	SpeedDefault           EncoderLevel = zstd.SpeedDefault
	SpeedBetterCompression EncoderLevel = zstd.SpeedBetterCompression
	SpeedBestCompression   EncoderLevel = zstd.SpeedBestCompression
)

type Reader

type Reader zstd.Decoder

func NewReader

func NewReader(r io.Reader, opts ...ReaderOption) (*Reader, error)

NewReader returns a new zstd reader.

func (*Reader) Close

func (r *Reader) Close() error

func (*Reader) Read

func (r *Reader) Read(p []byte) (int, error)

type ReaderOption

type ReaderOption = zstd.DOption

type SeekableReader

type SeekableReader struct {
	// contains filtered or unexported fields
}

func NewSeekableReader

func NewSeekableReader(r io.ReadSeeker, opts ...ReaderOption) (*SeekableReader, error)

NewSeekableReader returns a zstd reader to decompress data from seekable format.

func (*SeekableReader) Close

func (r *SeekableReader) Close() error

func (*SeekableReader) Read

func (r *SeekableReader) Read(p []byte) (int, error)

func (*SeekableReader) Seek

func (r *SeekableReader) Seek(offset int64, whence int) (int64, error)

type SeekableWriter

type SeekableWriter struct {
	// contains filtered or unexported fields
}

func NewSeekableWriter

func NewSeekableWriter(w io.Writer, blockSize int, opts ...WriterOption) (*SeekableWriter, error)

NewSeekableWriter returns a zstd writer to compress data to seekable format. blockSize is an important parameter, it should be decided according to the actual business requirements. If it's too small, the compression ratio could be very bad, even no compression at all. If it's too large, it could cost more traffic when reading the data partially from underlying storage.

func (*SeekableWriter) Close

func (w *SeekableWriter) Close() error

func (*SeekableWriter) Write

func (w *SeekableWriter) Write(p []byte) (int, error)

type Writer

type Writer zstd.Encoder

func NewWriter

func NewWriter(w io.Writer, opts ...WriterOption) (*Writer, error)

NewWriter returns a new zstd writer.

func (*Writer) Close

func (w *Writer) Close() error

func (*Writer) Write

func (w *Writer) Write(p []byte) (int, error)

type WriterOption

type WriterOption = zstd.EOption

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL