public BooleanWritable evaluate(Text s, Text likePattern) {
    if (s == null || likePattern == null) {
      return null;
    }
    if (!likePattern.equals(lastLikePattern)) {
      lastLikePattern.set(likePattern);
      String strLikePattern = likePattern.toString();

      parseSimplePattern(strLikePattern);
      if (type == PatternType.COMPLEX) {
        p = Pattern.compile(likePatternToRegExp(strLikePattern), Pattern.DOTALL);
      }
    }

    if (type == PatternType.COMPLEX) {
      Matcher m = p.matcher(s.toString());
      result.set(m.matches());
    } else {
      int startS = 0;
      int endS = s.getLength();
      // if s is shorter than the required pattern
      if (endS < simplePattern.getLength()) {
        result.set(false);
        return result;
      }
      switch (type) {
      case BEGIN:
        endS = simplePattern.getLength();
        break;
      case END:
        startS = endS - simplePattern.getLength();
        break;
      case NONE:
        if (simplePattern.getLength() != s.getLength()) {
          result.set(false);
          return result;
        }
        break;
      }
      result.set(find(s, simplePattern, startS, endS));
    }
    return result;
  }
Parses the likePattern. Based on it is a simple pattern or not, the
function might change two member variables. {@link #type} will be changed
to the corresponding pattern type; {@link #simplePattern} will record the
string in it for later pattern matching if it is a simple pattern.
<p>
Examples: <blockquote>

<pre>
parseSimplePattern("%abc%") changes {@link #type} to PatternType.MIDDLE
and changes {@link #simplePattern} to "abc"
parseSimplePattern("%ab_c%") changes {@link #type} to PatternType.COMPLEX
and does not change {@link #simplePattern}
</pre>

</blockquote>

@param likePattern
         the input LIKE query pattern
ql/src/java/org/apache/hadoop/hive/ql/udf/UDFLike.java