You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pig.apache.org by ch...@apache.org on 2012/11/07 06:58:06 UTC
svn commit: r1406469 [6/10] - in /pig/trunk: ./ test/org/apache/pig/test/
Modified: pig/trunk/test/org/apache/pig/test/TestPOGenerate.java
URL: http://svn.apache.org/viewvc/pig/trunk/test/org/apache/pig/test/TestPOGenerate.java?rev=1406469&r1=1406468&r2=1406469&view=diff
==============================================================================
--- pig/trunk/test/org/apache/pig/test/TestPOGenerate.java (original)
+++ pig/trunk/test/org/apache/pig/test/TestPOGenerate.java Wed Nov 7 05:58:04 2012
@@ -18,46 +18,30 @@
package org.apache.pig.test;
-//import static org.apache.pig.PigServer.ExecType.LOCAL;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.PrintWriter;
-import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Random;
-import junit.framework.TestCase;
-
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.fs.FSDataInputStream;
-import org.apache.hadoop.fs.FileSystem;
-import org.apache.hadoop.fs.Path;
-import org.apache.pig.LoadFunc;
-import org.apache.pig.builtin.BinStorage;
-import org.apache.pig.builtin.PigStorage;
+import org.apache.pig.backend.hadoop.executionengine.physicalLayer.POStatus;
+import org.apache.pig.backend.hadoop.executionengine.physicalLayer.PhysicalOperator;
+import org.apache.pig.backend.hadoop.executionengine.physicalLayer.Result;
+import org.apache.pig.backend.hadoop.executionengine.physicalLayer.expressionOperators.ExpressionOperator;
+import org.apache.pig.backend.hadoop.executionengine.physicalLayer.expressionOperators.POProject;
+import org.apache.pig.backend.hadoop.executionengine.physicalLayer.plans.PhysicalPlan;
+import org.apache.pig.backend.hadoop.executionengine.physicalLayer.relationalOperators.POForEach;
import org.apache.pig.data.BagFactory;
import org.apache.pig.data.DataBag;
import org.apache.pig.data.DataType;
import org.apache.pig.data.Tuple;
import org.apache.pig.data.TupleFactory;
-import org.apache.pig.impl.io.BufferedPositionedInputStream;
-import org.apache.pig.impl.io.FileSpec;
import org.apache.pig.impl.plan.OperatorKey;
-import org.apache.pig.backend.hadoop.executionengine.physicalLayer.PhysicalOperator;
-import org.apache.pig.backend.hadoop.executionengine.physicalLayer.POStatus;
-import org.apache.pig.backend.hadoop.executionengine.physicalLayer.Result;
-import org.apache.pig.backend.hadoop.executionengine.physicalLayer.plans.PhysicalPlan;
-import org.apache.pig.backend.hadoop.executionengine.physicalLayer.relationalOperators.POForEach;
-import org.apache.pig.backend.hadoop.executionengine.physicalLayer.expressionOperators.ExpressionOperator;
-import org.apache.pig.backend.hadoop.executionengine.physicalLayer.expressionOperators.POProject;
-import org.apache.pig.test.utils.GenRandomData;
import org.junit.Before;
import org.junit.Test;
-public class TestPOGenerate extends TestCase {
+public class TestPOGenerate {
DataBag cogroup;
DataBag partialFlatten;
@@ -65,7 +49,7 @@ public class TestPOGenerate extends Test
Random r = new Random();
BagFactory bf = BagFactory.getInstance();
TupleFactory tf = TupleFactory.getInstance();
-
+
@Before
public void setUp() throws Exception {
Tuple [] inputA = new Tuple[4];
@@ -113,43 +97,44 @@ public class TestPOGenerate extends Test
tIn[2].set(1, emptyBag);
tIn[3].set(0, emptyBag);
tIn[3].set(1, cg42);
-
+
cogroup = bf.newDefaultBag();
for(int i = 0; i < 4; ++i) {
cogroup.add(tIn[i]);
}
-
+
Tuple[] tPartial = new Tuple[4];
for(int i = 0; i < 4; ++i) {
tPartial[i] = tf.newTuple(2);
tPartial[i].set(0, inputA[i].get(0));
tPartial[i].set(1, inputA[i].get(1));
}
-
+
tPartial[0].append(cg12);
-
+
tPartial[1].append(cg22);
-
+
tPartial[2].append(cg12);
-
+
tPartial[3].append(emptyBag);
-
+
partialFlatten = bf.newDefaultBag();
for(int i = 0; i < 4; ++i) {
partialFlatten.add(tPartial[i]);
}
-
+
simpleGenerate = bf.newDefaultBag();
for(int i = 0; i < 4; ++i) {
simpleGenerate.add(inputA[i]);
}
-
+
//System.out.println("Cogroup : " + cogroup);
//System.out.println("Partial : " + partialFlatten);
//System.out.println("Simple : " + simpleGenerate);
-
+
}
-
+
+ @Test
public void testJoin() throws Exception {
ExpressionOperator prj1 = new POProject(new OperatorKey("", r.nextLong()), -1, 0);
ExpressionOperator prj2 = new POProject(new OperatorKey("", r.nextLong()), -1, 1);
@@ -163,13 +148,12 @@ public class TestPOGenerate extends Test
PhysicalPlan plan2 = new PhysicalPlan();
plan2.add(prj2);
List<PhysicalPlan> inputs = new LinkedList<PhysicalPlan>();
- inputs.add(plan1);
+ inputs.add(plan1);
inputs.add(plan2);
PhysicalOperator poGen = new POForEach(new OperatorKey("", r.nextLong()), 1, inputs, toBeFlattened);
//DataBag obtained = bf.newDefaultBag();
- for(Iterator<Tuple> it = cogroup.iterator(); it.hasNext(); ) {
- Tuple t = it.next();
- /*plan1.attachInput(t);
+ for (Tuple t : cogroup) {
+ /*plan1.attachInput(t);
plan2.attachInput(t);*/
poGen.attachInput(t);
Result output = poGen.getNext(t);
@@ -181,9 +165,10 @@ public class TestPOGenerate extends Test
output = poGen.getNext(t);
}
}
-
+
}
-
+
+ @Test
public void testPartialJoin() throws Exception {
ExpressionOperator prj1 = new POProject(new OperatorKey("", r.nextLong()), -1, 0);
ExpressionOperator prj2 = new POProject(new OperatorKey("", r.nextLong()), -1, 1);
@@ -197,15 +182,14 @@ public class TestPOGenerate extends Test
PhysicalPlan plan2 = new PhysicalPlan();
plan2.add(prj2);
List<PhysicalPlan> inputs = new LinkedList<PhysicalPlan>();
- inputs.add(plan1);
+ inputs.add(plan1);
inputs.add(plan2);
PhysicalOperator poGen = new POForEach(new OperatorKey("", r.nextLong()), 1, inputs, toBeFlattened);
-
+
//DataBag obtained = bf.newDefaultBag();
List<String> obtained = new LinkedList<String>();
- for(Iterator<Tuple> it = cogroup.iterator(); it.hasNext(); ) {
- Tuple t = it.next();
- /*plan1.attachInput(t);
+ for (Tuple t : cogroup) {
+ /*plan1.attachInput(t);
plan2.attachInput(t);*/
poGen.attachInput(t);
Result output = poGen.getNext(t);
@@ -216,15 +200,15 @@ public class TestPOGenerate extends Test
}
}
int count = 0;
- for(Iterator<Tuple> it = partialFlatten.iterator(); it.hasNext(); ) {
- Tuple t = it.next();
+ for (Tuple t : partialFlatten) {
assertTrue(obtained.contains(t.toString()));
++count;
}
assertEquals(partialFlatten.size(), count);
-
+
}
-
+
+ @Test
public void testSimpleGenerate() throws Exception {
ExpressionOperator prj1 = new POProject(new OperatorKey("", r.nextLong()), -1, 0);
ExpressionOperator prj2 = new POProject(new OperatorKey("", r.nextLong()), -1, 1);
@@ -238,15 +222,14 @@ public class TestPOGenerate extends Test
PhysicalPlan plan2 = new PhysicalPlan();
plan2.add(prj2);
List<PhysicalPlan> inputs = new LinkedList<PhysicalPlan>();
- inputs.add(plan1);
+ inputs.add(plan1);
inputs.add(plan2);
PhysicalOperator poGen = new POForEach(new OperatorKey("", r.nextLong()), 1, inputs, toBeFlattened);
-
+
//DataBag obtained = bf.newDefaultBag();
List<String> obtained = new LinkedList<String>();
- for(Iterator<Tuple> it = simpleGenerate.iterator(); it.hasNext(); ) {
- Tuple t = it.next();
- /*plan1.attachInput(t);
+ for (Tuple t : simpleGenerate) {
+ /*plan1.attachInput(t);
plan2.attachInput(t);*/
poGen.attachInput(t);
Result output = poGen.getNext(t);
@@ -256,14 +239,13 @@ public class TestPOGenerate extends Test
output = poGen.getNext(t);
}
}
-
+
int count = 0;
- for(Iterator<Tuple> it = simpleGenerate.iterator(); it.hasNext(); ) {
- Tuple t = it.next();
+ for (Tuple t : simpleGenerate) {
assertTrue(obtained.contains(t.toString()));
++count;
}
assertEquals(simpleGenerate.size(), count);
-
+
}
}
Modified: pig/trunk/test/org/apache/pig/test/TestPOMapLookUp.java
URL: http://svn.apache.org/viewvc/pig/trunk/test/org/apache/pig/test/TestPOMapLookUp.java?rev=1406469&r1=1406468&r2=1406469&view=diff
==============================================================================
--- pig/trunk/test/org/apache/pig/test/TestPOMapLookUp.java (original)
+++ pig/trunk/test/org/apache/pig/test/TestPOMapLookUp.java Wed Nov 7 05:58:04 2012
@@ -17,38 +17,38 @@
*/
package org.apache.pig.test;
+import static org.junit.Assert.assertEquals;
+
import java.util.Map;
import java.util.Random;
import org.apache.pig.backend.executionengine.ExecException;
-import org.apache.pig.data.Tuple;
-import org.apache.pig.data.TupleFactory;
-import org.apache.pig.impl.plan.OperatorKey;
import org.apache.pig.backend.hadoop.executionengine.physicalLayer.Result;
-import org.apache.pig.backend.hadoop.executionengine.physicalLayer.plans.PhysicalPlan;
import org.apache.pig.backend.hadoop.executionengine.physicalLayer.expressionOperators.POMapLookUp;
import org.apache.pig.backend.hadoop.executionengine.physicalLayer.expressionOperators.POProject;
+import org.apache.pig.backend.hadoop.executionengine.physicalLayer.plans.PhysicalPlan;
+import org.apache.pig.data.Tuple;
+import org.apache.pig.data.TupleFactory;
+import org.apache.pig.impl.plan.OperatorKey;
import org.apache.pig.impl.plan.PlanException;
import org.apache.pig.test.utils.GenRandomData;
import org.junit.Test;
-import junit.framework.TestCase;
+public class TestPOMapLookUp {
-public class TestPOMapLookUp extends TestCase {
-
Random r = new Random();
Map<String, Object> map;// = GenRandomData.genRandMap(r, 10);
-
+
@Test
public void testMapLookUp() throws PlanException, ExecException {
-
+
POProject prj = new POProject(new OperatorKey("", r.nextLong()), -1, 0);
POMapLookUp op = new POMapLookUp(new OperatorKey("", r.nextLong()), -1);
PhysicalPlan plan = new PhysicalPlan();
plan.add(op);
plan.add(prj);
plan.connect(prj, op);
-
+
for(int i = 0 ; i < 10; i++) {
map = GenRandomData.genRandMap(r, 10);
Tuple t = TupleFactory.getInstance().newTuple();
@@ -60,9 +60,9 @@ public class TestPOMapLookUp extends Tes
//System.out.println(e.getValue() + " : " + res.result);
assertEquals(e.getValue(), res.result);
}
-
-
+
+
}
-
+
}
}
Modified: pig/trunk/test/org/apache/pig/test/TestPONegative.java
URL: http://svn.apache.org/viewvc/pig/trunk/test/org/apache/pig/test/TestPONegative.java?rev=1406469&r1=1406468&r2=1406469&view=diff
==============================================================================
--- pig/trunk/test/org/apache/pig/test/TestPONegative.java (original)
+++ pig/trunk/test/org/apache/pig/test/TestPONegative.java Wed Nov 7 05:58:04 2012
@@ -17,6 +17,9 @@
*/
package org.apache.pig.test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
import java.io.File;
import java.util.Iterator;
import java.util.Properties;
@@ -25,26 +28,20 @@ import java.util.Random;
import org.apache.pig.ExecType;
import org.apache.pig.PigServer;
import org.apache.pig.backend.executionengine.ExecException;
+import org.apache.pig.backend.hadoop.executionengine.physicalLayer.expressionOperators.PONegative;
+import org.apache.pig.backend.hadoop.executionengine.physicalLayer.expressionOperators.POProject;
+import org.apache.pig.backend.hadoop.executionengine.physicalLayer.plans.PhysicalPlan;
import org.apache.pig.data.BagFactory;
import org.apache.pig.data.DataBag;
import org.apache.pig.data.DataType;
import org.apache.pig.data.Tuple;
import org.apache.pig.data.TupleFactory;
import org.apache.pig.impl.plan.OperatorKey;
-import org.apache.pig.backend.hadoop.executionengine.physicalLayer.plans.PhysicalPlan;
-import org.apache.pig.backend.hadoop.executionengine.physicalLayer.expressionOperators.POProject;
-import org.apache.pig.backend.hadoop.executionengine.physicalLayer.expressionOperators.PONegative;
import org.apache.pig.impl.plan.PlanException;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
-
-import junit.framework.TestCase;
-@RunWith(JUnit4.class)
-public class TestPONegative extends TestCase {
-
+public class TestPONegative {
DataBag bag = BagFactory.getInstance().newDefaultBag();
- Random r = new Random();
+ Random r = new Random(100L);
TupleFactory tf = TupleFactory.getInstance();
final int MAX = 10;
@@ -65,12 +62,11 @@ public class TestPONegative extends Test
plan.add(prj); plan.add(pn);
plan.connect(prj, pn);
- for(Iterator<Tuple> it = bag.iterator(); it.hasNext(); ) {
- Tuple t = it.next();
+ for (Tuple t : bag) {
plan.attachInput(t);
Integer expected = -(Integer)t.get(0);
- int output = (Integer) pn.getNext(expected).result;
- assertEquals(expected.intValue(), output);
+ Integer output = (Integer) pn.getNext(expected).result;
+ assertEquals(expected, output);
}
}
@@ -81,9 +77,9 @@ public class TestPONegative extends Test
t.append(r.nextInt());
bag.add(t);
if( r.nextInt(3) % 3 == 0 ){
- t = tf.newTuple();
- t.append(null);
- bag.add(t);
+ t = tf.newTuple();
+ t.append(null);
+ bag.add(t);
}
}
@@ -96,18 +92,16 @@ public class TestPONegative extends Test
plan.add(prj); plan.add(pn);
plan.connect(prj, pn);
- for(Iterator<Tuple> it = bag.iterator(); it.hasNext(); ) {
- Tuple t = it.next();
+ for (Tuple t : bag) {
plan.attachInput(t);
if(t.get(0) == null) {
Integer output = (Integer)pn.getNext((Integer)null).result;
- assertEquals(null, output);
-
+ assertNull(output);
} else {
Integer expected = -(Integer)t.get(0);
- int output = (Integer) pn.getNext(expected).result;
- assertEquals(expected.intValue(), output);
+ Integer output = (Integer) pn.getNext(expected).result;
+ assertEquals(expected, output);
}
}
}
@@ -129,8 +123,7 @@ public class TestPONegative extends Test
plan.add(prj); plan.add(pn);
plan.connect(prj, pn);
- for(Iterator<Tuple> it = bag.iterator(); it.hasNext(); ) {
- Tuple t = it.next();
+ for (Tuple t : bag) {
plan.attachInput(t);
Long expected = -(Long)t.get(0);
long output = (Long) pn.getNext(expected).result;
@@ -145,9 +138,9 @@ public class TestPONegative extends Test
t.append(r.nextLong());
bag.add(t);
if( r.nextInt(3) % 3 == 0 ){
- t = tf.newTuple();
- t.append(null);
- bag.add(t);
+ t = tf.newTuple();
+ t.append(null);
+ bag.add(t);
}
}
@@ -166,12 +159,11 @@ public class TestPONegative extends Test
if(t.get(0) == null) {
Long output = (Long)pn.getNext((Long)null).result;
- assertEquals(null, output);
-
+ assertNull(output);
} else {
- Long expected = -(Long)t.get(0);
- long output = (Long) pn.getNext(expected).result;
- assertEquals(expected.longValue(), output);
+ Long expected = -(Long)t.get(0);
+ long output = (Long) pn.getNext(expected).result;
+ assertEquals(expected.longValue(), output);
}
}
}
@@ -193,12 +185,11 @@ public class TestPONegative extends Test
plan.add(prj); plan.add(pn);
plan.connect(prj, pn);
- for(Iterator<Tuple> it = bag.iterator(); it.hasNext(); ) {
- Tuple t = it.next();
+ for (Tuple t : bag) {
plan.attachInput(t);
- Double expected = -(Double)t.get(0);
- double output = (Double) pn.getNext(expected).result;
- assertEquals(expected.doubleValue(), output);
+ Double expected = -(Double)t.get(0);
+ Double output = (Double) pn.getNext(expected).result;
+ assertEquals(expected, output);
}
}
@@ -209,9 +200,9 @@ public class TestPONegative extends Test
t.append(r.nextDouble());
bag.add(t);
if( r.nextInt(3) % 3 == 0 ){
- t = tf.newTuple();
- t.append(null);
- bag.add(t);
+ t = tf.newTuple();
+ t.append(null);
+ bag.add(t);
}
}
@@ -224,17 +215,16 @@ public class TestPONegative extends Test
plan.add(prj); plan.add(pn);
plan.connect(prj, pn);
- for(Iterator<Tuple> it = bag.iterator(); it.hasNext(); ) {
- Tuple t = it.next();
+ for (Tuple t : bag) {
plan.attachInput(t);
if(t.get(0) == null) {
- Double output = (Double )pn.getNext((Double )null).result;
- assertEquals(null, output);
+ Double output = (Double )pn.getNext((Double )null).result;
+ assertNull(output);
} else {
Double expected = -(Double)t.get(0);
- double output = (Double) pn.getNext(expected).result;
- assertEquals(expected.doubleValue(), output);
+ Double output = (Double) pn.getNext(expected).result;
+ assertEquals(expected, output);
}
}
}
@@ -256,12 +246,11 @@ public class TestPONegative extends Test
plan.add(prj); plan.add(pn);
plan.connect(prj, pn);
- for(Iterator<Tuple> it = bag.iterator(); it.hasNext(); ) {
- Tuple t = it.next();
+ for (Tuple t : bag) {
plan.attachInput(t);
Float expected = -(Float)t.get(0);
- float output = (Float) pn.getNext(expected).result;
- assertEquals(expected.floatValue(), output);
+ Float output = (Float) pn.getNext(expected).result;
+ assertEquals(expected, output);
}
}
@@ -272,9 +261,9 @@ public class TestPONegative extends Test
t.append(r.nextFloat());
bag.add(t);
if( r.nextInt(3) % 3 == 0 ){
- t = tf.newTuple();
- t.append(null);
- bag.add(t);
+ t = tf.newTuple();
+ t.append(null);
+ bag.add(t);
}
}
@@ -292,12 +281,12 @@ public class TestPONegative extends Test
plan.attachInput(t);
if(t.get(0) == null) {
- Float output = (Float)pn.getNext((Float)null).result;
- assertEquals(null, output);
+ Float output = (Float)pn.getNext((Float)null).result;
+ assertNull(output);
} else {
Float expected = -(Float)t.get(0);
- float output = (Float) pn.getNext(expected).result;
- assertEquals(expected.floatValue(), output);
+ Float output = (Float) pn.getNext(expected).result;
+ assertEquals(expected, output);
}
}
}
@@ -318,5 +307,4 @@ public class TestPONegative extends Test
}
assertEquals(3, i);
}
-
}
Modified: pig/trunk/test/org/apache/pig/test/TestPORegexp.java
URL: http://svn.apache.org/viewvc/pig/trunk/test/org/apache/pig/test/TestPORegexp.java?rev=1406469&r1=1406468&r2=1406469&view=diff
==============================================================================
--- pig/trunk/test/org/apache/pig/test/TestPORegexp.java (original)
+++ pig/trunk/test/org/apache/pig/test/TestPORegexp.java Wed Nov 7 05:58:04 2012
@@ -17,232 +17,213 @@
*/
package org.apache.pig.test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
import java.lang.reflect.Method;
import java.util.Random;
import java.util.regex.Pattern;
import org.apache.pig.backend.hadoop.executionengine.physicalLayer.expressionOperators.PORegexp;
-import org.apache.pig.backend.hadoop.executionengine.physicalLayer.expressionOperators.regex.NonConstantRegex;
import org.apache.pig.backend.hadoop.executionengine.physicalLayer.expressionOperators.regex.CompiledAutomaton;
import org.apache.pig.backend.hadoop.executionengine.physicalLayer.expressionOperators.regex.CompiledRegex;
+import org.apache.pig.backend.hadoop.executionengine.physicalLayer.expressionOperators.regex.NonConstantRegex;
import org.apache.pig.backend.hadoop.executionengine.physicalLayer.expressionOperators.regex.RegexInit;
import org.apache.pig.impl.plan.OperatorKey;
-import org.junit.Before;
import org.junit.Test;
-import junit.framework.TestCase;
-public class TestPORegexp extends TestCase {
+public class TestPORegexp {
+ static Random r = new Random(42L);
- static Random r = new Random();
-
- @Before
- @Override
- protected void setUp() throws Exception {
-
- }
-
@Test
public void testOrdering() {
- try {
- CompiledAutomaton auto2 = new CompiledAutomaton("[a-z]{3}");
- assertEquals(false, auto2.match("1234", "abc") );
- assertEquals(true, auto2.match("abc", "1234") );
-
- auto2 = new CompiledAutomaton(".*#c");
- assertEquals(true, auto2.match("ab#c", "dummy"));
-
- auto2 = new CompiledAutomaton(".*@.*");
- assertEquals(true, auto2.match("ab@c", "dummy"));
-
- auto2 = new CompiledAutomaton("abc&def");
- assertEquals(true, auto2.match("abc&def", "dummy"));
-
- auto2 = new CompiledAutomaton("abc~[ab]");
- assertEquals(true, auto2.match("abc~a", "dummy"));
-
- CompiledRegex regex2 = new CompiledRegex(Pattern.compile("[a-z]{3}"));
- assertEquals(false, regex2.match("1234", "abc") );
- assertEquals(true, regex2.match("abc", "1234") );
-
- NonConstantRegex ncr = new NonConstantRegex();
- assertEquals(false, ncr.match("1234", "abc"));
- assertEquals(false, ncr.match("abc", "1234"));
- assertEquals(true, ncr.match("1234", "\\d\\d\\d\\d"));
- assertEquals(true, ncr.match("abc", "[a-z]{3}"));
-
-
- } catch( Exception e ){
- fail();
- }
+ CompiledAutomaton auto2 = new CompiledAutomaton("[a-z]{3}");
+ assertFalse(auto2.match("1234", "abc") );
+ assertTrue(auto2.match("abc", "1234") );
+
+ auto2 = new CompiledAutomaton(".*#c");
+ assertTrue(auto2.match("ab#c", "dummy"));
+
+ auto2 = new CompiledAutomaton(".*@.*");
+ assertTrue(auto2.match("ab@c", "dummy"));
+
+ auto2 = new CompiledAutomaton("abc&def");
+ assertTrue(auto2.match("abc&def", "dummy"));
+
+ auto2 = new CompiledAutomaton("abc~[ab]");
+ assertTrue(auto2.match("abc~a", "dummy"));
+
+ CompiledRegex regex2 = new CompiledRegex(Pattern.compile("[a-z]{3}"));
+ assertFalse(regex2.match("1234", "abc") );
+ assertTrue(regex2.match("abc", "1234") );
+
+ NonConstantRegex ncr = new NonConstantRegex();
+ assertFalse(ncr.match("1234", "abc"));
+ assertFalse(ncr.match("abc", "1234"));
+ assertTrue(ncr.match("1234", "\\d\\d\\d\\d"));
+ assertTrue(ncr.match("abc", "[a-z]{3}"));
}
-
+
@Test
- public void testRegexDetermination() {
- try {
- Method m = RegexInit.class.getDeclaredMethod
- ("determineBestRegexMethod", String.class);
- m.setAccessible(true);
-
- RegexInit regex = new RegexInit(new PORegexp(new OperatorKey()));
-
- assertEquals(1, m.invoke(regex, "abc") );
-
- assertEquals(1, m.invoke(regex, "\\\\abc") );
-
- assertEquals(1, m.invoke(regex, "abc.*"));
-
- assertEquals(1, m.invoke(regex, ".*abc"));
-
- assertEquals(1, m.invoke(regex, ".*abc.*"));
-
- assertEquals(1, m.invoke(regex, ".*abc\\.*"));
-
- assertEquals(1, m.invoke(regex, ".*abc\\\\"));
-
- assertEquals(0, m.invoke(regex, ".*abc\\d"));
-
- assertEquals(0, m.invoke(regex, ".*abc\\s"));
-
- assertEquals(0, m.invoke(regex, ".*abc\\Sw"));
-
- assertEquals(0, m.invoke(regex, "abc\\Sw"));
-
- assertEquals(0, m.invoke(regex, "a\\Q"));
-
- assertEquals(0, m.invoke(regex, "\\QThis is something"));
-
- assertEquals(0, m.invoke(regex, "(\\w)*\\s\\1"));
-
- assertEquals(0, m.invoke(regex, "[^a]bc"));
-
- assertEquals(0, m.invoke(regex, "\\p{Alpha}hi"));
-
- assertEquals(0, m.invoke(regex, "\\d{1,2}hi"));
-
- assertEquals(0, m.invoke(regex, "^abc.*"));
-
- assertEquals(1, m.invoke(regex, ".*[A-F]{2,3}.*"));
-
- assertEquals(0, m.invoke(regex, "\\d+"));
-
- assertEquals(0, m.invoke(regex, "\\d{2,3}"));
-
- assertEquals(0, m.invoke(regex, "\\\\\\d{2,3}"));
-
- assertEquals(0, m.invoke(regex, ".*\\d{2,3}.*"));
-
- assertEquals(0, m.invoke(regex, "\\d\\.0\\d"));
-
- assertEquals(0, m.invoke(regex, "[^f]ed.*"));
-
- assertEquals(0, m.invoke(regex, "[a-m[n-z]]"));
-
- assertEquals(0, m.invoke(regex, "[a-z&&[def]]"));
-
- assertEquals(0, m.invoke(regex, "[a-z&&[^abc]]"));
-
- assertEquals(1, m.invoke(regex, "[a-m\\[n-z\\]"));
-
- assertEquals(1, m.invoke(regex, "[a-m\\\\\\[n-z\\\\\\]]"));
-
- assertEquals(0, m.invoke(regex, "[a-m\\\\\\[n-z\\\\\\][0-9]]"));
-
- assertEquals(0, m.invoke(regex, "[a-m\\\\[n-z]]"));
-
- assertEquals(0, m.invoke(regex, "\\\\\\[[a-m\\\\\\[n-z\\\\\\][0-9]]"));
-
- assertEquals(0, m.invoke(regex, "[a-z]??" ));
-
- assertEquals(0, m.invoke(regex, "[a-z]*?" ));
-
- assertEquals(0, m.invoke(regex, "[a-z]+?" ));
-
- assertEquals(0, m.invoke(regex, "[a-z]{4}?" ));
-
- assertEquals(0, m.invoke(regex, "[a-z]{2,4}?" ));
-
- assertEquals(1, m.invoke(regex, "[a-z]\\??" ));
-
- assertEquals(1, m.invoke(regex, "[a-z]\\*?" ));
-
- assertEquals(1, m.invoke(regex, "[a-z]\\+?" ));
-
- assertEquals(1, m.invoke(regex, "[a-z]{4\\}?" ));
-
- assertEquals(1, m.invoke(regex, "[a-z]{2,4\\}?" ));
-
- assertEquals(0, m.invoke(regex, "[a-z]?+" ));
-
- assertEquals(0, m.invoke(regex, "[a-z]*+" ));
-
- assertEquals(0, m.invoke(regex, "[a-z]++" ));
-
- assertEquals(0, m.invoke(regex, "[a-z]{4}+" ));
-
- assertEquals(0, m.invoke(regex, "[a-z]{2,4}+" ));
-
- assertEquals(1, m.invoke(regex, "[a-z]\\?+" ));
-
- assertEquals(1, m.invoke(regex, "[a-z]\\*+" ));
-
- assertEquals(1, m.invoke(regex, "[a-z]\\++" ));
-
- assertEquals(1, m.invoke(regex, "[a-z]{4\\}+" ));
-
- assertEquals(1, m.invoke(regex, "[a-z]{2,4\\}+" ));
-
- assertEquals(1, m.invoke(regex, "[a-m\\[n-z\\]]" ));
-
- assertEquals(0, m.invoke(regex, "\\0101" ));
-
- assertEquals(0, m.invoke(regex, "\\x0A" ));
-
- assertEquals(0, m.invoke(regex, "\\u000A" ));
-
- assertEquals(0, m.invoke(regex, "&&" ));
-
- assertEquals(1, m.invoke(regex, "\\&&asdkfjalsdf" ));
-
- assertEquals(0, m.invoke(regex, "&&asdf\\&&" ));
-
- assertEquals(0, m.invoke(regex, "&&asdf\\&&asdfasdf" ));
-
- assertEquals(0, m.invoke(regex, "&&asdfas\\&&asdfasdfa\\&&" ));
-
- assertEquals(0, m.invoke(regex, "&&asdflj&&" ));
-
- assertEquals(0, m.invoke(regex, "\\\\&&asdfasdf" ));
-
- assertEquals(1, m.invoke(regex, "\\\\\\&&asdfasdf" ));
-
- assertEquals(0, m.invoke(regex, "\\\\&&asdfasdf&&" ));
-
- assertEquals(0, m.invoke(regex, "\\&&asdfasdf\\\\&&" ));
-
- assertEquals(0, m.invoke(regex, "\\&&asd&&fasdf\\\\\\&&" ));
-
- assertEquals(0, m.invoke(regex, "\\dasdfasdf" ));
-
- assertEquals(1, m.invoke(regex, "\\\\dasdfasdf" ));
-
- assertEquals(0, m.invoke(regex, "\\\\dasdfasdf\\d" ));
-
- assertEquals(0, m.invoke(regex, "\\\\dasdf\\dasdf\\\\d" ));
-
- assertEquals(0, m.invoke(regex, "\\\\dasd\\\\dfasdf\\d" ));
-
- assertEquals(1, m.invoke(regex, "\\\\dasdfasdf\\" ));
-
- assertEquals(0, m.invoke(regex, "\\dasase\\\\dfasdf\\" ));
-
- assertEquals(1, m.invoke(regex, "\\\\dasdfasdf\\\\" ));
-
- assertEquals(1, m.invoke(regex, "xyz#abc") );
-
-
- } catch( Exception e ) {
- System.err.println(e.getMessage());
- fail();
- }
+ public void testRegexDetermination() throws Exception {
+ Method m = RegexInit.class.getDeclaredMethod("determineBestRegexMethod", String.class);
+ m.setAccessible(true);
+
+ RegexInit regex = new RegexInit(new PORegexp(new OperatorKey()));
+
+ assertEquals(1, m.invoke(regex, "abc") );
+
+ assertEquals(1, m.invoke(regex, "\\\\abc") );
+
+ assertEquals(1, m.invoke(regex, "abc.*"));
+
+ assertEquals(1, m.invoke(regex, ".*abc"));
+
+ assertEquals(1, m.invoke(regex, ".*abc.*"));
+
+ assertEquals(1, m.invoke(regex, ".*abc\\.*"));
+
+ assertEquals(1, m.invoke(regex, ".*abc\\\\"));
+
+ assertEquals(0, m.invoke(regex, ".*abc\\d"));
+
+ assertEquals(0, m.invoke(regex, ".*abc\\s"));
+
+ assertEquals(0, m.invoke(regex, ".*abc\\Sw"));
+
+ assertEquals(0, m.invoke(regex, "abc\\Sw"));
+
+ assertEquals(0, m.invoke(regex, "a\\Q"));
+
+ assertEquals(0, m.invoke(regex, "\\QThis is something"));
+
+ assertEquals(0, m.invoke(regex, "(\\w)*\\s\\1"));
+
+ assertEquals(0, m.invoke(regex, "[^a]bc"));
+
+ assertEquals(0, m.invoke(regex, "\\p{Alpha}hi"));
+
+ assertEquals(0, m.invoke(regex, "\\d{1,2}hi"));
+
+ assertEquals(0, m.invoke(regex, "^abc.*"));
+
+ assertEquals(1, m.invoke(regex, ".*[A-F]{2,3}.*"));
+
+ assertEquals(0, m.invoke(regex, "\\d+"));
+
+ assertEquals(0, m.invoke(regex, "\\d{2,3}"));
+
+ assertEquals(0, m.invoke(regex, "\\\\\\d{2,3}"));
+
+ assertEquals(0, m.invoke(regex, ".*\\d{2,3}.*"));
+
+ assertEquals(0, m.invoke(regex, "\\d\\.0\\d"));
+
+ assertEquals(0, m.invoke(regex, "[^f]ed.*"));
+
+ assertEquals(0, m.invoke(regex, "[a-m[n-z]]"));
+
+ assertEquals(0, m.invoke(regex, "[a-z&&[def]]"));
+
+ assertEquals(0, m.invoke(regex, "[a-z&&[^abc]]"));
+
+ assertEquals(1, m.invoke(regex, "[a-m\\[n-z\\]"));
+
+ assertEquals(1, m.invoke(regex, "[a-m\\\\\\[n-z\\\\\\]]"));
+
+ assertEquals(0, m.invoke(regex, "[a-m\\\\\\[n-z\\\\\\][0-9]]"));
+
+ assertEquals(0, m.invoke(regex, "[a-m\\\\[n-z]]"));
+
+ assertEquals(0, m.invoke(regex, "\\\\\\[[a-m\\\\\\[n-z\\\\\\][0-9]]"));
+
+ assertEquals(0, m.invoke(regex, "[a-z]??" ));
+
+ assertEquals(0, m.invoke(regex, "[a-z]*?" ));
+
+ assertEquals(0, m.invoke(regex, "[a-z]+?" ));
+
+ assertEquals(0, m.invoke(regex, "[a-z]{4}?" ));
+
+ assertEquals(0, m.invoke(regex, "[a-z]{2,4}?" ));
+
+ assertEquals(1, m.invoke(regex, "[a-z]\\??" ));
+
+ assertEquals(1, m.invoke(regex, "[a-z]\\*?" ));
+
+ assertEquals(1, m.invoke(regex, "[a-z]\\+?" ));
+
+ assertEquals(1, m.invoke(regex, "[a-z]{4\\}?" ));
+
+ assertEquals(1, m.invoke(regex, "[a-z]{2,4\\}?" ));
+
+ assertEquals(0, m.invoke(regex, "[a-z]?+" ));
+
+ assertEquals(0, m.invoke(regex, "[a-z]*+" ));
+
+ assertEquals(0, m.invoke(regex, "[a-z]++" ));
+
+ assertEquals(0, m.invoke(regex, "[a-z]{4}+" ));
+
+ assertEquals(0, m.invoke(regex, "[a-z]{2,4}+" ));
+
+ assertEquals(1, m.invoke(regex, "[a-z]\\?+" ));
+
+ assertEquals(1, m.invoke(regex, "[a-z]\\*+" ));
+
+ assertEquals(1, m.invoke(regex, "[a-z]\\++" ));
+
+ assertEquals(1, m.invoke(regex, "[a-z]{4\\}+" ));
+
+ assertEquals(1, m.invoke(regex, "[a-z]{2,4\\}+" ));
+
+ assertEquals(1, m.invoke(regex, "[a-m\\[n-z\\]]" ));
+
+ assertEquals(0, m.invoke(regex, "\\0101" ));
+
+ assertEquals(0, m.invoke(regex, "\\x0A" ));
+
+ assertEquals(0, m.invoke(regex, "\\u000A" ));
+
+ assertEquals(0, m.invoke(regex, "&&" ));
+
+ assertEquals(1, m.invoke(regex, "\\&&asdkfjalsdf" ));
+
+ assertEquals(0, m.invoke(regex, "&&asdf\\&&" ));
+
+ assertEquals(0, m.invoke(regex, "&&asdf\\&&asdfasdf" ));
+
+ assertEquals(0, m.invoke(regex, "&&asdfas\\&&asdfasdfa\\&&" ));
+
+ assertEquals(0, m.invoke(regex, "&&asdflj&&" ));
+
+ assertEquals(0, m.invoke(regex, "\\\\&&asdfasdf" ));
+
+ assertEquals(1, m.invoke(regex, "\\\\\\&&asdfasdf" ));
+
+ assertEquals(0, m.invoke(regex, "\\\\&&asdfasdf&&" ));
+
+ assertEquals(0, m.invoke(regex, "\\&&asdfasdf\\\\&&" ));
+
+ assertEquals(0, m.invoke(regex, "\\&&asd&&fasdf\\\\\\&&" ));
+
+ assertEquals(0, m.invoke(regex, "\\dasdfasdf" ));
+
+ assertEquals(1, m.invoke(regex, "\\\\dasdfasdf" ));
+
+ assertEquals(0, m.invoke(regex, "\\\\dasdfasdf\\d" ));
+
+ assertEquals(0, m.invoke(regex, "\\\\dasdf\\dasdf\\\\d" ));
+
+ assertEquals(0, m.invoke(regex, "\\\\dasd\\\\dfasdf\\d" ));
+
+ assertEquals(1, m.invoke(regex, "\\\\dasdfasdf\\" ));
+
+ assertEquals(0, m.invoke(regex, "\\dasase\\\\dfasdf\\" ));
+
+ assertEquals(1, m.invoke(regex, "\\\\dasdfasdf\\\\" ));
+
+ assertEquals(1, m.invoke(regex, "xyz#abc") );
}
-}
+}
\ No newline at end of file
Modified: pig/trunk/test/org/apache/pig/test/TestPOSort.java
URL: http://svn.apache.org/viewvc/pig/trunk/test/org/apache/pig/test/TestPOSort.java?rev=1406469&r1=1406468&r2=1406469&view=diff
==============================================================================
--- pig/trunk/test/org/apache/pig/test/TestPOSort.java (original)
+++ pig/trunk/test/org/apache/pig/test/TestPOSort.java Wed Nov 7 05:58:04 2012
@@ -17,219 +17,222 @@
*/
package org.apache.pig.test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
import java.util.LinkedList;
import java.util.List;
import java.util.Random;
-import junit.framework.TestCase;
-import junit.framework.Assert;
-
import org.apache.pig.ComparisonFunc;
import org.apache.pig.FuncSpec;
import org.apache.pig.backend.executionengine.ExecException;
-import org.apache.pig.data.*;
-import org.apache.pig.impl.plan.OperatorKey;
-import org.apache.pig.backend.hadoop.executionengine.physicalLayer.PhysicalOperator;
import org.apache.pig.backend.hadoop.executionengine.physicalLayer.POStatus;
+import org.apache.pig.backend.hadoop.executionengine.physicalLayer.PhysicalOperator;
import org.apache.pig.backend.hadoop.executionengine.physicalLayer.Result;
-import org.apache.pig.backend.hadoop.executionengine.physicalLayer.plans.PhysicalPlan;
-import org.apache.pig.test.PORead;
-import org.apache.pig.backend.hadoop.executionengine.physicalLayer.relationalOperators.POSort;
import org.apache.pig.backend.hadoop.executionengine.physicalLayer.expressionOperators.POProject;
import org.apache.pig.backend.hadoop.executionengine.physicalLayer.expressionOperators.POUserComparisonFunc;
+import org.apache.pig.backend.hadoop.executionengine.physicalLayer.plans.PhysicalPlan;
+import org.apache.pig.backend.hadoop.executionengine.physicalLayer.relationalOperators.POSort;
+import org.apache.pig.data.DataBag;
+import org.apache.pig.data.DataType;
+import org.apache.pig.data.DefaultBagFactory;
+import org.apache.pig.data.Tuple;
+import org.apache.pig.data.TupleFactory;
+import org.apache.pig.impl.plan.OperatorKey;
import org.apache.pig.test.utils.GenRandomData;
import org.junit.Test;
-public class TestPOSort extends TestCase {
- Random r = new Random();
- int MAX_TUPLES = 10;
-
- @Test
- public void testPOSortAscString() throws ExecException {
- DataBag input = (DataBag) GenRandomData.genRandSmallTupDataBag(r,
- MAX_TUPLES, 100);
- poSortAscString( input );
- }
-
- @Test
- public void testPOSortAscStringWithNull() throws ExecException {
- DataBag input = (DataBag) GenRandomData.genRandSmallTupDataBagWithNulls(r,
- MAX_TUPLES, 100);
- poSortAscString( input );
- }
-
-
-
- public void poSortAscString(DataBag input) throws ExecException {
-
- List<PhysicalPlan> sortPlans = new LinkedList<PhysicalPlan>();
- POProject pr1 = new POProject(new OperatorKey("", r.nextLong()), -1, 0);
- pr1.setResultType(DataType.CHARARRAY);
- PhysicalPlan expPlan = new PhysicalPlan();
- expPlan.add(pr1);
- sortPlans.add(expPlan);
-
- List<Boolean> mAscCols = new LinkedList<Boolean>();
- mAscCols.add(true);
- PORead read = new PORead(new OperatorKey("", r.nextLong()), input);
- List<PhysicalOperator> inputs = new LinkedList<PhysicalOperator>();
- inputs.add(read);
- POSort sort = new POSort(new OperatorKey("", r.nextLong()), -1, inputs,
- sortPlans, mAscCols, null);
-
- //verify
- Tuple t = null;
- Result res1 = sort.getNext(t);
- Result res2 = sort.getNext(t);
-
- while (res2.returnStatus != POStatus.STATUS_EOP) {
- Object i1 = ((Tuple) res1.result).get(0);
- Object i2 = ((Tuple) res2.result).get(0);
-
- //System.out.println("i1: " + i1.toString() + " i2: " + i2.toString());
- int i = DataType.compare(i1, i2);
- System.out.println("RESULT2=i : " + res2.result + " i = " + i);
- assertEquals(true, (i <= 0));
- res1 = res2;
- res2 = sort.getNext(t);
- }
- }
-
-
- @Test
- public void testPOSortDescString() throws ExecException {
- DataBag input = (DataBag) GenRandomData.genRandSmallTupDataBag(r,
- MAX_TUPLES, 100);
- poSortDescString(input);
- }
-
- @Test
- public void testPOSortDescStringWithNulls() throws ExecException {
- DataBag input = (DataBag) GenRandomData.genRandSmallTupDataBagWithNulls(r,
- MAX_TUPLES, 100);
- poSortDescString(input);
- }
-
-
- public void poSortDescString(DataBag input) throws ExecException {
-
- List<PhysicalPlan> sortPlans = new LinkedList<PhysicalPlan>();
- POProject pr1 = new POProject(new OperatorKey("", r.nextLong()), -1, 0);
- pr1.setResultType(DataType.CHARARRAY);
- PhysicalPlan expPlan = new PhysicalPlan();
- expPlan.add(pr1);
- sortPlans.add(expPlan);
- List<Boolean> mAscCols = new LinkedList<Boolean>();
- mAscCols.add(false);
- PORead read = new PORead(new OperatorKey("", r.nextLong()), input);
- List<PhysicalOperator> inputs = new LinkedList<PhysicalOperator>();
- inputs.add(read);
- POSort sort = new POSort(new OperatorKey("", r.nextLong()), -1, inputs,
- sortPlans, mAscCols, null);
- Tuple t = null;
- Result res1 = sort.getNext(t);
- // System.out.println(res1.result);
- Result res2 = sort.getNext(t);
- while (res2.returnStatus != POStatus.STATUS_EOP) {
- Object i1 = ((Tuple) res1.result).get(0);
- Object i2 = ((Tuple) res2.result).get(0);
- int i = DataType.compare(i1, i2);
- // System.out.println(res2.result + " i = " + i);
- assertEquals(true, (i >= 0));
- res1 = res2;
- res2 = sort.getNext(t);
- }
- }
-
- @Test
- public void testPOSortAsc() throws ExecException {
- DataBag input = (DataBag) GenRandomData.genRandSmallTupDataBag(r,
- MAX_TUPLES, 100);
- poSortAscInt( input );
-
- }
-
- @Test
- public void testPOSortAscWithNulls() throws ExecException {
- DataBag input = (DataBag) GenRandomData.genRandSmallTupDataBagWithNulls(r,
- MAX_TUPLES, 100);
- poSortAscInt( input );
-
- }
-
-
- public void poSortAscInt( DataBag input) throws ExecException {
-
- List<PhysicalPlan> sortPlans = new LinkedList<PhysicalPlan>();
- POProject pr1 = new POProject(new OperatorKey("", r.nextLong()), -1, 1);
- pr1.setResultType(DataType.INTEGER);
- PhysicalPlan expPlan = new PhysicalPlan();
- expPlan.add(pr1);
- sortPlans.add(expPlan);
- List<Boolean> mAscCols = new LinkedList<Boolean>();
- mAscCols.add(true);
- PORead read = new PORead(new OperatorKey("", r.nextLong()), input);
- List<PhysicalOperator> inputs = new LinkedList<PhysicalOperator>();
- inputs.add(read);
- POSort sort = new POSort(new OperatorKey("", r.nextLong()), -1, inputs,
- sortPlans, mAscCols, null);
- Tuple t = null;
- Result res1 = sort.getNext(t);
- // System.out.println(res1.result);
- Result res2 = sort.getNext(t);
- while (res2.returnStatus != POStatus.STATUS_EOP) {
- Object i1 = ((Tuple) res1.result).get(1);
- Object i2 = ((Tuple) res2.result).get(1);
- int i = DataType.compare(i1, i2);
- assertEquals(true, (i <= 0));
- // System.out.println(res2.result);
- res1 = res2;
- res2 = sort.getNext(t);
- }
- }
-
- @Test
- public void testPOSortDescInt() throws ExecException {
- DataBag input = (DataBag) GenRandomData.genRandSmallTupDataBag(r,
- MAX_TUPLES, 100);
- poSortDescInt(input );
- }
-
- @Test
- public void testPOSortDescIntWithNulls() throws ExecException {
- DataBag input = (DataBag) GenRandomData.genRandSmallTupDataBagWithNulls(r,
- MAX_TUPLES, 100);
- poSortDescInt(input );
- }
-
- public void poSortDescInt(DataBag input) throws ExecException {
- List<PhysicalPlan> sortPlans = new LinkedList<PhysicalPlan>();
- POProject pr1 = new POProject(new OperatorKey("", r.nextLong()), -1, 1);
- pr1.setResultType(DataType.INTEGER);
- PhysicalPlan expPlan = new PhysicalPlan();
- expPlan.add(pr1);
- sortPlans.add(expPlan);
- List<Boolean> mAscCols = new LinkedList<Boolean>();
- mAscCols.add(false);
- PORead read = new PORead(new OperatorKey("", r.nextLong()), input);
- List<PhysicalOperator> inputs = new LinkedList<PhysicalOperator>();
- inputs.add(read);
- POSort sort = new POSort(new OperatorKey("", r.nextLong()), -1, inputs,
- sortPlans, mAscCols, null);
- Tuple t = null;
- Result res1 = sort.getNext(t);
- // System.out.println(res1.result);
- Result res2 = sort.getNext(t);
- while (res2.returnStatus != POStatus.STATUS_EOP) {
- Object i1 = ((Tuple) res1.result).get(1);
- Object i2 = ((Tuple) res2.result).get(1);
- int i = DataType.compare(i1, i2);
- assertEquals(true, (i >= 0));
- // System.out.println(res2.result);
- res1 = res2;
- res2 = sort.getNext(t);
- }
- }
+public class TestPOSort {
+ Random r = new Random(42L);
+ int MAX_TUPLES = 10;
+
+ @Test
+ public void testPOSortAscString() throws ExecException {
+ DataBag input = (DataBag) GenRandomData.genRandSmallTupDataBag(r,
+ MAX_TUPLES, 100);
+ poSortAscString( input );
+ }
+
+ @Test
+ public void testPOSortAscStringWithNull() throws ExecException {
+ DataBag input = (DataBag) GenRandomData.genRandSmallTupDataBagWithNulls(r,
+ MAX_TUPLES, 100);
+ poSortAscString( input );
+ }
+
+
+
+ public void poSortAscString(DataBag input) throws ExecException {
+
+ List<PhysicalPlan> sortPlans = new LinkedList<PhysicalPlan>();
+ POProject pr1 = new POProject(new OperatorKey("", r.nextLong()), -1, 0);
+ pr1.setResultType(DataType.CHARARRAY);
+ PhysicalPlan expPlan = new PhysicalPlan();
+ expPlan.add(pr1);
+ sortPlans.add(expPlan);
+
+ List<Boolean> mAscCols = new LinkedList<Boolean>();
+ mAscCols.add(true);
+ PORead read = new PORead(new OperatorKey("", r.nextLong()), input);
+ List<PhysicalOperator> inputs = new LinkedList<PhysicalOperator>();
+ inputs.add(read);
+ POSort sort = new POSort(new OperatorKey("", r.nextLong()), -1, inputs,
+ sortPlans, mAscCols, null);
+
+ //verify
+ Tuple t = null;
+ Result res1 = sort.getNext(t);
+ Result res2 = sort.getNext(t);
+
+ while (res2.returnStatus != POStatus.STATUS_EOP) {
+ Object i1 = ((Tuple) res1.result).get(0);
+ Object i2 = ((Tuple) res2.result).get(0);
+
+ //System.out.println("i1: " + i1.toString() + " i2: " + i2.toString());
+ int i = DataType.compare(i1, i2);
+ System.out.println("RESULT2=i : " + res2.result + " i = " + i);
+ assertEquals(true, (i <= 0));
+ res1 = res2;
+ res2 = sort.getNext(t);
+ }
+ }
+
+
+ @Test
+ public void testPOSortDescString() throws ExecException {
+ DataBag input = (DataBag) GenRandomData.genRandSmallTupDataBag(r,
+ MAX_TUPLES, 100);
+ poSortDescString(input);
+ }
+
+ @Test
+ public void testPOSortDescStringWithNulls() throws ExecException {
+ DataBag input = (DataBag) GenRandomData.genRandSmallTupDataBagWithNulls(r,
+ MAX_TUPLES, 100);
+ poSortDescString(input);
+ }
+
+
+ public void poSortDescString(DataBag input) throws ExecException {
+
+ List<PhysicalPlan> sortPlans = new LinkedList<PhysicalPlan>();
+ POProject pr1 = new POProject(new OperatorKey("", r.nextLong()), -1, 0);
+ pr1.setResultType(DataType.CHARARRAY);
+ PhysicalPlan expPlan = new PhysicalPlan();
+ expPlan.add(pr1);
+ sortPlans.add(expPlan);
+ List<Boolean> mAscCols = new LinkedList<Boolean>();
+ mAscCols.add(false);
+ PORead read = new PORead(new OperatorKey("", r.nextLong()), input);
+ List<PhysicalOperator> inputs = new LinkedList<PhysicalOperator>();
+ inputs.add(read);
+ POSort sort = new POSort(new OperatorKey("", r.nextLong()), -1, inputs,
+ sortPlans, mAscCols, null);
+ Tuple t = null;
+ Result res1 = sort.getNext(t);
+ // System.out.println(res1.result);
+ Result res2 = sort.getNext(t);
+ while (res2.returnStatus != POStatus.STATUS_EOP) {
+ Object i1 = ((Tuple) res1.result).get(0);
+ Object i2 = ((Tuple) res2.result).get(0);
+ int i = DataType.compare(i1, i2);
+ // System.out.println(res2.result + " i = " + i);
+ assertEquals(true, (i >= 0));
+ res1 = res2;
+ res2 = sort.getNext(t);
+ }
+ }
+
+ @Test
+ public void testPOSortAsc() throws ExecException {
+ DataBag input = (DataBag) GenRandomData.genRandSmallTupDataBag(r,
+ MAX_TUPLES, 100);
+ poSortAscInt( input );
+
+ }
+
+ @Test
+ public void testPOSortAscWithNulls() throws ExecException {
+ DataBag input = (DataBag) GenRandomData.genRandSmallTupDataBagWithNulls(r,
+ MAX_TUPLES, 100);
+ poSortAscInt( input );
+
+ }
+
+
+ public void poSortAscInt( DataBag input) throws ExecException {
+
+ List<PhysicalPlan> sortPlans = new LinkedList<PhysicalPlan>();
+ POProject pr1 = new POProject(new OperatorKey("", r.nextLong()), -1, 1);
+ pr1.setResultType(DataType.INTEGER);
+ PhysicalPlan expPlan = new PhysicalPlan();
+ expPlan.add(pr1);
+ sortPlans.add(expPlan);
+ List<Boolean> mAscCols = new LinkedList<Boolean>();
+ mAscCols.add(true);
+ PORead read = new PORead(new OperatorKey("", r.nextLong()), input);
+ List<PhysicalOperator> inputs = new LinkedList<PhysicalOperator>();
+ inputs.add(read);
+ POSort sort = new POSort(new OperatorKey("", r.nextLong()), -1, inputs,
+ sortPlans, mAscCols, null);
+ Tuple t = null;
+ Result res1 = sort.getNext(t);
+ // System.out.println(res1.result);
+ Result res2 = sort.getNext(t);
+ while (res2.returnStatus != POStatus.STATUS_EOP) {
+ Object i1 = ((Tuple) res1.result).get(1);
+ Object i2 = ((Tuple) res2.result).get(1);
+ int i = DataType.compare(i1, i2);
+ assertEquals(true, (i <= 0));
+ // System.out.println(res2.result);
+ res1 = res2;
+ res2 = sort.getNext(t);
+ }
+ }
+
+ @Test
+ public void testPOSortDescInt() throws ExecException {
+ DataBag input = (DataBag) GenRandomData.genRandSmallTupDataBag(r,
+ MAX_TUPLES, 100);
+ poSortDescInt(input );
+ }
+
+ @Test
+ public void testPOSortDescIntWithNulls() throws ExecException {
+ DataBag input = (DataBag) GenRandomData.genRandSmallTupDataBagWithNulls(r,
+ MAX_TUPLES, 100);
+ poSortDescInt(input );
+ }
+
+ public void poSortDescInt(DataBag input) throws ExecException {
+ List<PhysicalPlan> sortPlans = new LinkedList<PhysicalPlan>();
+ POProject pr1 = new POProject(new OperatorKey("", r.nextLong()), -1, 1);
+ pr1.setResultType(DataType.INTEGER);
+ PhysicalPlan expPlan = new PhysicalPlan();
+ expPlan.add(pr1);
+ sortPlans.add(expPlan);
+ List<Boolean> mAscCols = new LinkedList<Boolean>();
+ mAscCols.add(false);
+ PORead read = new PORead(new OperatorKey("", r.nextLong()), input);
+ List<PhysicalOperator> inputs = new LinkedList<PhysicalOperator>();
+ inputs.add(read);
+ POSort sort = new POSort(new OperatorKey("", r.nextLong()), -1, inputs,
+ sortPlans, mAscCols, null);
+ Tuple t = null;
+ Result res1 = sort.getNext(t);
+ // System.out.println(res1.result);
+ Result res2 = sort.getNext(t);
+ while (res2.returnStatus != POStatus.STATUS_EOP) {
+ Object i1 = ((Tuple) res1.result).get(1);
+ Object i2 = ((Tuple) res2.result).get(1);
+ int i = DataType.compare(i1, i2);
+ assertEquals(true, (i >= 0));
+ // System.out.println(res2.result);
+ res1 = res2;
+ res2 = sort.getNext(t);
+ }
+ }
/***
* Sorting
@@ -237,7 +240,7 @@ public class TestPOSort extends TestCase
* (3, 8)
* (2, 8)
*
- * BY $1 DESC, $0 ASC
+ * BY $1 DESC, $0 ASC
*
* should return
* (1, 10)
@@ -295,28 +298,28 @@ public class TestPOSort extends TestCase
Result res ;
// output line 1
res = sort.getNext(t);
- Assert.assertEquals(((Tuple) res.result).get(0), 1) ;
- Assert.assertEquals(((Tuple) res.result).get(1), 10) ;
+ assertEquals(((Tuple) res.result).get(0), 1) ;
+ assertEquals(((Tuple) res.result).get(1), 10) ;
// output line 2
res = sort.getNext(t);
- Assert.assertEquals(((Tuple) res.result).get(0), 2) ;
- Assert.assertEquals(((Tuple) res.result).get(1), 8) ;
+ assertEquals(((Tuple) res.result).get(0), 2) ;
+ assertEquals(((Tuple) res.result).get(1), 8) ;
// output line 3
res = sort.getNext(t);
- Assert.assertEquals(((Tuple) res.result).get(0), 3) ;
- Assert.assertEquals(((Tuple) res.result).get(1), 8) ;
-
+ assertEquals(((Tuple) res.result).get(0), 3) ;
+ assertEquals(((Tuple) res.result).get(1), 8) ;
+
}
/***
* Sorting
* (null, 10)
- * (1, 8)
+ * (1, 8)
* (1, null)
* (null,null)
* (3, 8)
- *
- * BY $1 DESC, $0 ASC
+ *
+ * BY $1 DESC, $0 ASC
*
* should return
* (null, 10)
@@ -387,26 +390,26 @@ public class TestPOSort extends TestCase
Result res ;
// output line 1
res = sort.getNext(t);
- Assert.assertEquals(((Tuple) res.result).get(0), null) ;
- Assert.assertEquals(((Tuple) res.result).get(1), 10) ;
+ assertNull(((Tuple) res.result).get(0)) ;
+ assertEquals(((Tuple) res.result).get(1), 10) ;
// output line 2
res = sort.getNext(t);
- Assert.assertEquals(((Tuple) res.result).get(0), 1) ;
- Assert.assertEquals(((Tuple) res.result).get(1), 8) ;
+ assertEquals(((Tuple) res.result).get(0), 1) ;
+ assertEquals(((Tuple) res.result).get(1), 8) ;
// output line 3
res = sort.getNext(t);
- Assert.assertEquals(((Tuple) res.result).get(0), 3) ;
- Assert.assertEquals(((Tuple) res.result).get(1), 8) ;
+ assertEquals(((Tuple) res.result).get(0), 3) ;
+ assertEquals(((Tuple) res.result).get(1), 8) ;
// output line 4
res = sort.getNext(t);
- Assert.assertEquals(((Tuple) res.result).get(0), null) ;
- Assert.assertEquals(((Tuple) res.result).get(1), null) ;
+ assertNull(((Tuple) res.result).get(0)) ;
+ assertNull(((Tuple) res.result).get(1)) ;
// output line 5
res = sort.getNext(t);
- Assert.assertEquals(((Tuple) res.result).get(0), 1 );
- Assert.assertEquals(((Tuple) res.result).get(1), null) ;
+ assertEquals(((Tuple) res.result).get(0), 1 );
+ assertNull(((Tuple) res.result).get(1)) ;
+
-
}
/***
@@ -424,7 +427,7 @@ public class TestPOSort extends TestCase
*
* @throws ExecException
*/
-
+
@Test
@@ -476,28 +479,28 @@ public class TestPOSort extends TestCase
Result res ;
// output line 1
res = sort.getNext(t);
- Assert.assertEquals(((Tuple) res.result).get(0), 3) ;
- Assert.assertEquals(((Tuple) res.result).get(1), 5) ;
+ assertEquals(((Tuple) res.result).get(0), 3) ;
+ assertEquals(((Tuple) res.result).get(1), 5) ;
// output line 2
res = sort.getNext(t);
- Assert.assertEquals(((Tuple) res.result).get(0), 3) ;
- Assert.assertEquals(((Tuple) res.result).get(1), 8) ;
+ assertEquals(((Tuple) res.result).get(0), 3) ;
+ assertEquals(((Tuple) res.result).get(1), 8) ;
// output line 3
res = sort.getNext(t);
- Assert.assertEquals(((Tuple) res.result).get(0), 1) ;
- Assert.assertEquals(((Tuple) res.result).get(1), 2) ;
+ assertEquals(((Tuple) res.result).get(0), 1) ;
+ assertEquals(((Tuple) res.result).get(1), 2) ;
}
-
+
/***
* Sorting
* (null, 10)
- * (1, 8)
+ * (1, 8)
* (1, null)
* (null,null)
* (3, 8)
- *
- * BY $0 DESC, $1 ASC
+ *
+ * BY $0 DESC, $1 ASC
*
* should return
* (3, 8 )
@@ -567,88 +570,87 @@ public class TestPOSort extends TestCase
Result res ;
// output line 1
res = sort.getNext(t);
- Assert.assertEquals(((Tuple) res.result).get(0), 3) ;
- Assert.assertEquals(((Tuple) res.result).get(1), 8) ;
+ assertEquals(((Tuple) res.result).get(0), 3) ;
+ assertEquals(((Tuple) res.result).get(1), 8) ;
// output line 2
res = sort.getNext(t);
- Assert.assertEquals(((Tuple) res.result).get(0), 1) ;
- Assert.assertEquals(((Tuple) res.result).get(1), null) ;
+ assertEquals(((Tuple) res.result).get(0), 1) ;
+ assertNull(((Tuple) res.result).get(1)) ;
// output line 3
res = sort.getNext(t);
- Assert.assertEquals(((Tuple) res.result).get(0), 1) ;
- Assert.assertEquals(((Tuple) res.result).get(1), 8) ;
+ assertEquals(((Tuple) res.result).get(0), 1) ;
+ assertEquals(((Tuple) res.result).get(1), 8) ;
// output line 4
res = sort.getNext(t);
- Assert.assertEquals(((Tuple) res.result).get(0), null) ;
- Assert.assertEquals(((Tuple) res.result).get(1), null) ;
+ assertNull(((Tuple) res.result).get(0)) ;
+ assertNull(((Tuple) res.result).get(1)) ;
// output line 5
res = sort.getNext(t);
- Assert.assertEquals(((Tuple) res.result).get(0), null) ;
- Assert.assertEquals(((Tuple) res.result).get(1), 10) ;
+ assertNull(((Tuple) res.result).get(0)) ;
+ assertEquals(((Tuple) res.result).get(1), 10) ;
}
-
+
@Test
- public void testPOSortUDF() throws ExecException {
- DataBag input = (DataBag) GenRandomData.genRandSmallTupDataBag(r,
- MAX_TUPLES, 100);
- poSortUDFWithNull(input);
-
- }
-
- @Test
- public void testPOSortUDFWithNull() throws ExecException {
- DataBag input = (DataBag) GenRandomData.genRandSmallTupDataBagWithNulls(r,
- MAX_TUPLES, 100);
- poSortUDFWithNull(input);
-
- }
-
-
- public void poSortUDFWithNull(DataBag input) throws ExecException {
- PORead read = new PORead(new OperatorKey("", r.nextLong()), input);
- List<PhysicalOperator> inputs = new LinkedList<PhysicalOperator>();
- inputs.add(read);
- String funcName = WeirdComparator.class.getName() + "()";
- /*POUserFunc comparator = new POUserFunc(
- new OperatorKey("", r.nextLong()), -1, inputs, funcName);*/
- POUserComparisonFunc comparator = new POUserComparisonFunc(
- new OperatorKey("", r.nextLong()), -1, null, new FuncSpec(funcName));
- POSort sort = new POSort(new OperatorKey("", r.nextLong()), -1, inputs,
- null, null, comparator);
- Tuple t = null;
- Result res1 = sort.getNext(t);
- // System.out.println(res1.result);
- Result res2 = sort.getNext(t);
- while (res2.returnStatus != POStatus.STATUS_EOP) {
- int i1 = ((Integer) ((Tuple) res1.result).get(1) == null ? 0 : (Integer) ((Tuple) res1.result).get(1));
- int i2 = ((Integer) ((Tuple) res2.result).get(1) == null ? 0 : (Integer) ((Tuple) res2.result).get(1));
- int i = (i1 - 50) * (i1 - 50) - (i2 - 50) * (i2 - 50);
- assertEquals(true, (i <= 0));
- System.out.println(i + " : " + res2.result);
- res1 = res2;
- res2 = sort.getNext(t);
- }
-
- }
- // sorts values in ascending order of their distance from 50
- public static class WeirdComparator extends ComparisonFunc {
-
- @Override
- public int compare(Tuple t1, Tuple t2) {
- // TODO Auto-generated method stub
- int result = 0;
- try {
- int i1 = ((Integer) t1.get(1) == null ? 0 : (Integer)t1.get(1));
- int i2 = ((Integer) t2.get(1) == null ? 0 : (Integer)t2.get(1));
- result = (i1 - 50) * (i1 - 50) - (i2 - 50) * (i2 - 50);
- } catch (ExecException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return result;
- }
+ public void testPOSortUDF() throws ExecException {
+ DataBag input = (DataBag) GenRandomData.genRandSmallTupDataBag(r,
+ MAX_TUPLES, 100);
+ poSortUDFWithNull(input);
+
+ }
- }
+ @Test
+ public void testPOSortUDFWithNull() throws ExecException {
+ DataBag input = (DataBag) GenRandomData.genRandSmallTupDataBagWithNulls(r,
+ MAX_TUPLES, 100);
+ poSortUDFWithNull(input);
+
+ }
+
+
+ public void poSortUDFWithNull(DataBag input) throws ExecException {
+ PORead read = new PORead(new OperatorKey("", r.nextLong()), input);
+ List<PhysicalOperator> inputs = new LinkedList<PhysicalOperator>();
+ inputs.add(read);
+ String funcName = WeirdComparator.class.getName() + "()";
+ /*POUserFunc comparator = new POUserFunc(
+ new OperatorKey("", r.nextLong()), -1, inputs, funcName);*/
+ POUserComparisonFunc comparator = new POUserComparisonFunc(
+ new OperatorKey("", r.nextLong()), -1, null, new FuncSpec(funcName));
+ POSort sort = new POSort(new OperatorKey("", r.nextLong()), -1, inputs,
+ null, null, comparator);
+ Tuple t = null;
+ Result res1 = sort.getNext(t);
+ // System.out.println(res1.result);
+ Result res2 = sort.getNext(t);
+ while (res2.returnStatus != POStatus.STATUS_EOP) {
+ int i1 = ((Integer) ((Tuple) res1.result).get(1) == null ? 0 : (Integer) ((Tuple) res1.result).get(1));
+ int i2 = ((Integer) ((Tuple) res2.result).get(1) == null ? 0 : (Integer) ((Tuple) res2.result).get(1));
+ int i = (i1 - 50) * (i1 - 50) - (i2 - 50) * (i2 - 50);
+ assertEquals(true, (i <= 0));
+ System.out.println(i + " : " + res2.result);
+ res1 = res2;
+ res2 = sort.getNext(t);
+ }
+
+ }
+ // sorts values in ascending order of their distance from 50
+ public static class WeirdComparator extends ComparisonFunc {
+
+ @Override
+ public int compare(Tuple t1, Tuple t2) {
+ // TODO Auto-generated method stub
+ int result = 0;
+ try {
+ int i1 = ((Integer) t1.get(1) == null ? 0 : (Integer)t1.get(1));
+ int i2 = ((Integer) t2.get(1) == null ? 0 : (Integer)t2.get(1));
+ result = (i1 - 50) * (i1 - 50) - (i2 - 50) * (i2 - 50);
+ } catch (ExecException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return result;
+ }
+ }
}
Modified: pig/trunk/test/org/apache/pig/test/TestPOUserFunc.java
URL: http://svn.apache.org/viewvc/pig/trunk/test/org/apache/pig/test/TestPOUserFunc.java?rev=1406469&r1=1406468&r2=1406469&view=diff
==============================================================================
--- pig/trunk/test/org/apache/pig/test/TestPOUserFunc.java (original)
+++ pig/trunk/test/org/apache/pig/test/TestPOUserFunc.java Wed Nov 7 05:58:04 2012
@@ -18,37 +18,36 @@
package org.apache.pig.test;
+import static org.junit.Assert.assertEquals;
+
import java.io.IOException;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Random;
-import junit.framework.TestCase;
-
import org.apache.pig.Algebraic;
import org.apache.pig.ComparisonFunc;
import org.apache.pig.EvalFunc;
import org.apache.pig.FuncSpec;
import org.apache.pig.backend.executionengine.ExecException;
+import org.apache.pig.backend.hadoop.executionengine.physicalLayer.POStatus;
+import org.apache.pig.backend.hadoop.executionengine.physicalLayer.PhysicalOperator;
+import org.apache.pig.backend.hadoop.executionengine.physicalLayer.Result;
+import org.apache.pig.backend.hadoop.executionengine.physicalLayer.expressionOperators.POUserComparisonFunc;
+import org.apache.pig.backend.hadoop.executionengine.physicalLayer.expressionOperators.POUserFunc;
import org.apache.pig.data.BagFactory;
import org.apache.pig.data.DataBag;
import org.apache.pig.data.DataType;
import org.apache.pig.data.Tuple;
import org.apache.pig.data.TupleFactory;
-import org.apache.pig.impl.plan.OperatorKey;
import org.apache.pig.impl.logicalLayer.schema.Schema;
-import org.apache.pig.backend.hadoop.executionengine.physicalLayer.PhysicalOperator;
-import org.apache.pig.backend.hadoop.executionengine.physicalLayer.POStatus;
-import org.apache.pig.backend.hadoop.executionengine.physicalLayer.Result;
-import org.apache.pig.test.PORead;
-import org.apache.pig.backend.hadoop.executionengine.physicalLayer.expressionOperators.POUserComparisonFunc;
-import org.apache.pig.backend.hadoop.executionengine.physicalLayer.expressionOperators.POUserFunc;
+import org.apache.pig.impl.plan.OperatorKey;
import org.apache.pig.test.utils.GenRandomData;
import org.junit.Test;
-public class TestPOUserFunc extends TestCase {
- Random r = new Random();
+public class TestPOUserFunc {
+ Random r = new Random(42L);
int MAX_TUPLES = 10;
public static class ARITY extends EvalFunc<Integer> {
@@ -66,7 +65,7 @@ public class TestPOUserFunc extends Test
@Override
public Schema outputSchema(Schema input) {
- return new Schema(new Schema.FieldSchema(null, DataType.INTEGER));
+ return new Schema(new Schema.FieldSchema(null, DataType.INTEGER));
}
}
@@ -108,7 +107,7 @@ public class TestPOUserFunc extends Test
public Double exec(Tuple input) throws IOException {
double sum = 0;
double count = 0;
-
+
try {
sum = sum(input);
count = count(input);
@@ -227,7 +226,7 @@ public class TestPOUserFunc extends Test
@Override
public Schema outputSchema(Schema input) {
- return new Schema(new Schema.FieldSchema(null, DataType.DOUBLE));
+ return new Schema(new Schema.FieldSchema(null, DataType.DOUBLE));
}
}
@@ -302,7 +301,7 @@ public class TestPOUserFunc extends Test
public void testAlgebraicAVG() throws IOException, ExecException {
Integer input[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
- algebraicAVG( input, 55, 10, 110, 20, 5.5 );
+ algebraicAVG( input, 55.0, 10L, 110.0, 20L, 5.5 );
}
@@ -317,16 +316,15 @@ public class TestPOUserFunc extends Test
public void testAlgebraicAVGWithNulls() throws IOException, ExecException {
Integer input[] = { 1, 2, 3, 4, null, 6, 7, 8, 9, 10 };
- algebraicAVG( input, 50, 10, 100, 20, 5 );
+ algebraicAVG( input, 50.0, 10L, 100.0, 20L, 5.0 );
}
- @Test
- public void algebraicAVG(
- Integer[] input
- , double initialExpectedSum, long initialExpectedCount
- , double intermedExpectedSum, long intermedExpectedCount
- , double expectedAvg
+ public void algebraicAVG(
+ Integer[] input
+ , Double initialExpectedSum, Long initialExpectedCount
+ , Double intermedExpectedSum, Long intermedExpectedCount
+ , Double expectedAvg
) throws IOException, ExecException {
// generate data
@@ -355,8 +353,8 @@ public class TestPOUserFunc extends Test
: null;
System.out.println(outputInitial1 + " " + outputInitial2);
assertEquals(outputInitial1, outputInitial2);
- double sum = (Double) outputInitial1.get(0);
- long count = (Long) outputInitial1.get(1);
+ Double sum = (Double) outputInitial1.get(0);
+ Long count = (Long) outputInitial1.get(1);
assertEquals(initialExpectedSum, sum);
assertEquals(initialExpectedCount, count);
@@ -390,7 +388,7 @@ public class TestPOUserFunc extends Test
Double output = (res.returnStatus == POStatus.STATUS_OK) ? (Double) res.result
: null;
// Double output = fin.exec(outputInitial);
- assertEquals( expectedAvg, output);
+ assertEquals((Double)expectedAvg, output);
// System.out.println("output = " + output);
}