Documentation ¶
Index ¶
- func NewIterator(reader io.Reader, schema *desc.MessageDescriptor, opts encoding.Options) encoding.ReaderIterator
- func ParseProtoSchema(filePath string) (*desc.MessageDescriptor, error)
- type Encoder
- func (enc *Encoder) Bytes() ([]byte, error)
- func (enc *Encoder) Close()
- func (enc *Encoder) Discard() ts.Segment
- func (enc *Encoder) DiscardReset(start time.Time, capacity int) ts.Segment
- func (enc *Encoder) Encode(dp ts.Datapoint, timeUnit xtime.Unit, protoBytes ts.Annotation) error
- func (enc *Encoder) LastEncoded() (ts.Datapoint, error)
- func (enc *Encoder) Len() int
- func (enc *Encoder) NumEncoded() int
- func (enc *Encoder) Reset(start time.Time, capacity int)
- func (enc *Encoder) SetSchema(schema *desc.MessageDescriptor)
- func (enc *Encoder) Stream() xio.SegmentReader
- type Schema
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewIterator ¶
func NewIterator( reader io.Reader, schema *desc.MessageDescriptor, opts encoding.Options, ) encoding.ReaderIterator
NewIterator creates a new iterator.
func ParseProtoSchema ¶
func ParseProtoSchema(filePath 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. TODO(rartoul): Add support for changing the schema (and updating the ordering of the custom encoded fields) on demand: https://github.com/m3db/m3/issues/1471
func NewEncoder ¶
NewEncoder creates a new protobuf encoder.
func (*Encoder) Bytes ¶
Bytes returns the raw bytes of the underlying data stream. Does not transfer ownership and is generally unsafe.
func (*Encoder) Discard ¶
Discard closes the encoder and transfers ownership of the data stream to the caller.
func (*Encoder) DiscardReset ¶
DiscardReset does the same thing as Discard except it also resets the encoder for reuse.
func (*Encoder) Encode ¶
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 marshaled protobuf message that matches the configured schema.
func (*Encoder) LastEncoded ¶
LastEncoded returns the last encoded datapoint. Does not include annotation / protobuf message for interface purposes.
func (*Encoder) NumEncoded ¶
NumEncoded returns the number of encoded messages.
func (*Encoder) SetSchema ¶
func (enc *Encoder) SetSchema(schema *desc.MessageDescriptor)
SetSchema sets the encoders schema. TODO(rartoul): Add support for changing the schema (and updating the ordering of the custom encoded fields) on demand: https://github.com/m3db/m3/issues/1471
func (*Encoder) Stream ¶
func (enc *Encoder) Stream() xio.SegmentReader
Stream returns a copy of the underlying data stream.
type Schema ¶
type Schema *desc.MessageDescriptor
Schema represents a schema for a protobuf message.