本文整理匯總了Golang中github.com/influxdb/influxdb/client.Point類的典型用法代碼示例。如果您正苦於以下問題:Golang Point類的具體用法?Golang Point怎麽用?Golang Point使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Point類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: ReadDB
func ReadDB(c *client.Client, sdb, ddb, cmd string) client.BatchPoints {
q := client.Query{
Command: cmd,
Database: sdb,
}
//get type client.BatchPoints
var batchpoints client.BatchPoints
response, err := c.Query(q)
if err != nil {
fmt.Printf("Fail to get response from database, read database error: %s\n", err.Error())
}
res := response.Results
if len(res) == 0 {
fmt.Printf("The response of database is null, read database error!\n")
} else {
res_length := len(res)
for k := 0; k < res_length; k++ {
//show progress of reading series
count := len(res[k].Series)
bar := pb.StartNew(count)
for _, ser := range res[k].Series {
//get type client.Point
var point client.Point
point.Measurement = ser.Name
point.Tags = ser.Tags
for _, v := range ser.Values {
point.Time, _ = time.Parse(time.RFC3339, v[0].(string))
field := make(map[string]interface{})
l := len(v)
for i := 1; i < l; i++ {
if v[i] != nil {
field[ser.Columns[i]] = v[i]
}
}
point.Fields = field
point.Precision = "s"
batchpoints.Points = append(batchpoints.Points, point)
}
bar.Increment()
time.Sleep(3 * time.Millisecond)
}
bar.FinishPrint("Read series has finished!\n")
}
batchpoints.Database = ddb
batchpoints.RetentionPolicy = "default"
}
return batchpoints
}
示例2: addTagsToPoint
// Adds additional tags to the existing tags of a point
func addTagsToPoint(point *influxdb.Point, tags map[string]string) {
if point.Tags == nil {
point.Tags = tags
} else {
for k, v := range tags {
point.Tags[k] = v
}
}
}
示例3: deepcopy
// deepcopy returns a deep copy of the BatchPoints object. This is primarily so
// we can do multithreaded output flushing (see Agent.flush)
func (bp *BatchPoints) deepcopy() *BatchPoints {
bp.mu.Lock()
defer bp.mu.Unlock()
var bpc BatchPoints
bpc.Time = bp.Time
bpc.Precision = bp.Precision
bpc.Tags = make(map[string]string)
for k, v := range bp.Tags {
bpc.Tags[k] = v
}
var pts []client.Point
for _, pt := range bp.Points {
var ptc client.Point
ptc.Measurement = pt.Measurement
ptc.Time = pt.Time
ptc.Precision = pt.Precision
ptc.Raw = pt.Raw
ptc.Tags = make(map[string]string)
ptc.Fields = make(map[string]interface{})
for k, v := range pt.Tags {
ptc.Tags[k] = v
}
for k, v := range pt.Fields {
ptc.Fields[k] = v
}
pts = append(pts, ptc)
}
bpc.Points = pts
return &bpc
}