package matchfinder

Import Path
	github.com/andybalholm/brotli/matchfinder (on go.dev)

Dependency Relation
	imports 8 packages, and imported by one package

Involved Source Files emitter.go m0.go m4.go The matchfinder package defines reusable components for data compression. Many compression libraries have two main parts: - Something that looks for repeated sequences of bytes - An encoder for the compressed data format (often an entropy coder) Although these are logically two separate steps, the implementations are usually closely tied together. You can't use flate's matcher with snappy's encoder, for example. This package defines interfaces and an intermediate representation to allow mixing and matching compression components. pathfinder.go textencoder.go
Package-Level Type Names (total 10)
/* sort by: | */
AutoReset wraps a MatchFinder that can return references to data in previous blocks, and calls Reset before each block. It is useful for (e.g.) using a snappy Encoder with a MatchFinder designed for flate. (Snappy doesn't support references between blocks.) MatchFinder MatchFinder ( AutoReset) FindMatches(dst []Match, src []byte) []Match Reset clears any internal state, preparing the MatchFinder to be used with a new stream. AutoReset : MatchFinder
An Encoder encodes the data in its final format. Encode appends the encoded format of src to dst, using the match information from matches. Reset clears any internal state, preparing the Encoder to be used with a new stream. TextEncoder *github.com/andybalholm/brotli.Encoder
M0 is an implementation of the MatchFinder interface based on the algorithm used by snappy, but modified to be more like the algorithm used by compression level 0 of the brotli reference implementation. It has a maximum block size of 65536 bytes. Lazy turns on "lazy matching," for higher compression but less speed. MaxDistance int MaxLength int FindMatches looks for matches in src, appends them to dst, and returns dst. src must not be longer than 65536 bytes. ( M0) Reset() M0 : MatchFinder
M4 is an implementation of the MatchFinder interface that uses a hash table to find matches, optional match chains, and the advanced parsing technique from https://fastcompression.blogspot.com/2011/12/advanced-parsing-strategies.html. ChainLength is how many entries to search on the "match chain" of older locations with the same hash as the current location. DistanceBitCost is used when comparing two matches to see which is better. The comparison is primarily based on the length of the matches, but it can also take the distance into account, in terms of the number of bits needed to represent the distance. One byte of length is given a score of 256, so 32 (256/8) would be a reasonable first guess for the value of one bit. (The default is 0, which bases the comparison solely on length.) HashLen is the number of bytes to use to calculate the hashes. The maximum is 8 and the default is 6. MaxDistance is the maximum distance (in bytes) to look back for a match. The default is 65535. MinLength is the length of the shortest match to return. The default is 4. TableBits is the number of bits in the hash table indexes. The default is 17 (128K entries). (*M4) FindMatches(dst []Match, src []byte) []Match (*M4) Reset() *M4 : MatchFinder
A Match is the basic unit of LZ77 compression. // how far back in the stream to copy from // the number of bytes in the matched string; it may be 0 at the end of the input // the number of unmatched bytes since the previous match func AutoReset.FindMatches(dst []Match, src []byte) []Match func M0.FindMatches(dst []Match, src []byte) []Match func (*M4).FindMatches(dst []Match, src []byte) []Match func MatchFinder.FindMatches(dst []Match, src []byte) []Match func NoMatchFinder.FindMatches(dst []Match, src []byte) []Match func (*Pathfinder).FindMatches(dst []Match, src []byte) []Match func AutoReset.FindMatches(dst []Match, src []byte) []Match func Encoder.Encode(dst []byte, src []byte, matches []Match, lastBlock bool) []byte func M0.FindMatches(dst []Match, src []byte) []Match func (*M4).FindMatches(dst []Match, src []byte) []Match func MatchFinder.FindMatches(dst []Match, src []byte) []Match func NoMatchFinder.FindMatches(dst []Match, src []byte) []Match func (*Pathfinder).FindMatches(dst []Match, src []byte) []Match func TextEncoder.Encode(dst []byte, src []byte, matches []Match, lastBlock bool) []byte func github.com/andybalholm/brotli.(*Encoder).Encode(dst []byte, src []byte, matches []Match, lastBlock bool) []byte
A MatchFinder performs the LZ77 stage of compression, looking for matches. FindMatches looks for matches in src, appends them to dst, and returns dst. Reset clears any internal state, preparing the MatchFinder to be used with a new stream. AutoReset M0 *M4 NoMatchFinder *Pathfinder
A NoMatchFinder implements MatchFinder, but doesn't find any matches. It can be used to implement the equivalent of the standard library flate package's HuffmanOnly setting. ( NoMatchFinder) FindMatches(dst []Match, src []byte) []Match ( NoMatchFinder) Reset() NoMatchFinder : MatchFinder
Pathfinder is a MatchFinder that uses hash chains to find matches, and a shortest-path optimizer to choose which matches to use. ChainLength is how many entries to search on the "match chain" of older locations with the same hash as the current location. HashLen is the number of bytes to use to calculate the hashes. The maximum is 8 and the default is 6. MaxDistance is the maximum distance (in bytes) to look back for a match. The default is 65535. MinLength is the length of the shortest match to return. The default is 4. TableBits is the number of bits in the hash table indexes. The default is 17 (128K entries). (*Pathfinder) FindMatches(dst []Match, src []byte) []Match (*Pathfinder) Reset() *Pathfinder : MatchFinder
A TextEncoder is an Encoder that produces a human-readable representation of the LZ77 compression. Matches are replaced with <Length,Distance> symbols. ( TextEncoder) Encode(dst []byte, src []byte, matches []Match, lastBlock bool) []byte ( TextEncoder) Reset() TextEncoder : Encoder
A Writer uses MatchFinder and Encoder to write compressed data to Dest. BlockSize is the number of bytes to compress at a time. If it is zero, each Write operation will be treated as one block. Dest io.Writer Encoder Encoder MatchFinder MatchFinder (*Writer) Close() error (*Writer) Reset(newDest io.Writer) (*Writer) Write(p []byte) (n int, err error) *Writer : github.com/miekg/dns.Writer *Writer : github.com/parquet-go/parquet-go/compress.Writer *Writer : github.com/prometheus/common/expfmt.Closer *Writer : internal/bisect.Writer *Writer : io.Closer *Writer : io.WriteCloser *Writer : io.Writer func github.com/andybalholm/brotli.NewWriterV2(dst io.Writer, level int) *Writer