MCPcopy Create free account
hub / github.com/apache/pig / exec

Method exec

src/org/apache/pig/builtin/INDEXOF.java:50–67  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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) {

Callers 2

testINDEXOFMethod · 0.95
testIndexOfMethod · 0.95

Calls 4

sizeMethod · 0.65
warnMethod · 0.65
getMethod · 0.65
getMessageMethod · 0.45

Tested by 2

testINDEXOFMethod · 0.76
testIndexOfMethod · 0.76