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

Method exec

src/org/apache/pig/builtin/COUNT.java:57–79  ·  view source on GitHub ↗
(Tuple input)

Source from the content-addressed store, hash-verified

55 private static TupleFactory mTupleFactory = TupleFactory.getInstance();
56
57 @Override
58 public Long exec(Tuple input) throws IOException {
59 try {
60 DataBag bag = (DataBag)input.get(0);
61 if(bag==null)
62 return null;
63
64 Iterator it = bag.iterator();
65 long cnt = 0;
66 while (it.hasNext()){
67 Tuple t = (Tuple)it.next();
68 if (t != null && t.size() > 0 && t.get(0) != null )
69 cnt++;
70 }
71 return cnt;
72 } catch (ExecException ee) {
73 throw ee;
74 } catch (Exception e) {
75 int errCode = 2106;
76 String msg = "Error while computing count in " + this.getClass().getSimpleName();
77 throw new ExecException(msg, errCode, PigException.BUG, e);
78 }
79 }
80
81 public String getInitial() {
82 return Initial.class.getName();

Callers 2

testCOUNTMethod · 0.95
testCOUNTBagNullCheckMethod · 0.95

Calls 6

getMethod · 0.95
iteratorMethod · 0.95
sizeMethod · 0.95
getClassMethod · 0.80
hasNextMethod · 0.45
nextMethod · 0.45

Tested by 2

testCOUNTMethod · 0.76
testCOUNTBagNullCheckMethod · 0.76