func (this *sargFactory) VisitLike(expr *expression.Like) (interface{}, error) { return newSargLike(expr, expr.Regexp()), nil }
func (this *DNF) VisitLike(expr *expression.Like) (interface{}, error) { err := expr.MapChildren(this) if err != nil { return nil, err } re := expr.Regexp() if re == nil { return expr, nil } prefix, complete := re.LiteralPrefix() if complete { eq := expression.NewEq(expr.First(), expression.NewConstant(prefix)) return eq, nil } if prefix == "" { return expr, nil } var and expression.Expression le := expression.NewLE(expression.NewConstant(prefix), expr.First()) last := len(prefix) - 1 if prefix[last] < math.MaxUint8 { bytes := []byte(prefix) bytes[last]++ and = expression.NewAnd(le, expression.NewLT( expr.First(), expression.NewConstant(string(bytes)))) } else { and = expression.NewAnd(le, expression.NewLT( expr.First(), expression.EMPTY_ARRAY_EXPR)) } return and, nil }