@Override
  public StructObjectInspector initialize(ObjectInspector[] args) throws UDFArgumentException {
    if (args.length < 2) {
      throw new UDFArgumentException("UDTFReplicateRows() expects at least two arguments.");
    }
    if (!(args[0] instanceof LongObjectInspector)) {
      throw new UDFArgumentException(
          "The first argument to UDTFReplicateRows() must be a long (got "
              + args[0].getTypeName() + " instead).");
    }

    ArrayList<String> fieldNames = new ArrayList<String>();
    ArrayList<ObjectInspector> fieldOIs = new ArrayList<ObjectInspector>();
    for (int index = 0; index < args.length; ++index) {
      fieldNames.add("col" + index);
      fieldOIs.add(args[index]);
    }
    argOIs = fieldOIs;
    return ObjectInspectorFactory.getStandardStructObjectInspector(fieldNames, fieldOIs);
  }
Takes a row of data and repeats n times.
ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDTFReplicateRows.java