proto

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: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewIterator

func NewIterator(
	reader io.Reader,
	descr namespace.SchemaDescr,
	opts encoding.Options,
) encoding.ReaderIterator

NewIterator creates a new iterator.

func ParseProtoSchema

func ParseProtoSchema(filePath string, messageName string) (*desc.MessageDescriptor, error)

ParseProtoSchema parses a Protobuf schema. TODO(rartoul): This is temporary code that will eventually be replaced with storing the schemas in etcd.

Types

type Encoder

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

Encoder compresses arbitrary ProtoBuf streams given a schema.

func NewEncoder

func NewEncoder(start time.Time, opts encoding.Options) *Encoder

NewEncoder creates a new protobuf encoder.

func (*Encoder) Bytes

func (enc *Encoder) Bytes() ([]byte, error)

Bytes returns the raw bytes of the underlying data stream. Does not transfer ownership and is generally unsafe.

func (*Encoder) Close

func (enc *Encoder) Close()

Close closes the encoder.

func (*Encoder) Discard

func (enc *Encoder) Discard() ts.Segment

Discard closes the encoder and transfers ownership of the data stream to the caller.

func (*Encoder) DiscardReset

func (enc *Encoder) DiscardReset(start time.Time, capacity int, descr namespace.SchemaDescr) ts.Segment

DiscardReset does the same thing as Discard except it also resets the encoder for reuse.

func (*Encoder) Encode

func (enc *Encoder) Encode(dp ts.Datapoint, timeUnit xtime.Unit, protoBytes ts.Annotation) error

Encode encodes a timestamp and a protobuf message. The function signature is strange in order to implement the encoding.Encoder interface. It accepts a ts.Datapoint, but only the Timestamp field will be used, the Value field will be ignored and will always return 0 on subsequent iteration. In addition, the provided annotation is expected to be a marshalled protobuf message that matches the configured schema.

func (*Encoder) LastEncoded

func (enc *Encoder) LastEncoded() (ts.Datapoint, error)

LastEncoded returns the last encoded datapoint. Does not include annotation / protobuf message for interface purposes.

func (*Encoder) Len

func (enc *Encoder) Len() int

Len returns the length of the data stream.

func (*Encoder) NumEncoded

func (enc *Encoder) NumEncoded() int

NumEncoded returns the number of encoded messages.

func (*Encoder) Reset

func (enc *Encoder) Reset(
	start time.Time,
	capacity int,
	descr namespace.SchemaDescr,
)

Reset resets the encoder for reuse.

func (*Encoder) SetSchema

func (enc *Encoder) SetSchema(descr namespace.SchemaDescr)

func (*Encoder) Stats

func (enc *Encoder) Stats() EncoderStats

Stats returns EncoderStats which contain statistics about the encoders compression ratio.

func (*Encoder) Stream

func (enc *Encoder) Stream(ctx context.Context) (xio.SegmentReader, bool)

Stream returns a copy of the underlying data stream.

type EncoderStats

type EncoderStats struct {
	UncompressedBytes int
	CompressedBytes   int
}

EncoderStats contains statistics about the encoders compression performance.

type Schema

type Schema *desc.MessageDescriptor

Schema represents a schema for a protobuf message.

Jump to

Keyboard shortcuts

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