incubator-hama-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From edwardy...@apache.org
Subject svn commit: r684691 - in /incubator/hama/trunk: ./ src/examples/org/apache/hama/examples/ src/java/org/apache/hama/ src/java/org/apache/hama/io/
Date Mon, 11 Aug 2008 09:43:38 GMT
Author: edwardyoon
Date: Mon Aug 11 02:43:36 2008
New Revision: 684691

URL: http://svn.apache.org/viewvc?rev=684691&view=rev
Log:
Vector.get() returns double

Modified:
    incubator/hama/trunk/CHANGES.txt
    incubator/hama/trunk/src/examples/org/apache/hama/examples/MatrixAddition.java
    incubator/hama/trunk/src/java/org/apache/hama/AbstractBase.java
    incubator/hama/trunk/src/java/org/apache/hama/AbstractMatrix.java
    incubator/hama/trunk/src/java/org/apache/hama/Matrix.java
    incubator/hama/trunk/src/java/org/apache/hama/Vector.java
    incubator/hama/trunk/src/java/org/apache/hama/io/VectorWritable.java

Modified: incubator/hama/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/CHANGES.txt?rev=684691&r1=684690&r2=684691&view=diff
==============================================================================
--- incubator/hama/trunk/CHANGES.txt (original)
+++ incubator/hama/trunk/CHANGES.txt Mon Aug 11 02:43:36 2008
@@ -2,7 +2,17 @@
 
 Trunk (unreleased changes)
 
-    HAMA-23: Add Hama configuration files.
+  NEW FEATURES
+
+    HAMA-25: Add matrix addition example (edwardyoon)
+    HAMA-23: Add Hama configuration files (edwardyoon)
+    HAMA-6: Add a 'who we are' page (edwardyoon)
+    HAMA-7: Add some information for a new comer (edwardyoon)
+    HAMA-1: Create the Hama web site (edwardyoon via Ian Holsman)
+    HAMA-2: The intial donation of Hama from the google project (edwardyoon)
+    
+  IMPROVEMENTS
+  
     HAMA-12: Matrix interface re-arrangement (edwardyoon)
     HAMA-21: Implement get(int index) method (edwardyoon)
     HAMA-19: Remove vector-norms enum to interface from implementation (edwardyoon)
@@ -11,26 +21,23 @@
     HAMA-10: Refactor the mapred package 
              for the latest version of dependencies (edwardyoon)  
     HAMA-9: Upgrade dependencies (edwardyoon)
-    HAMA-6: Add a 'who we are' page (edwardyoon)
-    HAMA-7: Add some information for a new comer (edwardyoon)
-    HAMA-1: Create the Hama web site (edwardyoon via Ian Holsman)
-    HAMA-2: The intial donation of Hama from the google project (edwardyoon)
+
+  BUG FIXES
+  
+    HAMA-25: Vector.get() returns double (edwardyoon)
 
 ----
 Google Code Trunk 
 
-  Improvements
-    Issue-23: add FindBugs Ant task to build script (Minslovely)
-    Issue-17: Logigng full stack (Minslovely)
-    Issue-4: Remove Groovy inteface to sandbox (Edward J. Yoon)
-    Issue-3: Code Formatter (Edward J. Yoon) 
-	
-  New Features
+  NEW FEATURES
     Issue-22: Hama project web-site	(Edward J. Yoon)
     Issue-21: Add feature vector (Edward J. Yoon)
     Issue-13: Add setDimension() method to reduce function (Edward J. Yoon) 
     Issue-7: Meta-column to store the matrix-info (Chanwit via Edward J. Yoon)
-  
-First Code Base:
-   
     Issue-1: Hama Initial Code (Edward J. Yoon)
+
+  IMPROVEMENTS
+    Issue-23: add FindBugs Ant task to build script (Minslovely)
+    Issue-17: Logigng full stack (Minslovely)
+    Issue-4: Remove Groovy inteface to sandbox (Edward J. Yoon)
+    Issue-3: Code Formatter (Edward J. Yoon) 

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=684691&r1=684690&r2=684691&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 Mon Aug
11 02:43:36 2008
@@ -36,18 +36,18 @@
     HamaConfiguration conf = new HamaConfiguration();
 
     Matrix a = Matrix.random(conf, row, column);
-    System.out.println("Create the " + row + " * " + column
-        + " random matrix A.");
     Matrix b = Matrix.random(conf, row, column);
-    System.out.println("Create the " + row + " * " + column
-        + " random matrix B.");
 
     long start = System.currentTimeMillis();
     Matrix c = a.add(b);
     long end = System.currentTimeMillis();
     System.out.println(executeTime(start, end));
-
-    System.out.println(c.get(0, 0));
+    
+    for(int i =  0; i < row; i++) {
+      for(int j =  0; j < row; j++) {
+        System.out.println(c.get(i, j));
+      }
+    }
   }
 
   public static String executeTime(long start, long end) {

Modified: incubator/hama/trunk/src/java/org/apache/hama/AbstractBase.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/java/org/apache/hama/AbstractBase.java?rev=684691&r1=684690&r2=684691&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/AbstractBase.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/AbstractBase.java Mon Aug 11 02:43:36 2008
@@ -25,4 +25,8 @@
     return Integer.parseInt(cKey
         .substring(cKey.indexOf(":") + 1, cKey.length()));
   }
+  
+  public byte[] getColumnIndex(int b) {
+    return Bytes.toBytes(Constants.COLUMN + String.valueOf(b));
+  }
 }

Modified: incubator/hama/trunk/src/java/org/apache/hama/AbstractMatrix.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/java/org/apache/hama/AbstractMatrix.java?rev=684691&r1=684690&r2=684691&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/AbstractMatrix.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/AbstractMatrix.java Mon Aug 11 02:43:36
2008
@@ -76,7 +76,7 @@
   protected void create() {
     try {
       tableDesc.addFamily(new HColumnDescriptor(Constants.METADATA.toString()));
-      LOG.info("Initializaing.");
+      LOG.info("Initializing the matrix storage.");
       admin.createTable(tableDesc);
     } catch (IOException e) {
       LOG.error(e, e);
@@ -103,8 +103,9 @@
   /** {@inheritDoc} */
   public Vector getRow(int row) {
     try {
-      return new Vector(row, table.getRow(String.valueOf(row).getBytes()));
+      return new Vector(row, table.getRow(String.valueOf(row)));
     } catch (IOException e) {
+      // TODO Auto-generated catch block
       e.printStackTrace();
     }
     return null;
@@ -119,7 +120,7 @@
     }
     return null;
   }
-  
+
   /** {@inheritDoc} */
   public int getRows() {
     Cell rows = null;

Modified: incubator/hama/trunk/src/java/org/apache/hama/Matrix.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/java/org/apache/hama/Matrix.java?rev=684691&r1=684690&r2=684691&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/Matrix.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/Matrix.java Mon Aug 11 02:43:36 2008
@@ -113,7 +113,8 @@
    * @return an m-by-n matrix with uniformly distributed random elements.
    */
   public static Matrix random(HamaConfiguration conf, int m, int n) {
-    Matrix rand = new Matrix(conf, RandomVariable.randMatrixName());
+    Text name = RandomVariable.randMatrixName();
+    Matrix rand = new Matrix(conf, name);
     for (int i = 0; i < m; i++) {
       for (int j = 0; j < n; j++) {
         rand.set(i, j, RandomVariable.rand());
@@ -121,6 +122,7 @@
     }
 
     rand.setDimension(m, n);
+    LOG.info("Create the " + m + " * " + n + " random matrix : " + name);
     return rand;
   }
 

Modified: incubator/hama/trunk/src/java/org/apache/hama/Vector.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/java/org/apache/hama/Vector.java?rev=684691&r1=684690&r2=684691&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/Vector.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/Vector.java Mon Aug 11 02:43:36 2008
@@ -78,7 +78,7 @@
   }
 
   public double get(int index) {
-    return bytesToInt(this.cells.get(intToBytes(index)).getValue());
+    return bytesToDouble(this.cells.get(getColumnIndex(index)).getValue());
   }
 
   public double norm(Norm type) {

Modified: incubator/hama/trunk/src/java/org/apache/hama/io/VectorWritable.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/java/org/apache/hama/io/VectorWritable.java?rev=684691&r1=684690&r2=684691&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/io/VectorWritable.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/io/VectorWritable.java Mon Aug 11 02:43:36
2008
@@ -20,19 +20,24 @@
 import org.apache.hadoop.io.Writable;
 import org.apache.hama.AbstractBase;
 import org.apache.hama.Vector;
+import org.apache.log4j.Logger;
 
 public class VectorWritable extends AbstractBase implements Writable,
     Map<byte[], Cell> {
+  static final Logger LOG = Logger.getLogger(VectorWritable.class);
   public byte[] row;
   public HbaseMapWritable<byte[], Cell> cells;
   public int[] m_dims;
   public double[] m_vals;
 
   public void parse(Set<Entry<byte[], Cell>> entrySet) {
+    this.cells = new HbaseMapWritable<byte[], Cell>();
+    
     SortedMap<Integer, Double> m = new TreeMap<Integer, Double>();
     for (Map.Entry<byte[], Cell> f : entrySet) {
       m.put(getColumnIndex(f.getKey()), Double.parseDouble(Bytes.toString(f
           .getValue().getValue())));
+      this.cells.put(f.getKey(), f.getValue());
     }
 
     this.m_dims = new int[m.keySet().size()];
@@ -134,7 +139,7 @@
   }
 
   public int size() {
-    //return this.cells.size();
+    // return this.cells.size();
     return m_dims.length;
   }
 



Mime
View raw message