Method invoked on every tuple during foreach evaluation @param input tuple; first column is assumed to have the column to convert the second column is the string we search for the third is an optional column from where to start the search @exception java.io.IO
(Tuple input)
| 48 | * @return index of first occurrence, or null in case of processing error |
| 49 | */ |
| 50 | @Override |
| 51 | public Integer exec(Tuple input) throws IOException { |
| 52 | if (input == null || input.size() < 2) { |
| 53 | warn("invalid input tuple: "+input, PigWarning.UDF_WARNING_1); |
| 54 | return null; |
| 55 | } |
| 56 | try { |
| 57 | String str = (String)input.get(0); |
| 58 | String search = (String)input.get(1); |
| 59 | int fromIndex = 0; |
| 60 | if (input.size() >=3) |
| 61 | fromIndex = (Integer)input.get(2); |
| 62 | return str.indexOf(search, fromIndex); |
| 63 | } catch(Exception e){ |
| 64 | warn("Failed to process input; error - " + e.getMessage(), PigWarning.UDF_WARNING_1); |
| 65 | return null; |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | @Override |
| 70 | public Schema outputSchema(Schema input) { |