v1

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2024 License: Apache-2.0 Imports: 17 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 (
	// AnyTagValue is the `*` for a regular expression. It could match "any" Entry in an Entity.
	AnyTagValue = &modelv1.TagValue{Value: &modelv1.TagValue_Null{}}

	// 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 (
	// 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.

func MustTagValueToStr added in v0.7.1

func MustTagValueToStr(tag *modelv1.TagValue) string

MustTagValueToStr converts modelv1.TagValue to string.

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 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) CopyTo added in v0.7.0

func (s *Series) CopyTo(dst *Series)

CopyTo copies the content of the series to the destination series.

func (*Series) Marshal added in v0.6.0

func (s *Series) Marshal() error

Marshal encodes series to internal Buffer and generates ID.

func (*Series) MarshalWithWildcard added in v0.6.1

func (s *Series) MarshalWithWildcard() error

MarshalWithWildcard encodes series to internal Buffer and generates ID with wildcard.

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 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 MustTagValueSpecToValueType added in v0.7.0

func MustTagValueSpecToValueType(tag databasev1.TagType) ValueType

MustTagValueSpecToValueType converts databasev1.TagType to ValueType.

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