You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pig.apache.org by ol...@apache.org on 2008/09/05 00:26:03 UTC

svn commit: r692279 - in /incubator/pig/branches/types: CHANGES.txt src/org/apache/pig/builtin/FloatSum.java test/org/apache/pig/test/TestBuiltin.java

Author: olga
Date: Thu Sep  4 15:26:02 2008
New Revision: 692279

URL: http://svn.apache.org/viewvc?rev=692279&view=rev
Log:
PIG-413: problem with float sum

Modified:
    incubator/pig/branches/types/CHANGES.txt
    incubator/pig/branches/types/src/org/apache/pig/builtin/FloatSum.java
    incubator/pig/branches/types/test/org/apache/pig/test/TestBuiltin.java

Modified: incubator/pig/branches/types/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/pig/branches/types/CHANGES.txt?rev=692279&r1=692278&r2=692279&view=diff
==============================================================================
--- incubator/pig/branches/types/CHANGES.txt (original)
+++ incubator/pig/branches/types/CHANGES.txt Thu Sep  4 15:26:02 2008
@@ -177,3 +177,5 @@
     PIG-397: code defaults to single reducer
 
     PIG-373: unconnected load causes problem,
+
+    PIG-413: problem with float sum

Modified: incubator/pig/branches/types/src/org/apache/pig/builtin/FloatSum.java
URL: http://svn.apache.org/viewvc/incubator/pig/branches/types/src/org/apache/pig/builtin/FloatSum.java?rev=692279&r1=692278&r2=692279&view=diff
==============================================================================
--- incubator/pig/branches/types/src/org/apache/pig/builtin/FloatSum.java (original)
+++ incubator/pig/branches/types/src/org/apache/pig/builtin/FloatSum.java Thu Sep  4 15:26:02 2008
@@ -83,7 +83,7 @@
                     return null;
                 }
 
-                long sum = 0;
+                double sum = 0;
                 boolean sawNonNull = false;
                 for (Iterator<Tuple> it = values.iterator(); it.hasNext();) {
                     Tuple t = (Tuple) it.next();

Modified: incubator/pig/branches/types/test/org/apache/pig/test/TestBuiltin.java
URL: http://svn.apache.org/viewvc/incubator/pig/branches/types/test/org/apache/pig/test/TestBuiltin.java?rev=692279&r1=692278&r2=692279&view=diff
==============================================================================
--- incubator/pig/branches/types/test/org/apache/pig/test/TestBuiltin.java (original)
+++ incubator/pig/branches/types/test/org/apache/pig/test/TestBuiltin.java Thu Sep  4 15:26:02 2008
@@ -132,15 +132,30 @@
         allowedInput.put("StringMax", "String");
         expectedMap.put("String", "unit");
 
-        
+        // The idea here is that we can reuse the same input
+        // and expected output of the algebraic functions
+        // for their Initial and Final Stages 
         String[] stages = {"Initial", "Final"};
         String[] aggs = {"SUM", "DoubleSum", "IntSum", "LongSum", "FloatSum",
                         "MIN", "IntMin", "LongMin", "FloatMin", "StringMin",
                         "MAX", "IntMax", "LongMax", "FloatMax", "StringMax",};
         for (String agg : aggs) {
             for (String stage : stages) {
-                allowedInput.put(agg + stage, allowedInput.get(agg));
-                expectedMap.put(agg + stage, expectedMap.get(agg));
+                // For Int Sum Final and Float Sum Final, the input is expected
+                // be Long and Double respectively
+                if((agg + stage).equals("IntSumFinal")) {
+                    allowedInput.put(agg + stage, allowedInput.get("LongSum"));
+                    expectedMap.put(agg + stage, expectedMap.get("LongSum"));
+                } else if ((agg + stage).equals("FloatSumFinal")) {
+                    allowedInput.put(agg + stage, allowedInput.get("DoubleSum"));
+                    expectedMap.put(agg + stage, expectedMap.get("DoubleSum"));
+                } else {
+                    // In all other cases, the input and expected output
+                    // for "Initial" and "Final" stages should match the input
+                    // and expected output for the aggregate function itself
+                    allowedInput.put(agg + stage, allowedInput.get(agg));
+                    expectedMap.put(agg + stage, expectedMap.get(agg));
+                }
             }
             
         }