m3tsz

package
v0.0.0-...-9649366 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2019 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultIntOptimizationEnabled is the default switch for m3tsz int optimization
	DefaultIntOptimizationEnabled = true

	// OpcodeZeroSig indicates that there were zero significant digits.
	OpcodeZeroSig = 0x0
	// OpcodeNonZeroSig indicates that there were a non-zero number of significant digits.
	OpcodeNonZeroSig = 0x1

	// NumSigBits is the number of bits required to encode the maximum possible value
	// of significant digits.
	NumSigBits = 6
)

Variables

This section is empty.

Functions

func NewDecoder

func NewDecoder(intOptimized bool, opts encoding.Options) encoding.Decoder

NewDecoder creates a decoder.

func NewEncoder

func NewEncoder(
	start time.Time,
	bytes checked.Bytes,
	intOptimized bool,
	opts encoding.Options,
) encoding.Encoder

NewEncoder creates a new encoder.

func NewReaderIterator

func NewReaderIterator(reader io.Reader, intOptimized bool, opts encoding.Options) encoding.ReaderIterator

NewReaderIterator returns a new iterator for a given reader

Types

type FloatEncoderAndIterator

type FloatEncoderAndIterator struct {
	PrevXOR       uint64
	PrevFloatBits uint64

	// Only taken into account if using the WriteFloat() and ReadFloat()
	// APIs.
	NotFirst bool
}

FloatEncoderAndIterator encapsulates the state required for a logical stream of bits that represent a stream of float values compressed with XOR.

func (*FloatEncoderAndIterator) ReadFloat

func (eit *FloatEncoderAndIterator) ReadFloat(stream encoding.IStream) error

ReadFloat reads a compressed float from the stream.

func (*FloatEncoderAndIterator) WriteFloat

func (eit *FloatEncoderAndIterator) WriteFloat(stream encoding.OStream, val float64)

WriteFloat writes a float into the stream, writing the full value or a compressed XOR as appropriate.

type IntSigBitsTracker

type IntSigBitsTracker struct {
	NumSig             uint8 // current largest number of significant places for int diffs
	CurHighestLowerSig uint8
	NumLowerSig        uint8
}

IntSigBitsTracker is used to track the number of significant bits which should be used to encode the delta between two integers.

func (*IntSigBitsTracker) TrackNewSig

func (t *IntSigBitsTracker) TrackNewSig(numSig uint8) uint8

TrackNewSig gets the new number of significant bits given the number of significant bits of the current diff. It takes into account thresholds to try and find a value that's best for the current data

func (*IntSigBitsTracker) WriteIntSig

func (t *IntSigBitsTracker) WriteIntSig(stream encoding.OStream, sig uint8)

WriteIntSig writes the number of significant bits of the diff if it has changed and updates the IntSigBitsTracker.

func (*IntSigBitsTracker) WriteIntValDiff

func (t *IntSigBitsTracker) WriteIntValDiff(
	stream encoding.OStream, valBits uint64, neg bool)

WriteIntValDiff writes the provided val diff bits along with whether the bits are negative or not.

type TimestampEncoder

type TimestampEncoder struct {
	PrevTime       time.Time
	PrevTimeDelta  time.Duration
	PrevAnnotation []byte

	Options encoding.Options

	TimeUnit xtime.Unit
	// contains filtered or unexported fields
}

TimestampEncoder encapsulates the state required for a logical stream of bits that represent a stream of timestamps compressed using delta-of-delta

func NewTimestampEncoder

func NewTimestampEncoder(
	start time.Time, timeUnit xtime.Unit, opts encoding.Options) TimestampEncoder

NewTimestampEncoder creates a new TimestampEncoder.

func (*TimestampEncoder) WriteFirstTime

func (enc *TimestampEncoder) WriteFirstTime(
	stream encoding.OStream, currTime time.Time, ant ts.Annotation, timeUnit xtime.Unit) error

WriteFirstTime encodes the first timestamp.

func (*TimestampEncoder) WriteNextTime

func (enc *TimestampEncoder) WriteNextTime(
	stream encoding.OStream, currTime time.Time, ant ts.Annotation, timeUnit xtime.Unit) error

WriteNextTime encodes the next (non-first) timestamp.

func (*TimestampEncoder) WriteTime

func (enc *TimestampEncoder) WriteTime(
	stream encoding.OStream, currTime time.Time, ant ts.Annotation, timeUnit xtime.Unit) error

WriteTime encode the timestamp using delta-of-delta compression.

func (*TimestampEncoder) WriteTimeUnit

func (enc *TimestampEncoder) WriteTimeUnit(stream encoding.OStream, timeUnit xtime.Unit)

WriteTimeUnit writes the new time unit into the stream. It exists as a standalone method so that other calls can encode time unit changes without relying on the marker scheme.

type TimestampIterator

type TimestampIterator struct {
	PrevTime      time.Time
	PrevTimeDelta time.Duration
	PrevAnt       ts.Annotation

	TimeUnit xtime.Unit

	Opts encoding.Options

	TimeUnitChanged bool
	Done            bool

	// Controls whether the iterator will "look ahead" for marker encoding
	// schemes. Setting SkipMarkers to true disables the look ahead behavior
	// for situations where looking ahead is not safe.
	SkipMarkers bool
}

TimestampIterator encapsulates all the state required for iterating over delta-of-delta compresed timestamps.

func NewTimestampIterator

func NewTimestampIterator(opts encoding.Options, skipMarkers bool) TimestampIterator

NewTimestampIterator creates a new TimestampIterator.

func (*TimestampIterator) ReadTimeUnit

func (it *TimestampIterator) ReadTimeUnit(stream encoding.IStream) error

ReadTimeUnit reads an encoded time unit and updates the iterator's state accordingly. It is exposed as a public method so that callers can control the encoding / decoding of the time unit on their own if they choose.

func (*TimestampIterator) ReadTimestamp

func (it *TimestampIterator) ReadTimestamp(stream encoding.IStream) (bool, bool, error)

ReadTimestamp reads the first or next timestamp.

Jump to

Keyboard shortcuts

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