Help us shape the future of Go! Take the 2026 Go Developer Survey

codec

package
v0.1.0-rc.5 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxSamples = 240
)

Variables

View Source
var ErrInvalid = errors.New("invalid metric payload")

Functions

This section is empty.

Types

type Codec

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

Codec owns one bounded encoder and decoder; returned iterators own their buffers.

func New

func New() (*Codec, error)

func (*Codec) Close

func (c *Codec) Close() error

func (*Codec) Decode

func (c *Codec) Decode(head Head, body []byte) (*Iterator, error)

Decode copies the bounded body; iteration needs neither a lock nor an open Codec.

func (*Codec) DecodeValues

func (c *Codec) DecodeValues(first float64, count int, stream []byte) (*Iterator, error)

DecodeValues reads what EncodeValues wrote, given the first value and the count, which the stream does not repeat. It carries no checksum of its own, so the caller checks the bytes it stored; each Sample's At is its index.

func (*Codec) Encode

func (c *Codec) Encode(samples []Sample) (Head, []byte, error)

Encode requires strictly increasing timestamps and preserves every float64 bit.

func (*Codec) EncodeValues

func (c *Codec) EncodeValues(values []float64) ([]byte, error)

EncodeValues packs values alone, for a caller that keeps the timestamps and the first value itself. It returns Encode's stream for evenly spaced samples, which write no timestamps, behind the byte that says how it was packed:

Encode        1 | flags | 0 0 | stream | checksum
EncodeValues      flags |       stream
type Head struct {
	Start, End int64
	Count      int
	First      float64
}

Head is what the row around a body already holds. Encode returns it, the caller stores it, and Decode is given it back; nothing in the body repeats it.

type Iterator

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

func (*Iterator) Err

func (it *Iterator) Err() error

func (*Iterator) Next

func (it *Iterator) Next() bool

func (*Iterator) Sample

func (it *Iterator) Sample() Sample

type Sample

type Sample struct {
	At    int64
	Value float64
}

Jump to

Keyboard shortcuts

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