incubator-hama-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From edwardy...@apache.org
Subject svn commit: r1070720 - /incubator/hama/trunk/src/examples/org/apache/hama/examples/PiEstimator.java
Date Tue, 15 Feb 2011 01:22:20 GMT
Author: edwardyoon
Date: Tue Feb 15 01:22:20 2011
New Revision: 1070720

URL: http://svn.apache.org/viewvc?rev=1070720&view=rev
Log:
Add missed methods

Modified:
    incubator/hama/trunk/src/examples/org/apache/hama/examples/PiEstimator.java

Modified: incubator/hama/trunk/src/examples/org/apache/hama/examples/PiEstimator.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/examples/org/apache/hama/examples/PiEstimator.java?rev=1070720&r1=1070719&r2=1070720&view=diff
==============================================================================
--- incubator/hama/trunk/src/examples/org/apache/hama/examples/PiEstimator.java (original)
+++ incubator/hama/trunk/src/examples/org/apache/hama/examples/PiEstimator.java Tue Feb 15
01:22:20 2011
@@ -101,6 +101,23 @@ public class PiEstimator {
 
   }
 
+  private static void initTempDir(FileSystem fileSys) throws IOException {
+    if (fileSys.exists(TMP_OUTPUT)) {
+      fileSys.delete(TMP_OUTPUT, true);
+    }
+  }
+
+  private static void printOutput(FileSystem fileSys, HamaConfiguration conf)
+      throws IOException {
+    SequenceFile.Reader reader = new SequenceFile.Reader(fileSys, TMP_OUTPUT,
+        conf);
+    DoubleWritable output = new DoubleWritable();
+    DoubleWritable zero = new DoubleWritable();
+    reader.next(output, zero);
+    reader.close();
+
+    System.out.println("Estimated value of PI is " + output);
+  }
 
   public static void main(String[] args) throws InterruptedException,
       IOException, ClassNotFoundException {
@@ -135,7 +152,7 @@ public class PiEstimator {
 
     if (bsp.waitForCompletion(true)) {
       printOutput(fileSys, conf);
-      
+
       System.out.println("Job Finished in "
           + (double) (System.currentTimeMillis() - startTime) / 1000.0
           + " seconds");



Mime
View raw message