Avoid multi-line if with a switch
parent
1b700264a7
commit
3a5baff88d
|
@ -404,15 +404,16 @@ func (m *Measurement) idsForExpr(n *influxql.BinaryExpr) (seriesIDs, bool, influ
|
|||
func (m *Measurement) walkWhereForSeriesIds(expr influxql.Expr, filters map[uint32]influxql.Expr) (seriesIDs, bool, influxql.Expr) {
|
||||
switch n := expr.(type) {
|
||||
case *influxql.BinaryExpr:
|
||||
// if it's EQ then it's either a field expression or against a tag. we can return this
|
||||
if n.Op == influxql.EQ || n.Op == influxql.LT || n.Op == influxql.LTE || n.Op == influxql.GT ||
|
||||
n.Op == influxql.GTE || n.Op == influxql.NEQ || n.Op == influxql.EQREGEX || n.Op == influxql.NEQREGEX {
|
||||
switch n.Op {
|
||||
case influxql.EQ, influxql.NEQ, influxql.LT, influxql.LTE, influxql.GT, influxql.GTE, influxql.EQREGEX, influxql.NEQREGEX:
|
||||
// if it's a compare, then it's either a field expression or against a tag. we can return this
|
||||
ids, shouldInclude, expr := m.idsForExpr(n)
|
||||
for _, id := range ids {
|
||||
filters[id] = expr
|
||||
}
|
||||
return ids, shouldInclude, expr
|
||||
} else if n.Op == influxql.AND || n.Op == influxql.OR { // if it's an AND or OR we need to union or intersect the results
|
||||
case influxql.AND, influxql.OR:
|
||||
// if it's an AND or OR we need to union or intersect the results
|
||||
var ids seriesIDs
|
||||
l, il, lexpr := m.walkWhereForSeriesIds(n.LHS, filters)
|
||||
r, ir, rexpr := m.walkWhereForSeriesIds(n.RHS, filters)
|
||||
|
|
Loading…
Reference in New Issue