hama-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From edwardy...@apache.org
Subject svn commit: r720125 - in /incubator/hama/trunk: CHANGES.txt src/java/org/apache/hama/DenseMatrix.java src/test/org/apache/hama/TestDenseMatrix.java
Date Mon, 24 Nov 2008 07:21:39 GMT
Author: edwardyoon
Date: Sun Nov 23 23:21:39 2008
New Revision: 720125

URL: http://svn.apache.org/viewvc?rev=720125&view=rev
Log:
Implement of setColumn(int column, Vector vector)

Modified:
    incubator/hama/trunk/CHANGES.txt
    incubator/hama/trunk/src/java/org/apache/hama/DenseMatrix.java
    incubator/hama/trunk/src/test/org/apache/hama/TestDenseMatrix.java

Modified: incubator/hama/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/CHANGES.txt?rev=720125&r1=720124&r2=720125&view=diff
==============================================================================
--- incubator/hama/trunk/CHANGES.txt (original)
+++ incubator/hama/trunk/CHANGES.txt Sun Nov 23 23:21:39 2008
@@ -33,7 +33,8 @@
     
   IMPROVEMENTS
     
-    HAMA-108: Implement AbstractMatrix.add(int i, int j, double value)
+    HAMA-99: Implement setColumn(int column, Vector vector) (edwardyoon)
+    HAMA-108: Implement add(int i, int j, double value) (edwardyoon)
     HAMA-103: Reduce an rows of intermediate 
                 to improve the multiplication performance (edwardyoon)
     HAMA-88: DenseMatrix.close should not delete the table 

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=720125&r1=720124&r2=720125&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/DenseMatrix.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/DenseMatrix.java Sun Nov 23 23:21:39 2008
@@ -349,7 +349,11 @@
   }
 
   public void setColumn(int column, Vector vector) throws IOException {
-    // TODO Auto-generated method stub
+    for(int i = 0; i < vector.size(); i++) {
+      VectorUpdate update = new VectorUpdate(i);
+      update.put(column, vector.get(i));
+      table.commit(update.getBatchUpdate());
+    }
   }
 
   public String getType() {

Modified: incubator/hama/trunk/src/test/org/apache/hama/TestDenseMatrix.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/test/org/apache/hama/TestDenseMatrix.java?rev=720125&r1=720124&r2=720125&view=diff
==============================================================================
--- incubator/hama/trunk/src/test/org/apache/hama/TestDenseMatrix.java (original)
+++ incubator/hama/trunk/src/test/org/apache/hama/TestDenseMatrix.java Sun Nov 23 23:21:39
2008
@@ -199,7 +199,6 @@
     m1.setRow(SIZE + 1, v);
     Iterator<DoubleEntry> it = m1.getRow(SIZE + 1).iterator();
 
-    // We should remove the timestamp and row attribute from the vector
     int i = 0;
     while (it.hasNext()) {
       assertEquals(entries[i], it.next().getValue());
@@ -207,6 +206,24 @@
     }
   }
 
+  public void testSetColumn() throws IOException {
+    Vector v = new DenseVector();
+    double[] entries = new double[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 };
+    
+    for (int i = 0; i < SIZE; i++) {
+      v.set(i, entries[i]);
+    }
+    
+    m1.setColumn(SIZE + 1, v);
+    Iterator<DoubleEntry> it = m1.getColumn(SIZE + 1).iterator();
+
+    int i = 0;
+    while (it.hasNext()) {
+      assertEquals(entries[i], it.next().getValue());
+      i++;
+    }
+  }
+  
   public void testLoadSave() throws IOException {
     String path1 = m1.getPath();
     // save m1 to aliase1



Mime
View raw message