本文整理匯總了Golang中github.com/influxdb/influxdb/engine.Processor.Yield方法的典型用法代碼示例。如果您正苦於以下問題:Golang Processor.Yield方法的具體用法?Golang Processor.Yield怎麽用?Golang Processor.Yield使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/influxdb/influxdb/engine.Processor
的用法示例。
在下文中一共展示了Processor.Yield方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: runListSeriesQuery
func (self *Coordinator) runListSeriesQuery(querySpec *parser.QuerySpec, p engine.Processor) error {
allSeries := self.clusterConfiguration.MetaStore.GetSeriesForDatabase(querySpec.Database())
matchingSeries := allSeries
if q := querySpec.Query().GetListSeriesQuery(); q.HasRegex() {
matchingSeries = nil
regex := q.GetRegex()
for _, s := range allSeries {
if !regex.MatchString(s) {
continue
}
matchingSeries = append(matchingSeries, s)
}
}
name := "list_series_result"
fields := []string{"name"}
points := make([]*protocol.Point, len(matchingSeries), len(matchingSeries))
for i, s := range matchingSeries {
fieldValues := []*protocol.FieldValue{{StringValue: proto.String(s)}}
points[i] = &protocol.Point{Values: fieldValues}
}
seriesResult := &protocol.Series{Name: &name, Fields: fields, Points: points}
_, err := p.Yield(seriesResult)
return err
}
示例2: runListContinuousQueries
func (self *Coordinator) runListContinuousQueries(user common.User, db string, p engine.Processor) error {
queries, err := self.ListContinuousQueries(user, db)
if err != nil {
return err
}
for _, q := range queries {
if ok, err := p.Yield(q); !ok || err != nil {
return err
}
}
return nil
}
示例3: runListSeriesQuery
func (self *Coordinator) runListSeriesQuery(querySpec *parser.QuerySpec, p engine.Processor) error {
allSeries := self.clusterConfiguration.MetaStore.GetSeriesForDatabase(querySpec.Database())
matchingSeries := allSeries
q := querySpec.Query().GetListSeriesQuery()
if q.HasRegex() {
matchingSeries = nil
regex := q.GetRegex()
for _, s := range allSeries {
if !regex.MatchString(s) {
continue
}
matchingSeries = append(matchingSeries, s)
}
}
name := "list_series_result"
var fields []string
points := make([]*protocol.Point, len(matchingSeries))
if q.IncludeSpaces {
fields = []string{"name", "space"}
spaces := self.clusterConfiguration.GetShardSpacesForDatabase(querySpec.Database())
for i, s := range matchingSeries {
spaceName := ""
for _, sp := range spaces {
if sp.MatchesSeries(s) {
spaceName = sp.Name
break
}
}
fieldValues := []*protocol.FieldValue{
{StringValue: proto.String(s)},
{StringValue: proto.String(spaceName)},
}
points[i] = &protocol.Point{Values: fieldValues}
}
} else {
fields = []string{"name"}
for i, s := range matchingSeries {
fieldValues := []*protocol.FieldValue{
{StringValue: proto.String(s)},
}
points[i] = &protocol.Point{Values: fieldValues}
}
}
seriesResult := &protocol.Series{Name: &name, Fields: fields, Points: points}
_, err := p.Yield(seriesResult)
return err
}
示例4: yieldToProcessor
func yieldToProcessor(s *protocol.Series, p engine.Processor, aliases []string) (bool, error) {
for _, alias := range aliases {
series := &protocol.Series{
Name: proto.String(alias),
Fields: s.Fields,
Points: s.Points,
}
log4go.Debug("Yielding to %s %s", p.Name(), series)
if ok, err := p.Yield(series); !ok || err != nil {
return ok, err
}
}
return true, nil
}
示例5: executeSinglePointQuery
func (self *Shard) executeSinglePointQuery(querySpec *parser.QuerySpec, name string, columns []string, p engine.Processor) error {
fields, err := self.getFieldsForSeries(querySpec.Database(), name, columns)
if err != nil {
log.Error("Error looking up fields for %s: %s", name, err)
return err
}
query := querySpec.SelectQuery()
fieldCount := len(fields)
fieldNames := make([]string, 0, fieldCount)
point := &protocol.Point{Values: make([]*protocol.FieldValue, 0, fieldCount)}
timestamp := common.TimeToMicroseconds(query.GetStartTime())
sequenceNumber, err := query.GetSinglePointQuerySequenceNumber()
if err != nil {
return err
}
// set the timestamp and sequence number
point.SequenceNumber = &sequenceNumber
point.SetTimestampInMicroseconds(timestamp)
for _, field := range fields {
sk := newStorageKey(field.Id, timestamp, sequenceNumber)
data, err := self.db.Get(sk.bytes())
if err != nil {
return err
}
if data == nil {
continue
}
fieldValue := &protocol.FieldValue{}
err = proto.Unmarshal(data, fieldValue)
if err != nil {
return err
}
fieldNames = append(fieldNames, field.Name)
point.Values = append(point.Values, fieldValue)
}
result := &protocol.Series{Name: &name, Fields: fieldNames, Points: []*protocol.Point{point}}
if len(result.Points) > 0 {
_, err := p.Yield(result)
return err
}
return nil
}