summaryrefslogtreecommitdiff
path: root/internal/mapr/wherecondition.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/mapr/wherecondition.go')
-rw-r--r--internal/mapr/wherecondition.go30
1 files changed, 15 insertions, 15 deletions
diff --git a/internal/mapr/wherecondition.go b/internal/mapr/wherecondition.go
index 7a60dba..280dcfb 100644
--- a/internal/mapr/wherecondition.go
+++ b/internal/mapr/wherecondition.go
@@ -6,7 +6,7 @@ import (
"strconv"
"strings"
- "github.com/mimecast/dtail/internal/io/logger"
+ "github.com/mimecast/dtail/internal/io/dlog"
)
// QueryOperation determines the mapreduce operation.
@@ -46,15 +46,18 @@ type whereCondition struct {
}
func (wc *whereCondition) String() string {
- return fmt.Sprintf("whereCondition(Operation:%v,lString:%s,lFloat:%v,lType:%s,rString:%s,rFloat:%v,rType:%s)",
- wc.Operation, wc.lString, wc.lFloat, wc.lType.String(), wc.rString, wc.rFloat, wc.rType.String())
+ return fmt.Sprintf("whereCondition(Operation:%v,lString:%s,lFloat:%v,"+
+ "lType:%s,rString:%s,rFloat:%v,rType:%s)",
+ wc.Operation, wc.lString, wc.lFloat, wc.lType.String(), wc.rString,
+ wc.rFloat, wc.rType.String())
}
func makeWhereConditions(tokens []token) (where []whereCondition, err error) {
parse := func(tokens []token) (whereCondition, []token, error) {
var wc whereCondition
if len(tokens) < 3 {
- return wc, nil, errors.New(invalidQuery + "Not enough arguments in 'where' clause")
+ err := errors.New(invalidQuery + "Not enough arguments in 'where' clause")
+ return wc, nil, err
}
whereOp := strings.ToLower(tokens[1].str)
@@ -94,7 +97,8 @@ func makeWhereConditions(tokens []token) (where []whereCondition, err error) {
case "nhassuffix":
wc.Operation = StringNotHasSuffix
default:
- return wc, nil, errors.New(invalidQuery + "Unknown operation in 'where' clause: " + whereOp)
+ return wc, nil, errors.New(invalidQuery +
+ "Unknown operation in 'where' clause: " + whereOp)
}
wc.lString = tokens[0].str
@@ -102,7 +106,8 @@ func makeWhereConditions(tokens []token) (where []whereCondition, err error) {
if wc.Operation > FloatOperation {
if !tokens[0].isBareword {
- return wc, nil, errors.New(invalidQuery + "Expected bareword at 'where' clause's lValue: " + tokens[0].str)
+ return wc, nil, errors.New(invalidQuery +
+ "Expected bareword at 'where' clause's lValue: " + tokens[0].str)
}
if f, err := strconv.ParseFloat(wc.lString, 64); err == nil {
wc.lFloat = f
@@ -112,7 +117,8 @@ func makeWhereConditions(tokens []token) (where []whereCondition, err error) {
}
if !tokens[2].isBareword {
- return wc, nil, errors.New(invalidQuery + "Expected bareword at 'where' clause's rValue: " + tokens[2].str)
+ return wc, nil, errors.New(invalidQuery +
+ "Expected bareword at 'where' clause's rValue: " + tokens[2].str)
}
if f, err := strconv.ParseFloat(wc.rString, 64); err == nil {
wc.rFloat = f
@@ -133,23 +139,19 @@ func makeWhereConditions(tokens []token) (where []whereCondition, err error) {
} else {
wc.rType = String
}
-
return wc, tokens[3:], nil
}
for len(tokens) > 0 {
var wc whereCondition
var err error
-
wc, tokens, err = parse(tokens)
if err != nil {
return nil, err
}
-
where = append(where, wc)
tokens = tokensConsumeOptional(tokens, "and")
}
-
return
}
@@ -168,9 +170,8 @@ func (wc *whereCondition) floatClause(lValue float64, rValue float64) bool {
case FloatGe:
return lValue >= rValue
default:
- logger.Error("Unknown float operation", lValue, wc.Operation, rValue)
+ dlog.Common.Error("Unknown float operation", lValue, wc.Operation, rValue)
}
-
return false
}
@@ -193,8 +194,7 @@ func (wc *whereCondition) stringClause(lValue string, rValue string) bool {
case StringNotHasSuffix:
return !strings.HasSuffix(lValue, rValue)
default:
- logger.Error("Unknown string operation", lValue, wc.Operation, rValue)
+ dlog.Common.Error("Unknown string operation", lValue, wc.Operation, rValue)
}
-
return false
}