Documentation ¶
Index ¶
- Constants
- func AugmentDict(dict []byte) []byte
- func Decompress(data, dict []byte) (d []byte, err error)
- type BackrefType
- type CompressionPhrase
- type CompressionPhrases
- type Compressor
- func (compressor *Compressor) Bytes() []byte
- func (compressor *Compressor) Compress(d []byte) (c []byte, err error)
- func (compressor *Compressor) CompressedSize256k(d []byte) (size int, err error)
- func (compressor *Compressor) ConsiderBypassing() (bypassed bool)
- func (compressor *Compressor) Len() int
- func (compressor *Compressor) Reset()
- func (compressor *Compressor) Revert() error
- func (compressor *Compressor) Stream() compress.Stream
- func (compressor *Compressor) Write(d []byte) (n int, err error)
- func (compressor *Compressor) Written() int
- func (compressor *Compressor) WrittenBytes() []byte
- type Header
- type Level
Constants ¶
const ( MaxInputSize = 1 << 21 // 2Mb MaxDictSize = 1 << 22 // 4Mb )
const ( SymbolDict byte = 0xFF SymbolShort byte = 0xFE SymbolLong byte = 0xFD )
const ( // Version is the current release version of the compressor. Version = 0 HeaderSize = 3 )
Variables ¶
This section is empty.
Functions ¶
func AugmentDict ¶
AugmentDict ensures the dictionary contains the special symbols
func Decompress ¶
Decompress decompresses the given data using the given dictionary the dictionary must be the same as the one used to compress the data Note that this is not a fail-safe decompressor, it will fail ungracefully if the data has a different format than the one expected
Types ¶
type BackrefType ¶
type BackrefType struct { Delimiter byte NbBitsAddress uint8 NbBitsLength uint8 NbBitsBackRef uint8 // contains filtered or unexported fields }
func InitBackRefTypes ¶
func InitBackRefTypes(dictLen int, level Level) (short, long, dict BackrefType)
type CompressionPhrase ¶
type CompressionPhrases ¶
type CompressionPhrases []CompressionPhrase
func CompressedStreamInfo ¶
func CompressedStreamInfo(c, dict []byte) (CompressionPhrases, error)
func (CompressionPhrases) ToCSV ¶
func (c CompressionPhrases) ToCSV() []byte
type Compressor ¶
type Compressor struct {
// contains filtered or unexported fields
}
func NewCompressor ¶
func NewCompressor(dict []byte, level Level) (*Compressor, error)
NewCompressor returns a new compressor with the given dictionary The dictionary is an unstructured sequence of substrings that are expected to occur frequently in the data. It is not included in the compressed data and should thus be a-priori known to both the compressor and the decompressor. The level determines the bit alignment of the compressed data. The "higher" the level, the better the compression ratio but the more constraints on the decompressor.
func (*Compressor) Bytes ¶
func (compressor *Compressor) Bytes() []byte
Bytes returns the compressed data
func (*Compressor) Compress ¶
func (compressor *Compressor) Compress(d []byte) (c []byte, err error)
Compress compresses the given data and returns the compressed data
func (*Compressor) CompressedSize256k ¶
func (compressor *Compressor) CompressedSize256k(d []byte) (size int, err error)
CompressedSize256k returns the size of the compressed data This is state less and thread-safe (but other methods are not) Max size of d is 256kB
func (*Compressor) ConsiderBypassing ¶
func (compressor *Compressor) ConsiderBypassing() (bypassed bool)
ConsiderBypassing switches to NoCompression if we get significant expansion instead of compression
func (*Compressor) Len ¶
func (compressor *Compressor) Len() int
Len returns the number of bytes compressed so far (includes the header)
func (*Compressor) Reset ¶
func (compressor *Compressor) Reset()
func (*Compressor) Revert ¶
func (compressor *Compressor) Revert() error
Revert undoes the last call to Write between any two calls to Revert, a call to Reset or Write should be made
func (*Compressor) Stream ¶
func (compressor *Compressor) Stream() compress.Stream
Stream returns a stream of the compressed data
func (*Compressor) Write ¶
func (compressor *Compressor) Write(d []byte) (n int, err error)
The compressor cannot recover from a Write error. It must be Reset before writing again
func (*Compressor) Written ¶
func (compressor *Compressor) Written() int
Written returns the number of bytes written to the compressor
func (*Compressor) WrittenBytes ¶
func (compressor *Compressor) WrittenBytes() []byte
WrittenBytes returns the bytes written to the compressor This returns a pointer to the internal buffer, so it should not be modified
type Header ¶
type Header struct { Version uint16 // compressor release version Level Level // compression level }
Header is the header of a compressed data. It contains the compressor release version and the compression level.
type Level ¶
type Level uint8
const ( NoCompression Level = 0 // BestCompression allows the compressor to produce a stream of bit-level granularity, // giving the compressor this freedom helps it achieve better compression ratios but // will impose a high number of constraints on the SNARK decompressor BestCompression Level = 1 GoodCompression Level = 2 GoodSnarkDecompression Level = 4 // BestSnarkDecompression forces the compressor to produce byte-aligned output. // It is convenient and efficient for the SNARK decompressor but can hurt the compression ratio significantly BestSnarkDecompression Level = 8 )
Directories ¶
Path | Synopsis |
---|---|
internal
|
|
suffixarray
Package suffixarray implements substring search in logarithmic time using an in-memory suffix array.
|
Package suffixarray implements substring search in logarithmic time using an in-memory suffix array. |