Documentation ¶
Overview ¶
Package v1 implements helpers to access data defined by API v1.
Index ¶
- Variables
- func DecodeFieldFlag(key []byte) (*databasev1.FieldSpec, time.Duration, error)
- func DecodeFieldValue(fieldValue []byte, fieldSpec *databasev1.FieldSpec) (*modelv1.FieldValue, error)
- func EncodeFamily(familySpec *databasev1.TagFamilySpec, family *modelv1.TagFamilyForWrite) ([]byte, error)
- func EncoderFieldFlag(fieldSpec *databasev1.FieldSpec, interval time.Duration) []byte
- func FieldValueTypeConv(fieldValue *modelv1.FieldValue) (tagType databasev1.FieldType, isNull bool)
- func FindTagByName(families []*databasev1.TagFamilySpec, tagName string) (int, int, *databasev1.TagSpec)
- func HashEntity(entity Entity) []byte
- func MarshalTagValue(tagValue *modelv1.TagValue) ([]byte, error)
- func MustCompareTagValue(tv1, tv2 *modelv1.TagValue) int
- func MustTagValueToStr(tag *modelv1.TagValue) string
- type Entity
- type EntityValue
- type EntityValues
- type Entry
- type Series
- type SeriesList
- type TagValue
- type ValueType
Constants ¶
This section is empty.
Variables ¶
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{}} )
var ( // TagFlag is a flag suffix to identify the encoding method. TagFlag = make([]byte, fieldFlagLength) )
Functions ¶
func DecodeFieldFlag ¶ added in v0.2.0
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
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
MarshalTagValue encodes modelv1.TagValue to bytes.
func MustCompareTagValue ¶ added in v0.6.0
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
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.
type EntityValue ¶ added in v0.6.0
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 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
CopyTo copies the content of the series to the destination series.
func (*Series) Marshal ¶ added in v0.6.0
Marshal encodes series to internal Buffer and generates ID.
func (*Series) MarshalWithWildcard ¶ added in v0.6.1
MarshalWithWildcard encodes series to internal Buffer and generates ID with wildcard.
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
ParseTagValue decodes modelv1.TagValue to TagValue.
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
MustTagValueToValueType converts modelv1.TagValue to ValueType.