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

Method exec

src/org/apache/pig/builtin/DIFF.java:54–80  ·  view source on GitHub ↗

Compares a tuple with two fields. Emits any differences. @param input a tuple with exactly two fields. @throws IOException if there are not exactly two fields in a tuple

(Tuple input)

Source from the content-addressed store, hash-verified

52 * @throws IOException if there are not exactly two fields in a tuple
53 */
54 @Override
55 public DataBag exec(Tuple input) throws IOException {
56 if (input.size() != 2) {
57 int errCode = 2107;
58 String msg = "DIFF expected two inputs but received " + input.size() + " inputs.";
59 throw new ExecException(msg, errCode, PigException.BUG);
60 }
61 try {
62 DataBag output = mBagFactory.newDefaultBag();
63 Object o1 = input.get(0);
64 if (o1 instanceof DataBag) {
65 DataBag bag1 = (DataBag)o1;
66 DataBag bag2 = (DataBag)input.get(1);
67 computeDiff(bag1, bag2, output);
68 } else {
69 Object d1 = input.get(0);
70 Object d2 = input.get(1);
71 if (!d1.equals(d2)) {
72 output.add(mTupleFactory.newTuple(d1));
73 output.add(mTupleFactory.newTuple(d2));
74 }
75 }
76 return output;
77 } catch (ExecException ee) {
78 throw ee;
79 }
80 }
81
82 private void computeDiff(
83 DataBag bag1,

Callers 1

testDIFFMethod · 0.95

Calls 7

computeDiffMethod · 0.95
addMethod · 0.95
sizeMethod · 0.65
getMethod · 0.65
newTupleMethod · 0.65
newDefaultBagMethod · 0.45
equalsMethod · 0.45

Tested by 1

testDIFFMethod · 0.76