Documentation ¶
Index ¶
- Variables
- type Decbuf
- func (d *Decbuf) Be32() uint32
- func (d *Decbuf) Be32int() int
- func (d *Decbuf) Be64() uint64
- func (d *Decbuf) Byte() byte
- func (d *Decbuf) CheckCrc32(castagnoliTable *crc32.Table)
- func (d *Decbuf) Close() error
- func (d *Decbuf) Err() error
- func (d *Decbuf) Len() int
- func (d *Decbuf) Position() int
- func (d *Decbuf) ResetAt(off int)
- func (d *Decbuf) Skip(l int)
- func (d *Decbuf) SkipUvarintBytes()
- func (d *Decbuf) UnsafeUvarintBytes() []byte
- func (d *Decbuf) Uvarint() int
- func (d *Decbuf) Uvarint64() uint64
- func (d *Decbuf) UvarintStr() string
- type DecbufFactory
- type DecbufFactoryMetrics
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidSize = errors.New("invalid size") ErrInvalidChecksum = errors.New("invalid checksum") )
var ErrPoolStopped = errors.New("file handle pool is stopped")
Functions ¶
This section is empty.
Types ¶
type Decbuf ¶
type Decbuf struct { E error // contains filtered or unexported fields }
Decbuf provides safe methods to extract data from a binary file. It does all necessary bounds checking and advancing of the binary file. Several datums can be extracted without checking for errors. However, before using any datum, the Err() method must be checked. New file-backed Decbuf instances must be created via DecbufFactory
func (*Decbuf) CheckCrc32 ¶
CheckCrc32 checks the integrity of the contents of this Decbuf, comparing the contents with the CRC32 checksum stored in the last four bytes. CheckCrc32 consumes the contents of this Decbuf.
func (*Decbuf) Position ¶
Position returns the current position of the underlying fileReader. Calling d.ResetAt(d.Position()) is effectively a no-op.
func (*Decbuf) ResetAt ¶
ResetAt sets the pointer of the underlying fileReader to the absolute offset and discards any buffered data. If E is non-nil, this method has no effect. ResetAt-ing beyond the end of the underlying fileReader will set E to an error and not advance the pointer of fileReader.
func (*Decbuf) Skip ¶
Skip advances the pointer of the underlying fileReader by the given number of bytes. If E is non-nil, this method has no effect. Skip-ing beyond the end of the underlying fileReader will set E to an error and not advance the pointer of the fileReader.
func (*Decbuf) SkipUvarintBytes ¶
func (d *Decbuf) SkipUvarintBytes()
SkipUvarintBytes advances the pointer of the underlying fileReader past the next varint-prefixed bytes. If E is non-nil, this method has no effect.
func (*Decbuf) UnsafeUvarintBytes ¶
UnsafeUvarintBytes reads varint prefixed bytes into a byte slice consuming them but without allocating. The bytes returned are NO LONGER VALID after subsequent reads from the Decbuf. If E is non-nil, this method returns an empty byte slice.
func (*Decbuf) UvarintStr ¶
UvarintStr reads varint prefixed bytes into a string and consumes them. The string returned allocates its own memory may be used after subsequent reads from the Decbuf. If E is non-nil, this method returns an empty string.
type DecbufFactory ¶
type DecbufFactory struct {
// contains filtered or unexported fields
}
DecbufFactory creates new file-backed decoding buffer instances for a specific index-header file.
func NewDecbufFactory ¶
func NewDecbufFactory(path string, maxIdleFileHandles uint, metrics *DecbufFactoryMetrics) *DecbufFactory
func (*DecbufFactory) NewDecbufAtChecked ¶
func (df *DecbufFactory) NewDecbufAtChecked(offset int, table *crc32.Table) Decbuf
NewDecbufAtChecked returns a new file-backed decoding buffer positioned at offset + 4 bytes. It expects the first 4 bytes after offset to hold the big endian encoded content length, followed by the contents and the expected checksum. This method checks the CRC of the content and will return an error Decbuf if it does not match the expected CRC.
func (*DecbufFactory) NewDecbufAtUnchecked ¶
func (df *DecbufFactory) NewDecbufAtUnchecked(offset int) Decbuf
NewDecbufAtUnchecked returns a new file-backed decoding buffer positioned at offset + 4 bytes. It expects the first 4 bytes after offset to hold the big endian encoded content length, followed by the contents and the expected checksum. This method does NOT compute the CRC of the content. To check the CRC of the content, use NewDecbufAtChecked.
func (*DecbufFactory) NewRawDecbuf ¶
func (df *DecbufFactory) NewRawDecbuf() Decbuf
NewRawDecbuf returns a new file-backed decoding buffer positioned at the beginning of the file, spanning the entire length of the file. It does not make any assumptions about the contents of the file, nor does it perform any form of integrity check. To create a decoding buffer for some subset of the file or perform integrity checks use NewDecbufAtUnchecked or NewDecbufAtChecked.
func (*DecbufFactory) Stop ¶
func (df *DecbufFactory) Stop()
Stop cleans up resources associated with this DecbufFactory
type DecbufFactoryMetrics ¶
type DecbufFactoryMetrics struct {
// contains filtered or unexported fields
}
func NewDecbufFactoryMetrics ¶
func NewDecbufFactoryMetrics(reg prometheus.Registerer) *DecbufFactoryMetrics