本文整理汇总了Golang中parser.SelectQuery.GetSinglePointQuerySequenceNumber方法的典型用法代码示例。如果您正苦于以下问题:Golang SelectQuery.GetSinglePointQuerySequenceNumber方法的具体用法?Golang SelectQuery.GetSinglePointQuerySequenceNumber怎么用?Golang SelectQuery.GetSinglePointQuerySequenceNumber使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类parser.SelectQuery
的用法示例。
在下文中一共展示了SelectQuery.GetSinglePointQuerySequenceNumber方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: fetchSinglePoint
func (self *LevelDbDatastore) fetchSinglePoint(database, series string, fields []*Field,
query *parser.SelectQuery) (*protocol.Series, error) {
fieldCount := len(fields)
fieldNames := make([]string, 0, fieldCount)
point := &protocol.Point{Values: make([]*protocol.FieldValue, 0, fieldCount)}
timestampBuffer := bytes.NewBuffer(make([]byte, 0, 8))
sequenceNumberBuffer := bytes.NewBuffer(make([]byte, 0, 8))
timestamp := common.TimeToMicroseconds(query.GetStartTime())
sequenceNumber, err := query.GetSinglePointQuerySequenceNumber()
if err != nil {
return nil, err
}
binary.Write(timestampBuffer, binary.BigEndian, self.convertTimestampToUint(×tamp))
binary.Write(sequenceNumberBuffer, binary.BigEndian, sequenceNumber)
sequenceNumber_uint64 := uint64(sequenceNumber)
point.SequenceNumber = &sequenceNumber_uint64
point.SetTimestampInMicroseconds(timestamp)
for _, field := range fields {
pointKey := append(append(field.Id, timestampBuffer.Bytes()...), sequenceNumberBuffer.Bytes()...)
if data, err := self.db.Get(self.readOptions, pointKey); err != nil {
return nil, err
} else {
fieldValue := &protocol.FieldValue{}
err := proto.Unmarshal(data, fieldValue)
if err != nil {
return nil, err
}
if data != nil {
fieldNames = append(fieldNames, field.Name)
point.Values = append(point.Values, fieldValue)
}
}
}
result := &protocol.Series{Name: &series, Fields: fieldNames, Points: []*protocol.Point{point}}
return result, nil
}