encoding

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package encoding implements encoding/decoding data points.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BufferWriter added in v0.3.0

type BufferWriter interface {
	Write(data []byte) (n int, err error)
	WriteByte(b byte) error
	Bytes() []byte
}

BufferWriter allows writing a variable-sized buffer of bytes.

type Packer added in v0.3.0

type Packer struct {
	// contains filtered or unexported fields
}

Packer writes data into a buffer.

func NewPacker added in v0.3.0

func NewPacker(buf BufferWriter) *Packer

NewPacker returns a new Writer.

func (*Packer) Bytes added in v0.3.0

func (w *Packer) Bytes() []byte

Bytes outputs the data in the buffer.

func (*Packer) PutUint16 added in v0.3.0

func (w *Packer) PutUint16(v uint16)

PutUint16 puts uint16 data into the buffer.

func (*Packer) PutUint32 added in v0.3.0

func (w *Packer) PutUint32(v uint32)

PutUint32 puts uint32 data into the buffer.

func (*Packer) PutUint64 added in v0.3.0

func (w *Packer) PutUint64(v uint64)

PutUint64 puts uint64 data into the buffer.

func (*Packer) Write added in v0.3.0

func (w *Packer) Write(p []byte)

Write binaries to the buffer.

type ParseInterval

type ParseInterval = func(key []byte) time.Duration

ParseInterval parses the interval rule from the key in a kv pair.

type Reader added in v0.3.0

type Reader struct {
	// contains filtered or unexported fields
}

Reader reads bits from buffer.

func NewReader added in v0.3.0

func NewReader(in io.ByteReader) *Reader

NewReader crate bit reader.

func (*Reader) ReadBits added in v0.3.0

func (r *Reader) ReadBits(numBits int) (uint64, error)

ReadBits read number of bits.

func (*Reader) ReadBool added in v0.3.0

func (r *Reader) ReadBool() (bool, error)

ReadBool reads a bit, 1 returns true, 0 returns false.

func (*Reader) ReadByte added in v0.3.0

func (r *Reader) ReadByte() (byte, error)

ReadByte reads a byte.

func (*Reader) Reset added in v0.3.0

func (r *Reader) Reset()

Reset resets the reader to read from a new slice.

type SeriesDecoder

type SeriesDecoder interface {
	// Decode the time series data
	Decode(key, data []byte) error
	// Len denotes the size of iterator
	Len() int
	// IsFull returns whether the encoded data reached its capacity
	IsFull() bool
	// Get the data point by its time
	Get(ts uint64) ([]byte, error)
	// Iterator returns a SeriesIterator
	Iterator() SeriesIterator
	// Range returns the start and end time of this series
	Range() (start, end uint64)
}

SeriesDecoder decodes encoded time series data.

type SeriesDecoderPool

type SeriesDecoderPool interface {
	Get(metadata []byte) SeriesDecoder
	Put(encoder SeriesDecoder)
}

SeriesDecoderPool allows putting and getting SeriesDecoder.

func NewDecoderPool added in v0.3.0

func NewDecoderPool(name string, size int, fn ParseInterval) SeriesDecoderPool

NewDecoderPool returns a SeriesDecoderPool which provides int-based xor decoders.

type SeriesEncoder

type SeriesEncoder interface {
	// Append a data point
	Append(ts uint64, value []byte)
	// IsFull returns whether the encoded data reached its capacity
	IsFull() bool
	// Reset the underlying buffer
	Reset(key []byte, buffer BufferWriter)
	// Encode the time series data point to a binary
	Encode() error
	// StartTime indicates the first entry's time
	StartTime() uint64
}

SeriesEncoder encodes time series data point.

type SeriesEncoderPool

type SeriesEncoderPool interface {
	Get(metadata []byte, buffer BufferWriter) SeriesEncoder
	Put(encoder SeriesEncoder)
}

SeriesEncoderPool allows putting and getting SeriesEncoder.

func NewEncoderPool added in v0.3.0

func NewEncoderPool(name string, size int, fn ParseInterval) SeriesEncoderPool

NewEncoderPool returns a SeriesEncoderPool which provides int-based xor encoders.

type SeriesIterator

type SeriesIterator interface {
	// Next scroll the cursor to the next
	Next() bool
	// Val returns the value of the current data point
	Val() []byte
	// Time returns the time of the current data point
	Time() uint64
	// Error might return an error indicates a decode failure
	Error() error
}

SeriesIterator iterates time series data.

type Writer added in v0.3.0

type Writer struct {
	// contains filtered or unexported fields
}

Writer writes bits to an io.BufferWriter.

func NewWriter added in v0.3.0

func NewWriter() *Writer

NewWriter create bit writer.

func (*Writer) Flush added in v0.3.0

func (w *Writer) Flush()

Flush flushes the currently in-process byte.

func (*Writer) Reset added in v0.3.0

func (w *Writer) Reset(buffer BufferWriter)

Reset writes to a new writer.

func (*Writer) WriteBits added in v0.3.0

func (w *Writer) WriteBits(u uint64, numBits int)

WriteBits writes number of bits.

func (*Writer) WriteBool added in v0.3.0

func (w *Writer) WriteBool(b bool)

WriteBool writes a boolean value true: 1 false: 0

func (*Writer) WriteByte added in v0.3.0

func (w *Writer) WriteByte(b byte) error

WriteByte write a byte.

type XORDecoder

type XORDecoder struct {
	// contains filtered or unexported fields
}

XORDecoder decodes buffer to uint64 values using xor compress.

func NewXORDecoder

func NewXORDecoder(br *Reader) *XORDecoder

NewXORDecoder create zstdDecoder decompress buffer using xor.

func (*XORDecoder) Err

func (d *XORDecoder) Err() error

Err returns error raised in Next().

func (*XORDecoder) Next

func (d *XORDecoder) Next() bool

Next return if zstdDecoder has value in buffer using xor, do uncompress logic in next method, data format reference zstdEncoder format.

func (*XORDecoder) Reset

func (d *XORDecoder) Reset()

Reset resets the underlying buffer to decode.

func (*XORDecoder) Value

func (d *XORDecoder) Value() uint64

Value returns uint64 from buffer.

type XOREncoder

type XOREncoder struct {
	// contains filtered or unexported fields
}

XOREncoder intends to compress uint64 data https://www.vldb.org/pvldb/vol8/p1816-teller.pdf

func NewXOREncoder

func NewXOREncoder(bw *Writer) *XOREncoder

NewXOREncoder creates xor zstdEncoder for compressing uint64 data.

func (*XOREncoder) Write

func (e *XOREncoder) Write(val uint64)

Jump to

Keyboard shortcuts

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