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

Method exec

tutorial/src/org/apache/pig/tutorial/NGramGenerator.java:48–67  ·  view source on GitHub ↗
(Tuple input)

Source from the content-addressed store, hash-verified

46 private static final int _ngramSizeLimit = 2;
47
48 public DataBag exec(Tuple input) throws IOException {
49 if (input == null || input.size() == 0)
50 return null;
51 try{
52 DataBag output = DefaultBagFactory.getInstance().newDefaultBag();
53 String query = (String)input.get(0);
54 String[] words = TutorialUtil.splitToWords(query);
55 Set<String> ngrams = new HashSet<String>();
56 TutorialUtil.makeNGram(words, ngrams, _ngramSizeLimit);
57 for (String ngram : ngrams) {
58 Tuple t = TupleFactory.getInstance().newTuple(1);
59 t.set(0, ngram);
60 output.add(t);
61 }
62 return output;
63 }catch(Exception e){
64 System.err.println("NGramGenerator: failed to process input; error - " + e.getMessage());
65 return null;
66 }
67 }
68
69 @Override
70 /**

Callers

nothing calls this directly

Calls 11

splitToWordsMethod · 0.95
makeNGramMethod · 0.95
getInstanceMethod · 0.95
setMethod · 0.95
addMethod · 0.95
sizeMethod · 0.65
getMethod · 0.65
newTupleMethod · 0.65
newDefaultBagMethod · 0.45
getInstanceMethod · 0.45
getMessageMethod · 0.45

Tested by

no test coverage detected