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

Method testDIFF

test/org/apache/pig/test/TestBuiltin.java:2824–2860  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2822 }
2823
2824 @Test
2825 public void testDIFF() throws Exception {
2826 // Test it in the case with two bags.
2827 BagFactory bf = BagFactory.getInstance();
2828 TupleFactory tf = TupleFactory.getInstance();
2829
2830 DataBag b1 = bf.newDefaultBag();
2831 DataBag b2 = bf.newDefaultBag();
2832 for (int i = 0; i < 10; i++) b1.add(tf.newTuple(new Integer(i)));
2833 for (int i = 0; i < 10; i += 2) b2.add(tf.newTuple(new Integer(i)));
2834 Tuple t = tf.newTuple(2);
2835 t.set(0, b1);
2836 t.set(1, b2);
2837 DIFF d = new DIFF();
2838 DataBag result = d.exec(t);
2839
2840 assertEquals(5, result.size());
2841 Iterator<Tuple> i = result.iterator();
2842 int[] values = new int[5];
2843 for (int j = 0; j < 5; j++) values[j] = (Integer)i.next().get(0);
2844 Arrays.sort(values);
2845 for (int j = 1; j < 10; j += 2) assertEquals(j, values[j/2]);
2846
2847 // Test it in the case of two objects that are equals
2848 t = tf.newTuple(2);
2849 t.set(0, new Integer(1));
2850 t.set(1, new Integer(1));
2851 result = d.exec(t);
2852 assertEquals(0, result.size());
2853
2854 // Test it in the case of two objects that are not equal
2855 t = tf.newTuple(2);
2856 t.set(0, new Integer(1));
2857 t.set(1, new Integer(2));
2858 result = d.exec(t);
2859 assertEquals(2, result.size());
2860 }
2861
2862 //see PIG-2331
2863 @Test

Callers

nothing calls this directly

Calls 13

getInstanceMethod · 0.95
getInstanceMethod · 0.95
newDefaultBagMethod · 0.95
addMethod · 0.95
newTupleMethod · 0.95
setMethod · 0.95
execMethod · 0.95
sizeMethod · 0.95
iteratorMethod · 0.95
sortMethod · 0.80
getMethod · 0.65
assertEqualsMethod · 0.45

Tested by

no test coverage detected