本文整理汇总了Golang中github.com/Wikia/influxdb/parser.QuerySpec.IsSinglePointQuery方法的典型用法代码示例。如果您正苦于以下问题:Golang QuerySpec.IsSinglePointQuery方法的具体用法?Golang QuerySpec.IsSinglePointQuery怎么用?Golang QuerySpec.IsSinglePointQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/Wikia/influxdb/parser.QuerySpec
的用法示例。
在下文中一共展示了QuerySpec.IsSinglePointQuery方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: getProcessor
func (self *ShardData) getProcessor(querySpec *parser.QuerySpec, processor engine.Processor) (engine.Processor, error) {
switch qt := querySpec.Query().Type(); qt {
case parser.Delete, parser.DropSeries:
return NilProcessor{}, nil
case parser.Select:
// continue
default:
panic(fmt.Errorf("Unexpected query type: %s", qt))
}
if querySpec.IsSinglePointQuery() {
return engine.NewPassthroughEngine(processor, 1), nil
}
query := querySpec.SelectQuery()
var err error
// We should aggregate at the shard level
if self.ShouldAggregateLocally(querySpec) {
log.Debug("creating a query engine")
processor, err = engine.NewQueryEngine(processor, query, nil)
if err != nil {
return nil, err
}
goto addFilter
}
// we shouldn't limit the queries if they have aggregates and aren't
// aggregated locally, otherwise the aggregation result which happen
// in the coordinator will get partial data and will be incorrect
if query.HasAggregates() {
log.Debug("creating a passthrough engine")
processor = engine.NewPassthroughEngine(processor, 1000)
goto addFilter
}
// This is an optimization so we don't send more data that we should
// over the wire. The coordinator has its own Passthrough which does
// the final limit.
if l := query.Limit; l > 0 {
log.Debug("creating a passthrough engine with limit")
processor = engine.NewPassthroughEngineWithLimit(processor, 1000, query.Limit)
}
addFilter:
if query := querySpec.SelectQuery(); query != nil && query.GetFromClause().Type != parser.FromClauseInnerJoin {
// Joins do their own filtering since we need to get all
// points before filtering. This is due to the fact that some
// where expressions will be difficult to compute before the
// points are joined together, think where clause with
// left.column = 'something' or right.column =
// 'something_else'. We can't filter the individual series
// separately. The filtering happens in merge.go:55
processor = engine.NewFilteringEngine(query, processor)
}
return processor, nil
}
示例2: executeQueryForSeries
func (self *Shard) executeQueryForSeries(querySpec *parser.QuerySpec, name string, columns []string, processor engine.Processor) error {
if querySpec.IsSinglePointQuery() {
log.Debug("Running single query for series %s", name)
return self.executeSinglePointQuery(querySpec, name, columns, processor)
}
var pi *PointIterator
var err error
columns, pi, err = self.getPointIteratorForSeries(querySpec, name, columns)
if err != nil {
return err
}
defer pi.Close()
query := querySpec.SelectQuery()
aliases := query.GetTableAliases(name)
seriesOutgoing := &protocol.Series{Name: protocol.String(name), Fields: columns, Points: make([]*protocol.Point, 0, self.pointBatchSize)}
for pi.Valid() {
p := pi.Point()
seriesOutgoing.Points = append(seriesOutgoing.Points, p)
if len(seriesOutgoing.Points) >= self.pointBatchSize {
ok, err := yieldToProcessor(seriesOutgoing, processor, aliases)
if !ok || err != nil {
log.Debug("Stopping processing.")
if err != nil {
log.Error("Error while processing data: %v", err)
return err
}
return nil
}
seriesOutgoing = &protocol.Series{Name: protocol.String(name), Fields: columns, Points: make([]*protocol.Point, 0, self.pointBatchSize)}
}
pi.Next()
}
if err := pi.Error(); err != nil {
return err
}
//Yield remaining data
if ok, err := yieldToProcessor(seriesOutgoing, processor, aliases); !ok || err != nil {
log.Debug("Stopping processing remaining points...")
if err != nil {
log.Error("Error while processing data: %v", err)
return err
}
}
log.Debug("Finished running query %s", query.GetQueryString())
return nil
}