compression

package
v0.4.9 Latest Latest
Warning

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

Go to latest
Published: May 12, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package compression provides compression support for JVS snapshots. It supports gzip compression at configurable levels for snapshot data.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompressedPath

func CompressedPath(path string) string

CompressedPath returns the compressed path for a file.

func DecompressDir

func DecompressDir(root string) (int, error)

DecompressDir decompresses only files listed in the root .READY compression manifest. User-owned .gz files and symlinks are left untouched. Returns the count of decompressed files and any error.

func DecompressFile

func DecompressFile(path string) (string, error)

DecompressFile decompresses a .gz file and returns the decompressed path. If the file is not compressed, returns the original path.

func IsCompressedFile

func IsCompressedFile(path string) bool

IsCompressedFile returns true if the file path indicates a compressed file.

func UncompressedPath

func UncompressedPath(path string) string

UncompressedPath returns the uncompressed path for a file.

Types

type CompressionLevel

type CompressionLevel int

CompressionLevel represents the compression level.

const (
	// LevelNone disables compression.
	LevelNone CompressionLevel = 0
	// LevelFast uses fastest compression (gzip level 1).
	LevelFast CompressionLevel = 1
	// LevelDefault uses default compression (gzip level 6).
	LevelDefault CompressionLevel = 6
	// LevelMax uses maximum compression (gzip level 9).
	LevelMax CompressionLevel = 9
)

type CompressionType

type CompressionType string

CompressionType represents the compression algorithm.

const (
	// TypeGzip uses gzip compression.
	TypeGzip CompressionType = "gzip"
	// TypeNone indicates no compression.
	TypeNone CompressionType = "none"
)

type Compressor

type Compressor struct {
	Type  CompressionType
	Level CompressionLevel
}

Compressor handles compression operations.

func NewCompressor

func NewCompressor(level CompressionLevel) *Compressor

NewCompressor creates a new compressor with the specified level. Level 0 means no compression.

func NewCompressorFromString

func NewCompressorFromString(level string) (*Compressor, error)

NewCompressorFromString creates a compressor from a string level. Valid values: "none", "fast", "default", "max"

func (*Compressor) CompressDir

func (c *Compressor) CompressDir(root string) (int, error)

CompressDir compresses eligible regular files in a snapshot directory tree and records the compressed paths in the root .READY marker. Returns the count of compressed files and any error.

func (*Compressor) CompressFile

func (c *Compressor) CompressFile(path string) (string, error)

CompressFile compresses a file and returns the compressed path. The compressed file has a .gz extension added. If compression is disabled, returns the original path.

func (*Compressor) IsEnabled

func (c *Compressor) IsEnabled() bool

IsEnabled returns true if compression is enabled.

func (*Compressor) String

func (c *Compressor) String() string

String returns the string representation of the compressor.

type MaterializedSizePlan

type MaterializedSizePlan struct {
	OriginalBytes           int64
	ConsumedCompressedPaths []string
}

func PlanMaterializedSize

func PlanMaterializedSize(root string) (*MaterializedSizePlan, error)

type SnapshotCompressionInfo

type SnapshotCompressionInfo struct {
	Type  CompressionType  `json:"type,omitempty"`
	Level CompressionLevel `json:"level,omitempty"`
}

SnapshotCompressionInfo stores compression metadata in the descriptor.

func CompressionInfoFromLevel

func CompressionInfoFromLevel(level string) (*SnapshotCompressionInfo, error)

CompressionInfoFromLevel creates compression info from a level string.

func (*SnapshotCompressionInfo) String

func (ci *SnapshotCompressionInfo) String() string

String returns the string representation of the compression info.

Jump to

Keyboard shortcuts

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