reference

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 7, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IndexHeader     = "s2idx\x00"
	IndexTrailer    = "\x00xdi2s"
	MaxIndexEntries = 1 << 16
)
View Source
const (
	ChunkLegacyCompressed = 0x00
	ChunkUncompressed     = 0x01
	ChunkMinLZBlock       = 0x02
	ChunkMinLZCompCRC     = 0x03
	ChunkIndex            = 0x40
	ChunkEOF              = 0x20
	ChunkPadding          = 0xfe
	ChunkStreamID         = 0xff
)

Variables

This section is empty.

Functions

func DecodeBlock

func DecodeBlock(src []byte) (dst []byte, err error)

DecodeBlock is a reference implementation of the MinLZ block decoder. This implementation is not optimized for speed, but for readability with no dependencies.

func EncodeBlock

func EncodeBlock(src []byte) ([]byte, error)

EncodeBlock is a reference implementation of the MinLZ block decoder. This implementation is not optimized for speed nor efficiency, but for readability with no dependencies. See 'encodeBlockGo' for a more optimal encoder.

func MaxEncodedLen

func MaxEncodedLen(srcLen int) int

MaxEncodedLen returns the maximum length of a snappy block, given its uncompressed length.

It will return a negative value if srcLen is too large to encode.

func ReadStream

func ReadStream(r io.Reader, debugOut io.Writer) error

Types

type Index

type Index struct {
	TotalUncompressed int64 // Total Uncompressed size.
	TotalCompressed   int64 // Total Compressed size if known. Will be -1 if unknown.

	// Compressed -> Uncompressed map of block start positions.
	// Not all blocks will be in here
	Blocks []struct {
		CompressedOffset   int64
		UncompressedOffset int64
	}
	// contains filtered or unexported fields
}

Index represents a MinLZ index.

func LoadIndex

func LoadIndex(b []byte) (*Index, error)

LoadIndex will load and parse a complete index.

func LoadIndexAfterHeader

func LoadIndexAfterHeader(b []byte) (*Index, error)

LoadIndexAfterHeader will load and parse an index, after the stream header has been parsed.

Jump to

Keyboard shortcuts

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