v1

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: May 9, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package v1 implements helpers to access data defined by API v1.

Index

Constants

This section is empty.

Variables

View Source
var (
	// NullFieldValue represents a null field value in the model.
	NullFieldValue = &modelv1.FieldValue{Value: &modelv1.FieldValue_Null{}}

	// EmptyStrFieldValue represents an empty string field value in the model.
	EmptyStrFieldValue = &modelv1.FieldValue{Value: &modelv1.FieldValue_Str{Str: &modelv1.Str{Value: ""}}}

	// EmptyBinaryFieldValue represents an empty binary field value in the model.
	EmptyBinaryFieldValue = &modelv1.FieldValue{Value: &modelv1.FieldValue_BinaryData{BinaryData: []byte{}}}

	// NullTagFamily represents a null tag family in the model.
	NullTagFamily = &modelv1.TagFamilyForWrite{}

	// NullTagValue represents a null tag value in the model.
	NullTagValue = &modelv1.TagValue{Value: &modelv1.TagValue_Null{}}
)
View Source
var AnyTagValue = &modelv1.TagValue{Value: &modelv1.TagValue_Null{}}

AnyTagValue is the `*` for a regular expression. It could match "any" Entry in an Entity.

View Source
var (
	// TagFlag is a flag suffix to identify the encoding method.
	TagFlag = make([]byte, fieldFlagLength)
)

Functions

func DecodeFieldFlag added in v0.2.0

func DecodeFieldFlag(key []byte) (*databasev1.FieldSpec, time.Duration, error)

DecodeFieldFlag decodes the encoding method, compression method, and interval from bytes.

func DecodeFieldValue added in v0.2.0

func DecodeFieldValue(fieldValue []byte, fieldSpec *databasev1.FieldSpec) (*modelv1.FieldValue, error)

DecodeFieldValue decodes bytes to field value based on its specification.

func EncodeFamily added in v0.2.0

func EncodeFamily(familySpec *databasev1.TagFamilySpec, family *modelv1.TagFamilyForWrite) ([]byte, error)

EncodeFamily encodes a tag family to bytes by referring to its specification.

func EncoderFieldFlag added in v0.2.0

func EncoderFieldFlag(fieldSpec *databasev1.FieldSpec, interval time.Duration) []byte

EncoderFieldFlag encodes the encoding method, compression method, and interval into bytes.

func FieldValueTypeConv

func FieldValueTypeConv(fieldValue *modelv1.FieldValue) (tagType databasev1.FieldType, isNull bool)

FieldValueTypeConv recognizes the field type from its value.

func FindTagByName

func FindTagByName(families []*databasev1.TagFamilySpec, tagName string) (int, int, *databasev1.TagSpec)

FindTagByName finds TagSpec in several tag families by its name. The tag name should be unique in these families.

func HashEntity added in v0.6.0

func HashEntity(entity Entity) []byte

HashEntity runs hash function (e.g. with xxhash algorithm) on each segment of the Entity, and concatenates all uint64 in byte array. So the return length of the byte array will be 8 (every uint64 has 8 bytes) * length of the input.

func MarshalTagValue added in v0.3.0

func MarshalTagValue(tagValue *modelv1.TagValue) ([]byte, error)

MarshalTagValue encodes modelv1.TagValue to bytes.

func MustCompareTagValue added in v0.6.0

func MustCompareTagValue(tv1, tv2 *modelv1.TagValue) int

MustCompareTagValue compares two tag values. It returns 0 if tv1 == tv2, -1 if tv1 < tv2, 1 if tv1 > tv2. It panics if the tag value type is inconsistent.

Types

type Entity added in v0.6.0

type Entity []Entry

Entity denotes an identity of a Series. It defined by Stream or Measure schema.

func (Entity) Marshal added in v0.6.0

func (e Entity) Marshal() []byte

Marshal encodes an Entity to bytes.

type EntityValue added in v0.6.0

type EntityValue = *modelv1.TagValue

EntityValue represents the value of a tag which is a part of an entity.

func StrValue added in v0.6.0

func StrValue(v string) EntityValue

StrValue returns an EntityValue which wraps a string value.

type EntityValues added in v0.6.0

type EntityValues []EntityValue

EntityValues is the encoded Entity.

func (EntityValues) Encode added in v0.6.0

func (evs EntityValues) Encode() (result []*modelv1.TagValue)

Encode EntityValues to tag values.

func (EntityValues) String added in v0.6.0

func (evs EntityValues) String() string

String outputs the string represent of an EntityValue.

func (EntityValues) ToEntity added in v0.6.0

func (evs EntityValues) ToEntity() (result Entity, err error)

ToEntity transforms EntityValues to Entity.

type Entry added in v0.6.0

type Entry []byte

Entry is an element in an Entity.

type Field added in v0.6.0

type Field struct {
	Name   string
	Values []*modelv1.FieldValue
}

Field is a field name and its values.

type MeasureQueryOptions added in v0.6.0

type MeasureQueryOptions struct {
	Name            string
	TimeRange       *timestamp.TimeRange
	Entities        [][]*modelv1.TagValue
	Filter          index.Filter
	Order           *OrderBy
	TagProjection   []TagProjection
	FieldProjection []string
}

MeasureQueryOptions is the options of a measure query.

type MeasureQueryResult added in v0.6.0

type MeasureQueryResult interface {
	Pull() *MeasureResult
	Release()
}

MeasureQueryResult is the result of a measure query.

type MeasureResult added in v0.6.0

type MeasureResult struct {
	Timestamps  []int64
	TagFamilies []TagFamily
	Fields      []Field
	SID         common.SeriesID
}

MeasureResult is the result of a query.

type OrderBy added in v0.6.0

type OrderBy struct {
	Index *databasev1.IndexRule
	Sort  modelv1.Sort
}

OrderBy is the order by rule.

type Series added in v0.6.0

type Series struct {
	Subject      string
	EntityValues []*modelv1.TagValue
	Buffer       []byte
	ID           common.SeriesID
}

Series denotes a series of data points.

func (*Series) Marshal added in v0.6.0

func (s *Series) Marshal() error

Marshal encodes series to internal Buffer and generates ID.

func (*Series) Unmarshal added in v0.6.0

func (s *Series) Unmarshal(src []byte) error

Unmarshal decodes series from internal Buffer.

type SeriesList added in v0.6.0

type SeriesList []*Series

SeriesList is a collection of Series.

func (SeriesList) IDs added in v0.6.0

func (a SeriesList) IDs() []common.SeriesID

IDs returns the IDs of the SeriesList.

func (SeriesList) Len added in v0.6.0

func (a SeriesList) Len() int

func (SeriesList) Less added in v0.6.0

func (a SeriesList) Less(i, j int) bool

func (SeriesList) Merge added in v0.6.0

func (a SeriesList) Merge(other SeriesList) SeriesList

Merge other SeriesList with this one to create a new SeriesList.

func (SeriesList) Swap added in v0.6.0

func (a SeriesList) Swap(i, j int)

func (SeriesList) ToList added in v0.6.0

func (a SeriesList) ToList() posting.List

ToList converts SeriesList to posting.List.

type SeriesPool added in v0.6.0

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

SeriesPool is a pool of Series.

func (*SeriesPool) Generate added in v0.6.0

func (sp *SeriesPool) Generate() *Series

Generate creates a new Series or gets one from the pool.

func (*SeriesPool) Release added in v0.6.0

func (sp *SeriesPool) Release(s *Series)

Release puts a Series back to the pool.

type StreamColumnResult added in v0.6.0

type StreamColumnResult struct {
	TagFamilies [][]TagFamily
	Timestamps  []int64
	ElementIDs  []string
}

StreamColumnResult is the result of a stream sort or filter.

type StreamFilterOptions added in v0.6.0

type StreamFilterOptions struct {
	Name           string
	TimeRange      *timestamp.TimeRange
	Entities       [][]*modelv1.TagValue
	Filter         index.Filter
	Order          *OrderBy
	TagProjection  []TagProjection
	MaxElementSize int
}

StreamFilterOptions is the options of a stream filter.

type StreamFilterResult added in v0.6.0

type StreamFilterResult interface {
	Pull() *StreamColumnResult
}

StreamFilterResult is the result of a stream filter.

type StreamQueryOptions added in v0.6.0

type StreamQueryOptions struct {
	Name          string
	TimeRange     *timestamp.TimeRange
	Entities      [][]*modelv1.TagValue
	Filter        index.Filter
	Order         *OrderBy
	TagProjection []TagProjection
}

StreamQueryOptions is the options of a stream query.

type StreamQueryResult added in v0.6.0

type StreamQueryResult interface {
	Pull() *StreamResult
	Release()
}

StreamQueryResult is the result of a stream query.

type StreamResult added in v0.6.0

type StreamResult struct {
	Timestamps  []int64
	ElementIDs  []string
	TagFamilies []TagFamily
	SID         common.SeriesID
}

StreamResult is the result of a query.

type StreamSortOptions added in v0.6.0

type StreamSortOptions struct {
	Name           string
	TimeRange      *timestamp.TimeRange
	Entities       [][]*modelv1.TagValue
	Filter         index.Filter
	Order          *OrderBy
	TagProjection  []TagProjection
	MaxElementSize int
}

StreamSortOptions is the options of a stream sort.

type StreamSortResult added in v0.6.0

type StreamSortResult interface {
	Pull() *StreamColumnResult
}

StreamSortResult is the result of a stream sort.

type Tag added in v0.6.0

type Tag struct {
	Name   string
	Values []*modelv1.TagValue
}

Tag is a tag name and its values.

type TagFamily added in v0.6.0

type TagFamily struct {
	Name string
	Tags []Tag
}

TagFamily is a tag family name and its tags.

type TagProjection added in v0.6.0

type TagProjection struct {
	Family string
	Names  []string
}

TagProjection is the projection of a tag family and its tags.

type TagValue added in v0.3.0

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

TagValue seels single value and array value.

func ParseTagValue added in v0.3.0

func ParseTagValue(tagValue *modelv1.TagValue) (TagValue, error)

ParseTagValue decodes modelv1.TagValue to TagValue.

func (TagValue) GetArr added in v0.3.0

func (fv TagValue) GetArr() [][]byte

GetArr returns the array value.

func (TagValue) GetValue added in v0.3.0

func (fv TagValue) GetValue() []byte

GetValue returns the single value.

type ValueType added in v0.6.0

type ValueType byte

ValueType is the type of the tag and field value.

const (
	ValueTypeUnknown ValueType = iota
	ValueTypeStr
	ValueTypeInt64
	ValueTypeFloat64
	ValueTypeBinaryData
	ValueTypeStrArr
	ValueTypeInt64Arr
)

ValueType constants.

func MustTagValueToValueType added in v0.6.0

func MustTagValueToValueType(tag *modelv1.TagValue) ValueType

MustTagValueToValueType converts modelv1.TagValue to ValueType.

Jump to

Keyboard shortcuts

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