-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #370 from influxdb/fix-370-shards-limit
Shards should be checking the limit on the query and stop returning data as soon as the limit is hit
- Loading branch information
Showing
4 changed files
with
83 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package engine | ||
|
||
import ( | ||
"parser" | ||
p "protocol" | ||
) | ||
|
||
type FilteringEngine struct { | ||
query *parser.SelectQuery | ||
processor QueryProcessor | ||
shouldFilter bool | ||
} | ||
|
||
func NewFilteringEngine(query *parser.SelectQuery, processor QueryProcessor) *FilteringEngine { | ||
shouldFilter := query.GetWhereCondition() != nil | ||
return &FilteringEngine{query, processor, shouldFilter} | ||
} | ||
|
||
// optimize for yield series and use it here | ||
func (self *FilteringEngine) YieldPoint(seriesName *string, columnNames []string, point *p.Point) bool { | ||
return self.YieldSeries(&p.Series{ | ||
Name: seriesName, | ||
Fields: columnNames, | ||
Points: []*p.Point{point}, | ||
}) | ||
} | ||
|
||
func (self *FilteringEngine) YieldSeries(seriesIncoming *p.Series) bool { | ||
if !self.shouldFilter { | ||
return self.processor.YieldSeries(seriesIncoming) | ||
} | ||
|
||
series, err := Filter(self.query, seriesIncoming) | ||
if err != nil { | ||
panic(err) | ||
} | ||
if len(series.Points) == 0 { | ||
return false | ||
} | ||
return self.processor.YieldSeries(series) | ||
} | ||
|
||
func (self *FilteringEngine) Close() { | ||
self.processor.Close() | ||
} | ||
|
||
func (self *FilteringEngine) SetShardInfo(shardId int, shardLocal bool) { | ||
self.processor.SetShardInfo(shardId, shardLocal) | ||
} | ||
func (self *FilteringEngine) GetName() string { | ||
return self.processor.GetName() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package engine | ||
|
||
import ( | ||
p "protocol" | ||
) | ||
|
||
type QueryProcessor interface { | ||
// This method returns true if the query should continue. If the query should be stopped, | ||
// like maybe the limit was hit, it should return false | ||
YieldPoint(seriesName *string, columnNames []string, point *p.Point) bool | ||
YieldSeries(seriesIncoming *p.Series) bool | ||
Close() | ||
|
||
// Set by the shard, so EXPLAIN query can know query against which shard is being measured | ||
SetShardInfo(shardId int, shardLocal bool) | ||
|
||
// Let QueryProcessor identify itself. What if it is a spy and we can't check that? | ||
GetName() string | ||
} |