@Override
  public ObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException {
    if (arguments.length != 2 && arguments.length != 3) {
      throw new UDFArgumentLengthException(
          "The function LOCATE accepts exactly 2 or 3 arguments.");
    }

    for (int i = 0; i < arguments.length; i++) {
      Category category = arguments[i].getCategory();
      if (category != Category.PRIMITIVE) {
        throw new UDFArgumentTypeException(i, "The "
            + GenericUDFUtils.getOrdinal(i + 1)
            + " argument of function LOCATE is expected to a "
            + Category.PRIMITIVE.toString().toLowerCase() + " type, but "
            + category.toString().toLowerCase() + " is found");
      }
    }

    converters = new ObjectInspectorConverters.Converter[arguments.length];
    for (int i = 0; i < arguments.length; i++) {
      if (i == 0 || i == 1) {
        converters[i] = ObjectInspectorConverters.getConverter(arguments[i],
            PrimitiveObjectInspectorFactory.writableStringObjectInspector);
      } else if (i == 2) {
        converters[i] = ObjectInspectorConverters.getConverter(arguments[i],
            PrimitiveObjectInspectorFactory.writableIntObjectInspector);
      }
    }

    return PrimitiveObjectInspectorFactory.writableIntObjectInspector;
  }
Generic UDF for string function <code>LOCATE(substr, str)</code>,
<code>LOCATE(substr, str, start)</code>. This mimcs the function from MySQL
http://dev.mysql.com/doc/refman/5.1/en/string-functions.html#function_locate

<pre>
usage:
LOCATE(substr, str)
LOCATE(substr, str, start)
</pre>
<p>
ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFLocate.java