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) Write(d []byte) (n int, err error)
- func (compressor *Compressor) Written() int
- func (compressor *Compressor) WrittenBytes() []byte
- type Header
Constants ¶
const ( MaxInputSize = 1 << 22 // 4Mb MaxDictSize = 1 << 22 // 4Mb )
const ( SymbolDynamic byte = 0xFF SymbolShort byte = 0xFE )
const ( // Version is the current release version of the compressor. Version = 1 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 DictLen int // contains filtered or unexported fields }
func NewDynamicBackrefType ¶
func NewDynamicBackrefType(dictLen, addressableBytes int) (dynamic BackrefType)
func NewShortBackrefType ¶
func NewShortBackrefType() (short 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) (*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) 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
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. |