本文整理汇总了Golang中protocol.Series.SortPointsTimeAscending方法的典型用法代码示例。如果您正苦于以下问题:Golang Series.SortPointsTimeAscending方法的具体用法?Golang Series.SortPointsTimeAscending怎么用?Golang Series.SortPointsTimeAscending使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类protocol.Series
的用法示例。
在下文中一共展示了Series.SortPointsTimeAscending方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: yieldResultsForSeries
//.........这里部分代码省略.........
barrierTime = *response.NextPointTime
}
}
// yield the points from leftover that are safe
for _, point := range leftover.Points {
if shouldYieldComparator(point.Timestamp) {
result.Points = append(result.Points, point)
} else {
break
}
}
// if they all got added, clear out the leftover
if len(leftover.Points) == len(result.Points) {
leftover.Points = make([]*protocol.Point, 0)
}
if barrierTime == BARRIER_TIME_MIN || barrierTime == BARRIER_TIME_MAX {
// all the nextPointTimes were nil so we're safe to send everything
for _, response := range responses {
// if this is the case we know that all responses contained the same
// fields. So just append the points
if len(response.Series.Fields) == fieldCount {
result.Points = append(result.Points, response.Series.Points...)
} else {
log.Debug("Responses from servers had different numbers of fields.")
for _, p := range response.Series.Points {
self.normalizePointAndAppend(fieldIndexes, result, response.Series.Fields, p)
}
}
}
if len(leftover.Fields) == fieldCount {
result.Points = append(result.Points, leftover.Points...)
leftover.Points = []*protocol.Point{}
} else {
log.Debug("Responses from servers had different numbers of fields.")
for _, p := range leftover.Points {
self.normalizePointAndAppend(fieldIndexes, result, leftover.Fields, p)
}
}
} else {
for _, response := range responses {
if shouldYieldComparator(response.NextPointTime) {
// all points safe to yield
if fieldCount == len(response.Series.Fields) {
result.Points = append(result.Points, response.Series.Points...)
} else {
log.Debug("Responses from servers had different numbers of fields.")
for _, p := range response.Series.Points {
self.normalizePointAndAppend(fieldIndexes, result, response.Series.Fields, p)
}
}
continue
}
if fieldCount == len(response.Series.Fields) {
for i, point := range response.Series.Points {
if shouldYieldComparator(point.Timestamp) {
result.Points = append(result.Points, point)
} else {
// since they're returned in order, we can just append these to
// the leftover and break out.
leftover.Points = append(leftover.Points, response.Series.Points[i:]...)
break
}
}
} else {
for i, point := range response.Series.Points {
if shouldYieldComparator(point.Timestamp) {
self.normalizePointAndAppend(fieldIndexes, result, response.Series.Fields, point)
} else {
// since they're returned in order, we can just append these to
// the leftover and break out.
for _, point := range response.Series.Points[i:] {
self.normalizePointAndAppend(fieldIndexes, leftover, response.Series.Fields, point)
}
break
}
}
}
}
}
if isAscending {
result.SortPointsTimeAscending()
leftover.SortPointsTimeAscending()
} else {
result.SortPointsTimeDescending()
leftover.SortPointsTimeDescending()
}
// Don't yield an empty points array, the engine will think it's the end of the stream.
// streamResultsFromChannels will send the empty ones after all channels have returned.
if len(result.Points) > 0 {
yield(result)
}
if len(leftover.Points) > 0 {
return leftover
}
return nil
}