Documentation
¶
Overview ¶
Package encoding implements encoding/decoding data points.
Index ¶
- func BytesToInt64(src []byte) int64
- func BytesToInt64List(dst []int64, src []byte, mt EncodeType, firstValue int64, itemsCount int) ([]int64, error)
- func BytesToUint16(src []byte) uint16
- func BytesToUint32(src []byte) uint32
- func BytesToUint64(src []byte) uint64
- func BytesToVarInt64(src []byte) ([]byte, int64, error)
- func BytesToVarInt64List(dst []int64, src []byte) ([]byte, error)
- func BytesToVarUint64(src []byte) ([]byte, uint64, error)
- func BytesToVarUint64s(dst []uint64, src []byte) ([]byte, error)
- func DecodeBytes(src []byte) ([]byte, []byte, error)
- func EncodeBytes(dst, b []byte) []byte
- func EncodeBytesBlock(dst []byte, a [][]byte) []byte
- func Int64ToBytes(dst []byte, v int64) []byte
- func ReleaseInt64List(is *Int64List)
- func ReleaseUint64List(is *Uint64List)
- func Uint16ToBytes(dst []byte, u uint16) []byte
- func Uint32ToBytes(dst []byte, u uint32) []byte
- func Uint64ToBytes(dst []byte, u uint64) []byte
- func VarInt64ListToBytes(dst []byte, vs []int64) []byte
- func VarInt64ToBytes(dst []byte, v int64) []byte
- func VarUint64ToBytes(dst []byte, u uint64) []byte
- func VarUint64sToBytes(dst []byte, us []uint64) []byte
- type BufferWriter
- type BytesBlockDecoder
- type EncodeType
- type Int64List
- type Packer
- type ParseInterval
- type Reader
- type SeriesDecoder
- type SeriesDecoderPool
- type SeriesEncoder
- type SeriesEncoderPool
- type SeriesIterator
- type Uint64List
- type Writer
- type XORDecoder
- type XOREncoder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BytesToInt64 ¶ added in v0.6.0
BytesToInt64 converts the first eight bytes of the given byte slice to an int64.
func BytesToInt64List ¶ added in v0.6.0
func BytesToInt64List(dst []int64, src []byte, mt EncodeType, firstValue int64, itemsCount int) ([]int64, error)
BytesToInt64List decodes bytes into a list of int64.
func BytesToUint16 ¶ added in v0.6.0
BytesToUint16 converts the first two bytes of the given byte slice to a uint16.
func BytesToUint32 ¶ added in v0.6.0
BytesToUint32 converts the first four bytes of the given byte slice to a uint32.
func BytesToUint64 ¶ added in v0.6.0
BytesToUint64 converts the first eight bytes of the given byte slice to a uint64.
func BytesToVarInt64 ¶ added in v0.6.0
BytesToVarInt64 converts the first bytes of the given byte slice to an int64. It uses variable-length encoding.
func BytesToVarInt64List ¶ added in v0.6.0
BytesToVarInt64List converts the first bytes of the given byte slice to an int64s. It uses variable-length encoding.
func BytesToVarUint64 ¶ added in v0.6.0
BytesToVarUint64 converts the first bytes of the given byte slice to a uint64. It uses variable-length encoding.
func BytesToVarUint64s ¶ added in v0.6.0
BytesToVarUint64s converts the first bytes of the given byte slice to a uint64s. It uses variable-length encoding.
func DecodeBytes ¶ added in v0.6.0
DecodeBytes decodes a string from src.
func EncodeBytes ¶ added in v0.6.0
EncodeBytes encodes a string into dst.
func EncodeBytesBlock ¶ added in v0.6.0
EncodeBytesBlock encodes a block of strings into dst.
func Int64ToBytes ¶ added in v0.6.0
Int64ToBytes appends the bytes of the given int64 to the given byte slice.
func ReleaseInt64List ¶ added in v0.6.0
func ReleaseInt64List(is *Int64List)
ReleaseInt64List releases the given list of int64. The list may be put into a pool for reuse.
func ReleaseUint64List ¶ added in v0.6.0
func ReleaseUint64List(is *Uint64List)
ReleaseUint64List releases the given list of uint64. The list may be put into a pool for reuse.
func Uint16ToBytes ¶ added in v0.6.0
Uint16ToBytes appends the bytes of the given uint16 to the given byte slice.
func Uint32ToBytes ¶ added in v0.6.0
Uint32ToBytes appends the bytes of the given uint32 to the given byte slice.
func Uint64ToBytes ¶ added in v0.6.0
Uint64ToBytes appends the bytes of the given uint64 to the given byte slice.
func VarInt64ListToBytes ¶ added in v0.6.0
VarInt64ListToBytes appends the bytes of the given int64s to the given byte slice. It uses variable-length encoding.
func VarInt64ToBytes ¶ added in v0.6.0
VarInt64ToBytes appends the bytes of the given int64 to the given byte slice. It uses variable-length encoding.
func VarUint64ToBytes ¶ added in v0.6.0
VarUint64ToBytes appends the bytes of the given uint64 to the given byte slice. It uses variable-length encoding.
func VarUint64sToBytes ¶ added in v0.6.0
VarUint64sToBytes appends the bytes of the given uint64s to the given byte slice. It uses variable-length encoding.
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 BytesBlockDecoder ¶ added in v0.6.0
type BytesBlockDecoder struct {
// contains filtered or unexported fields
}
BytesBlockDecoder decodes a block of strings from src. It reuses the underlying buffer for storing the decoded strings.
func (*BytesBlockDecoder) Reset ¶ added in v0.6.0
func (bbd *BytesBlockDecoder) Reset()
Reset resets the decoder.
type EncodeType ¶ added in v0.6.0
type EncodeType byte
EncodeType indicates the encoding type of a series.
const ( EncodeTypeUnknown EncodeType = iota EncodeTypeConst EncodeTypeDeltaConst EncodeTypeDelta EncodeTypeDeltaOfDelta EncodeTypeXOR )
EncodeType constants.
func Int64ListToBytes ¶ added in v0.6.0
func Int64ListToBytes(dst []byte, a []int64) (result []byte, mt EncodeType, firstValue int64)
Int64ListToBytes encodes a list of int64 into bytes.
type Int64List ¶ added in v0.6.0
type Int64List struct {
L []int64
}
Int64List is a list of int64.
func GenerateInt64List ¶ added in v0.6.0
GenerateInt64List generates a list of int64 with the given size. The returned list may be from a pool and should be released after use.
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.
type ParseInterval ¶
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.
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 Uint64List ¶ added in v0.6.0
type Uint64List struct {
L []uint64
}
Uint64List is a list of uint64.
func GenerateUint64List ¶ added in v0.6.0
func GenerateUint64List(size int) *Uint64List
GenerateUint64List generates a list of uint64 with the given size. The returned list may be from a pool and should be released after use.
type Writer ¶ added in v0.3.0
type Writer struct {
// contains filtered or unexported fields
}
Writer writes bits to an io.BufferWriter.
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.
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) 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.
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)