private String generateCandidate(Random control, String pattern) {
    StringBuilder sb = new StringBuilder();
    final StringTokenizer tokens = new StringTokenizer(pattern, "%");
    final boolean leftAnchor = pattern.startsWith("%");
    final boolean rightAnchor = pattern.endsWith("%");
    for (int i = 0; tokens.hasMoreTokens(); i++) {
      String chunk = tokens.nextToken();
      if (leftAnchor && i == 0) {
        // first item
        sb.append(randomizePattern(control, chunk));
      } else if (rightAnchor && tokens.hasMoreTokens() == false) {
        // last item
        sb.append(randomizePattern(control, chunk));
      } else {
        // middle item
        sb.append(randomizePattern(control, chunk));
      }
    }
    return sb.toString();
  }
Test vectorized expression and filter evaluation for strings.
ql/src/test/org/apache/hadoop/hive/ql/exec/vector/expressions/TestVectorStringExpressions.java