From 9c2e430a728cb4ca0b18049643ad732f620ced1c Mon Sep 17 00:00:00 2001 From: "Jonathan A. Sternberg" Date: Wed, 13 Apr 2016 11:29:18 -0400 Subject: [PATCH] Removing no longer used code in the query engine --- CHANGELOG.md | 1 + influxql/result.go | 121 --------------------------------------------- 2 files changed, 1 insertion(+), 121 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 42deb127264..9978c680895 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ - [#6296](https://github.com/influxdata/influxdb/issues/6296): Allow the implicit time field to be renamed again. - [#6379](https://github.com/influxdata/influxdb/issues/6379): Validate the first argument to percentile() is a variable. - [#6294](https://github.com/influxdata/influxdb/issues/6294): Fix panic running influx_inspect info. +- [#6382](https://github.com/influxdata/influxdb/pull/6382): Removed dead code from the old query engine. ## v0.12.0 [2016-04-05] ### Release Notes diff --git a/influxql/result.go b/influxql/result.go index ea67e03c43d..9b8f2182fc5 100644 --- a/influxql/result.go +++ b/influxql/result.go @@ -82,124 +82,3 @@ func (r *Result) UnmarshalJSON(b []byte) error { } return nil } - -// GetProcessor is a Method that returns processor type and index -// based on the type of expression. -func GetProcessor(expr Expr, startIndex int) (Processor, int) { - switch expr := expr.(type) { - case *VarRef: - return newEchoProcessor(startIndex), startIndex + 1 - case *Call: - return newEchoProcessor(startIndex), startIndex + 1 - case *BinaryExpr: - return getBinaryProcessor(expr, startIndex) - case *ParenExpr: - return GetProcessor(expr.Expr, startIndex) - case *NumberLiteral: - return newLiteralProcessor(expr.Val), startIndex - case *StringLiteral: - return newLiteralProcessor(expr.Val), startIndex - case *BooleanLiteral: - return newLiteralProcessor(expr.Val), startIndex - case *TimeLiteral: - return newLiteralProcessor(expr.Val), startIndex - case *DurationLiteral: - return newLiteralProcessor(expr.Val), startIndex - } - panic("unreachable") -} - -// Processor is a prcessor type returned by GetProcessor -type Processor func(values []interface{}) interface{} - -func newEchoProcessor(index int) Processor { - return func(values []interface{}) interface{} { - if index > len(values)-1 { - return nil - } - return values[index] - } -} - -func newLiteralProcessor(val interface{}) Processor { - return func(values []interface{}) interface{} { - return val - } -} - -func getBinaryProcessor(expr *BinaryExpr, startIndex int) (Processor, int) { - lhs, index := GetProcessor(expr.LHS, startIndex) - rhs, index := GetProcessor(expr.RHS, index) - - return newBinaryExprEvaluator(expr.Op, lhs, rhs), index -} - -func newBinaryExprEvaluator(op Token, lhs, rhs Processor) Processor { - switch op { - case ADD: - return func(values []interface{}) interface{} { - l := lhs(values) - r := rhs(values) - if lf, rf, ok := processorValuesAsFloat64(l, r); ok { - return lf + rf - } - return nil - } - case SUB: - return func(values []interface{}) interface{} { - l := lhs(values) - r := rhs(values) - if lf, rf, ok := processorValuesAsFloat64(l, r); ok { - return lf - rf - } - return nil - } - case MUL: - return func(values []interface{}) interface{} { - l := lhs(values) - r := rhs(values) - if lf, rf, ok := processorValuesAsFloat64(l, r); ok { - return lf * rf - } - return nil - } - case DIV: - return func(values []interface{}) interface{} { - l := lhs(values) - r := rhs(values) - if lf, rf, ok := processorValuesAsFloat64(l, r); ok { - return lf / rf - } - return nil - } - default: - // we shouldn't get here, but give them back nils if it goes this way - return func(values []interface{}) interface{} { - return nil - } - } -} - -func processorValuesAsFloat64(lhs interface{}, rhs interface{}) (float64, float64, bool) { - var lf float64 - var rf float64 - var ok bool - - lf, ok = lhs.(float64) - if !ok { - var li int64 - if li, ok = lhs.(int64); !ok { - return 0, 0, false - } - lf = float64(li) - } - rf, ok = rhs.(float64) - if !ok { - var ri int64 - if ri, ok = rhs.(int64); !ok { - return 0, 0, false - } - rf = float64(ri) - } - return lf, rf, true -}