incubator-hama-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From edwardy...@apache.org
Subject svn commit: r722847 - in /incubator/hama/trunk/src: examples/org/apache/hama/examples/ java/org/apache/hama/ java/org/apache/hama/algebra/ java/org/apache/hama/io/ java/org/apache/hama/mapred/
Date Wed, 03 Dec 2008 11:55:29 GMT
Author: edwardyoon
Date: Wed Dec  3 03:55:28 2008
New Revision: 722847

URL: http://svn.apache.org/viewvc?rev=722847&view=rev
Log:
I added some comments with trivial code changes.

Modified:
    incubator/hama/trunk/src/examples/org/apache/hama/examples/MatrixAddition.java
    incubator/hama/trunk/src/java/org/apache/hama/DenseMatrix.java
    incubator/hama/trunk/src/java/org/apache/hama/DenseVector.java
    incubator/hama/trunk/src/java/org/apache/hama/HamaAdminImpl.java
    incubator/hama/trunk/src/java/org/apache/hama/HamaConfiguration.java
    incubator/hama/trunk/src/java/org/apache/hama/SubMatrix.java
    incubator/hama/trunk/src/java/org/apache/hama/algebra/BlockCyclicMultiplyMap.java
    incubator/hama/trunk/src/java/org/apache/hama/algebra/RowCyclicAdditionMap.java
    incubator/hama/trunk/src/java/org/apache/hama/io/BlockID.java
    incubator/hama/trunk/src/java/org/apache/hama/mapred/BlockingMapRed.java

Modified: incubator/hama/trunk/src/examples/org/apache/hama/examples/MatrixAddition.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/examples/org/apache/hama/examples/MatrixAddition.java?rev=722847&r1=722846&r2=722847&view=diff
==============================================================================
--- incubator/hama/trunk/src/examples/org/apache/hama/examples/MatrixAddition.java (original)
+++ incubator/hama/trunk/src/examples/org/apache/hama/examples/MatrixAddition.java Wed Dec
 3 03:55:28 2008
@@ -40,8 +40,8 @@
       parseArgs(args);
     }
 
-    Matrix a = DenseMatrix.random(conf, row, column);
-    Matrix b = DenseMatrix.random(conf, row, column);
+    DenseMatrix a = DenseMatrix.random_mapred(conf, row, column);
+    DenseMatrix b = DenseMatrix.random_mapred(conf, row, column);
 
     Matrix c = a.add(b);
 

Modified: incubator/hama/trunk/src/java/org/apache/hama/DenseMatrix.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/java/org/apache/hama/DenseMatrix.java?rev=722847&r1=722846&r2=722847&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/DenseMatrix.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/DenseMatrix.java Wed Dec  3 03:55:28 2008
@@ -369,7 +369,7 @@
     return new DenseVector(table.getRow(BytesUtil.intToBytes(row)));
   }
 
-  public Vector getColumn(int column) throws IOException {
+  public DenseVector getColumn(int column) throws IOException {
     byte[] columnKey = BytesUtil.getColumnIndex(column);
     byte[][] c = { columnKey };
     Scanner scan = table.getScanner(c, HConstants.EMPTY_START_ROW);

Modified: incubator/hama/trunk/src/java/org/apache/hama/DenseVector.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/java/org/apache/hama/DenseVector.java?rev=722847&r1=722846&r2=722847&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/DenseVector.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/DenseVector.java Wed Dec  3 03:55:28 2008
@@ -49,7 +49,7 @@
     }
   }
 
-  public Vector add(double alpha, Vector v) {
+  public DenseVector add(double alpha, Vector v) {
     if (alpha == 0)
       return this;
 
@@ -59,7 +59,7 @@
     return this;
   }
 
-  public Vector add(Vector v2) {
+  public DenseVector add(Vector v2) {
     if (this.size() == 0) {
       DenseVector trunk = (DenseVector) v2;
       this.entries = trunk.entries;
@@ -145,8 +145,8 @@
     return 0;
   }
 
-  public Vector subVector(int i0, int i1) {
-    Vector res = new DenseVector();
+  public DenseVector subVector(int i0, int i1) {
+    DenseVector res = new DenseVector();
     for (int i = i0; i <= i1; i++) {
       res.set(i, get(i));
     }

Modified: incubator/hama/trunk/src/java/org/apache/hama/HamaAdminImpl.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/java/org/apache/hama/HamaAdminImpl.java?rev=722847&r1=722846&r2=722847&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/HamaAdminImpl.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/HamaAdminImpl.java Wed Dec  3 03:55:28 2008
@@ -41,18 +41,33 @@
   protected HBaseAdmin admin;
   protected HTable table;
 
+  /**
+   * Constructor
+   * 
+   * @param conf
+   * @throws MasterNotRunningException
+   */
   public HamaAdminImpl(HamaConfiguration conf) throws MasterNotRunningException {
     this.conf = conf;
     this.admin = new HBaseAdmin(conf);
     initialJob();
   }
 
+  /**
+   * Constructor
+   * 
+   * @param conf
+   * @param admin
+   */
   public HamaAdminImpl(HamaConfiguration conf, HBaseAdmin admin) {
     this.conf = conf;
     this.admin = admin;
     initialJob();
   }
 
+  /**
+   * Initializing the admin. 
+   */
   private void initialJob() {
     try {
       if (!admin.tableExists(Constants.ADMINTABLE)) {

Modified: incubator/hama/trunk/src/java/org/apache/hama/HamaConfiguration.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/java/org/apache/hama/HamaConfiguration.java?rev=722847&r1=722846&r2=722847&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/HamaConfiguration.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/HamaConfiguration.java Wed Dec  3 03:55:28
2008
@@ -31,7 +31,7 @@
   /** constructor */
   public HamaConfiguration() {
     super();
-    addHbaseResources();
+    addHamaResources();
   }
 
   /**
@@ -46,23 +46,46 @@
     }
   }
 
+  /**
+   * Sets the number of map task
+   * 
+   * @param map
+   */
   public void setNumMapTasks(int map) {
     set("mapred.map.tasks",String.valueOf(map));
   }
 
+  /**
+   * Sets the number of reduce task
+   * 
+   * @param map
+   */
   public void setNumReduceTasks(int reduce) {
     set("mapred.reduce.tasks",String.valueOf(reduce));
   }
   
+  /**
+   * Gets the number of map task
+   * 
+   * @param map
+   */
   public int getNumMapTasks() {
     return Integer.parseInt(get("mapred.map.tasks"));
   }
 
+  /**
+   * Gets the number of reduce task
+   * 
+   * @param map
+   */
   public int getNumReduceTasks() {
     return Integer.parseInt(get("mapred.reduce.tasks"));
   }
   
-  private void addHbaseResources() {
+  /**
+   * Adds Hama configurations
+   */
+  private void addHamaResources() {
     addResource("hama-site.xml");
   }
 }

Modified: incubator/hama/trunk/src/java/org/apache/hama/SubMatrix.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/java/org/apache/hama/SubMatrix.java?rev=722847&r1=722846&r2=722847&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/SubMatrix.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/SubMatrix.java Wed Dec  3 03:55:28 2008
@@ -62,12 +62,12 @@
     Object obj = null;
     try {
       obj = oos.readObject();
+      this.matrix = ((SubMatrix)obj).getDoubleArray();
     } catch (ClassNotFoundException e) {
       e.printStackTrace();
     }
     oos.close();
     bos.close();
-    this.matrix = ((SubMatrix)obj).matrix;
   }
   
   /**
@@ -128,14 +128,27 @@
     return new SubMatrix(C);
   }
 
+  /**
+   * Gets the number of rows
+   * 
+   * @return the number of rows
+   */
   public int getRows() {
     return this.matrix.length;
   }
 
+  /**
+   * Gets the number of columns
+   * 
+   * @return the number of columns
+   */
   public int getColumns() {
     return this.matrix[0].length;
   }
 
+  /**
+   * Close
+   */
   public void close() {
     matrix = null;
   }
@@ -149,6 +162,8 @@
   }
 
   /**
+   * Gets the bytes of the sub matrix
+   * 
    * @return the bytes of the sub matrix
    * @throws IOException
    */

Modified: incubator/hama/trunk/src/java/org/apache/hama/algebra/BlockCyclicMultiplyMap.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/java/org/apache/hama/algebra/BlockCyclicMultiplyMap.java?rev=722847&r1=722846&r2=722847&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/algebra/BlockCyclicMultiplyMap.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/algebra/BlockCyclicMultiplyMap.java Wed
Dec  3 03:55:28 2008
@@ -27,7 +27,6 @@
 import org.apache.hadoop.mapred.Reporter;
 import org.apache.hama.DenseMatrix;
 import org.apache.hama.HamaConfiguration;
-import org.apache.hama.Matrix;
 import org.apache.hama.SubMatrix;
 import org.apache.hama.io.BlockWritable;
 import org.apache.hama.mapred.BlockCyclicMap;
@@ -36,7 +35,7 @@
 public class BlockCyclicMultiplyMap extends
     BlockCyclicMap<IntWritable, BlockWritable> {
   static final Logger LOG = Logger.getLogger(BlockCyclicMultiplyMap.class);
-  protected Matrix matrix_b;
+  protected DenseMatrix matrix_b;
   public static final String MATRIX_B = "hama.multiplication.matrix.b";
 
   public void configure(JobConf job) {
@@ -65,8 +64,8 @@
       throws IOException {
     for (int i = 0; i < value.size(); i++) {
       SubMatrix a = value.get(i);
-      for (int j = 0; j < ((DenseMatrix) matrix_b).getBlockSize(); j++) {
-        SubMatrix b = ((DenseMatrix) matrix_b).getBlock(i, j);
+      for (int j = 0; j < matrix_b.getBlockSize(); j++) {
+        SubMatrix b = matrix_b.getBlock(i, j);
         SubMatrix c = a.mult(b);
         output.collect(key, new BlockWritable(key.get(), j, c));
       }

Modified: incubator/hama/trunk/src/java/org/apache/hama/algebra/RowCyclicAdditionMap.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/java/org/apache/hama/algebra/RowCyclicAdditionMap.java?rev=722847&r1=722846&r2=722847&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/algebra/RowCyclicAdditionMap.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/algebra/RowCyclicAdditionMap.java Wed Dec
 3 03:55:28 2008
@@ -26,9 +26,7 @@
 import org.apache.hadoop.mapred.OutputCollector;
 import org.apache.hadoop.mapred.Reporter;
 import org.apache.hama.DenseMatrix;
-import org.apache.hama.DenseVector;
 import org.apache.hama.HamaConfiguration;
-import org.apache.hama.Matrix;
 import org.apache.hama.io.VectorWritable;
 import org.apache.hama.mapred.RowCyclicMap;
 import org.apache.log4j.Logger;
@@ -36,7 +34,7 @@
 public class RowCyclicAdditionMap extends
     RowCyclicMap<IntWritable, VectorWritable> {
   static final Logger LOG = Logger.getLogger(RowCyclicAdditionMap.class);
-  protected Matrix matrix_b;
+  protected DenseMatrix matrix_b;
   public static final String MATRIX_B = "hama.addition.matrix.b";
 
   public void configure(JobConf job) {
@@ -65,7 +63,7 @@
       throws IOException {
 
     output.collect(key, new VectorWritable(key.get(), 
-        (DenseVector) matrix_b.getRow(key.get()).add(value.getDenseVector())));
+        matrix_b.getRow(key.get()).add(value.getDenseVector())));
 
   }
 

Modified: incubator/hama/trunk/src/java/org/apache/hama/io/BlockID.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/java/org/apache/hama/io/BlockID.java?rev=722847&r1=722846&r2=722847&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/io/BlockID.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/io/BlockID.java Wed Dec  3 03:55:28 2008
@@ -24,7 +24,6 @@
 import java.io.IOException;
 
 import org.apache.hadoop.io.WritableComparable;
-import org.apache.hadoop.io.WritableComparator;
 
 /** A WritableComparable for BlockIDs. */
 @SuppressWarnings("unchecked")

Modified: incubator/hama/trunk/src/java/org/apache/hama/mapred/BlockingMapRed.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/java/org/apache/hama/mapred/BlockingMapRed.java?rev=722847&r1=722846&r2=722847&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/mapred/BlockingMapRed.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/mapred/BlockingMapRed.java Wed Dec  3 03:55:28
2008
@@ -110,7 +110,7 @@
         startColumn = i * mBlockColSize;
         endColumn = startColumn + mBlockColSize - 1;
         output.collect(new BlockID(blkRow, i), new VectorWritable(key.get(),
-            (DenseVector) dv.subVector(startColumn, endColumn)));
+            dv.subVector(startColumn, endColumn)));
       }
     }
 



Mime
View raw message