本文整理汇总了Golang中parser.QuerySpec.IsDeleteFromSeriesQuery方法的典型用法代码示例。如果您正苦于以下问题:Golang QuerySpec.IsDeleteFromSeriesQuery方法的具体用法?Golang QuerySpec.IsDeleteFromSeriesQuery怎么用?Golang QuerySpec.IsDeleteFromSeriesQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类parser.QuerySpec
的用法示例。
在下文中一共展示了QuerySpec.IsDeleteFromSeriesQuery方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Query
func (self *Shard) Query(querySpec *parser.QuerySpec, processor cluster.QueryProcessor) error {
if querySpec.IsListSeriesQuery() {
return self.executeListSeriesQuery(querySpec, processor)
} else if querySpec.IsDeleteFromSeriesQuery() {
return self.executeDeleteQuery(querySpec, processor)
}
seriesAndColumns := querySpec.SelectQuery().GetReferencedColumns()
if !self.hasReadAccess(querySpec) {
return errors.New("User does not have access to one or more of the series requested.")
}
for series, columns := range seriesAndColumns {
if regex, ok := series.GetCompiledRegex(); ok {
seriesNames := self.metaStore.GetSeriesForDatabaseAndRegex(querySpec.Database(), regex)
for _, name := range seriesNames {
if !querySpec.HasReadAccess(name) {
continue
}
err := self.executeQueryForSeries(querySpec, name, columns, processor)
if err != nil {
return err
}
}
} else {
err := self.executeQueryForSeries(querySpec, series.Name, columns, processor)
if err != nil {
return err
}
}
}
return nil
}
示例2: Query
func (self *ShardData) Query(querySpec *parser.QuerySpec, response chan *protocol.Response) error {
// This is only for queries that are deletes or drops. They need to be sent everywhere as opposed to just the local or one of the remote shards.
// But this boolean should only be set to true on the server that receives the initial query.
if querySpec.RunAgainstAllServersInShard {
if querySpec.IsDeleteFromSeriesQuery() {
return self.logAndHandleDeleteQuery(querySpec, response)
} else if querySpec.IsDropSeriesQuery() {
return self.logAndHandleDropSeriesQuery(querySpec, response)
}
}
if self.localShard != nil {
var processor QueryProcessor
if querySpec.IsListSeriesQuery() {
processor = engine.NewListSeriesEngine(response)
} else if querySpec.IsDeleteFromSeriesQuery() || querySpec.IsDropSeriesQuery() || querySpec.IsSinglePointQuery() {
maxDeleteResults := 10000
processor = engine.NewPassthroughEngine(response, maxDeleteResults)
} else {
if self.ShouldAggregateLocally(querySpec) {
processor = engine.NewQueryEngine(querySpec.SelectQuery(), response)
} else {
maxPointsToBufferBeforeSending := 1000
processor = engine.NewPassthroughEngine(response, maxPointsToBufferBeforeSending)
}
}
err := self.localShard.Query(querySpec, processor)
processor.Close()
return err
}
healthyServers := make([]*ClusterServer, 0, len(self.clusterServers))
for _, s := range self.clusterServers {
if !s.IsUp() {
continue
}
healthyServers = append(healthyServers, s)
}
healthyCount := len(healthyServers)
if healthyCount == 0 {
message := fmt.Sprintf("No servers up to query shard %d", self.id)
response <- &protocol.Response{Type: &endStreamResponse, ErrorMessage: &message}
return errors.New(message)
}
randServerIndex := int(time.Now().UnixNano() % int64(healthyCount))
server := healthyServers[randServerIndex]
request := self.createRequest(querySpec)
return server.MakeRequest(request, response)
}
示例3: Query
func (self *ShardData) Query(querySpec *parser.QuerySpec, response chan *p.Response) {
// This is only for queries that are deletes or drops. They need to be sent everywhere as opposed to just the local or one of the remote shards.
// But this boolean should only be set to true on the server that receives the initial query.
if querySpec.RunAgainstAllServersInShard {
if querySpec.IsDeleteFromSeriesQuery() {
self.logAndHandleDeleteQuery(querySpec, response)
} else if querySpec.IsDropSeriesQuery() {
self.logAndHandleDropSeriesQuery(querySpec, response)
}
}
if self.IsLocal {
var processor QueryProcessor
var err error
if querySpec.IsListSeriesQuery() {
processor = engine.NewListSeriesEngine(response)
} else if querySpec.IsDeleteFromSeriesQuery() || querySpec.IsDropSeriesQuery() || querySpec.IsSinglePointQuery() {
maxDeleteResults := 10000
processor = engine.NewPassthroughEngine(response, maxDeleteResults)
} else {
query := querySpec.SelectQuery()
if self.ShouldAggregateLocally(querySpec) {
log.Debug("creating a query engine\n")
processor, err = engine.NewQueryEngine(query, response)
if err != nil {
response <- &p.Response{Type: &endStreamResponse, ErrorMessage: p.String(err.Error())}
log.Error("Error while creating engine: %s", err)
return
}
processor.SetShardInfo(int(self.Id()), self.IsLocal)
} else if query.HasAggregates() {
maxPointsToBufferBeforeSending := 1000
log.Debug("creating a passthrough engine\n")
processor = engine.NewPassthroughEngine(response, maxPointsToBufferBeforeSending)
} else {
maxPointsToBufferBeforeSending := 1000
log.Debug("creating a passthrough engine with limit\n")
processor = engine.NewPassthroughEngineWithLimit(response, maxPointsToBufferBeforeSending, query.Limit)
}
processor = engine.NewFilteringEngine(query, processor)
}
shard, err := self.store.GetOrCreateShard(self.id)
if err != nil {
response <- &p.Response{Type: &endStreamResponse, ErrorMessage: p.String(err.Error())}
log.Error("Error while getting shards: %s", err)
return
}
defer self.store.ReturnShard(self.id)
err = shard.Query(querySpec, processor)
processor.Close()
if err != nil {
response <- &p.Response{Type: &endStreamResponse, ErrorMessage: p.String(err.Error())}
}
response <- &p.Response{Type: &endStreamResponse}
return
}
healthyServers := make([]*ClusterServer, 0, len(self.clusterServers))
for _, s := range self.clusterServers {
if !s.IsUp() {
continue
}
healthyServers = append(healthyServers, s)
}
healthyCount := len(healthyServers)
if healthyCount == 0 {
message := fmt.Sprintf("No servers up to query shard %d", self.id)
response <- &p.Response{Type: &endStreamResponse, ErrorMessage: &message}
log.Error(message)
return
}
randServerIndex := int(time.Now().UnixNano() % int64(healthyCount))
server := healthyServers[randServerIndex]
request := self.createRequest(querySpec)
server.MakeRequest(request, response)
}