hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From szets...@apache.org
Subject svn commit: r956700 - in /hadoop/common/branches/branch-0.20: CHANGES.txt src/examples/org/apache/hadoop/examples/PiEstimator.java
Date Mon, 21 Jun 2010 21:20:44 GMT
Author: szetszwo
Date: Mon Jun 21 21:20:42 2010
New Revision: 956700

URL: http://svn.apache.org/viewvc?rev=956700&view=rev
Log:
MAPREDUCE-1880. Fix BigDecimal.divide(..) in the pi example.

Modified:
    hadoop/common/branches/branch-0.20/CHANGES.txt
    hadoop/common/branches/branch-0.20/src/examples/org/apache/hadoop/examples/PiEstimator.java

Modified: hadoop/common/branches/branch-0.20/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20/CHANGES.txt?rev=956700&r1=956699&r2=956700&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20/CHANGES.txt (original)
+++ hadoop/common/branches/branch-0.20/CHANGES.txt Mon Jun 21 21:20:42 2010
@@ -34,6 +34,8 @@ Release 0.20.3 - Unreleased
 
     MAPREDUCE-118. Fix Job.getJobID(). (Amareshwari Sriramadasu via sharad)
 
+    MAPREDUCE-1880. Fix BigDecimal.divide(..) in the pi example.  (szetszwo)
+
   IMPROVEMENTS
 
     MAPREDUCE-1407. Update javadoc in mapreduce.{Mapper,Reducer} to match

Modified: hadoop/common/branches/branch-0.20/src/examples/org/apache/hadoop/examples/PiEstimator.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20/src/examples/org/apache/hadoop/examples/PiEstimator.java?rev=956700&r1=956699&r2=956700&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20/src/examples/org/apache/hadoop/examples/PiEstimator.java
(original)
+++ hadoop/common/branches/branch-0.20/src/examples/org/apache/hadoop/examples/PiEstimator.java
Mon Jun 21 21:20:42 2010
@@ -20,6 +20,7 @@ package org.apache.hadoop.examples;
 
 import java.io.IOException;
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.util.Iterator;
 
 import org.apache.hadoop.conf.Configured;
@@ -310,10 +311,11 @@ public class PiEstimator extends Configu
       }
 
       //compute estimated value
+      final BigDecimal numTotal
+          = BigDecimal.valueOf(numMaps).multiply(BigDecimal.valueOf(numPoints));
       return BigDecimal.valueOf(4).setScale(20)
           .multiply(BigDecimal.valueOf(numInside.get()))
-          .divide(BigDecimal.valueOf(numMaps))
-          .divide(BigDecimal.valueOf(numPoints));
+          .divide(numTotal, RoundingMode.HALF_UP);
     } finally {
       fs.delete(TMP_DIR, true);
     }



Mime
View raw message