incubator-hama-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From edwardy...@apache.org
Subject svn commit: r915672 - in /incubator/hama/trunk: ./ src/java/org/apache/hama/ src/java/org/apache/hama/io/ src/java/org/apache/hama/mapreduce/ src/java/org/apache/hama/matrix/ src/java/org/apache/hama/matrix/algebra/
Date Wed, 24 Feb 2010 05:03:51 GMT
Author: edwardyoon
Date: Wed Feb 24 05:03:50 2010
New Revision: 915672

URL: http://svn.apache.org/viewvc?rev=915672&view=rev
Log:
Remove unused class  

Removed:
    incubator/hama/trunk/src/java/org/apache/hama/io/VectorUpdate.java
Modified:
    incubator/hama/trunk/CHANGES.txt
    incubator/hama/trunk/src/java/org/apache/hama/HamaMaster.java
    incubator/hama/trunk/src/java/org/apache/hama/mapreduce/RandomMatrixReducer.java
    incubator/hama/trunk/src/java/org/apache/hama/mapreduce/RotationInputFormat.java
    incubator/hama/trunk/src/java/org/apache/hama/matrix/AbstractMatrix.java
    incubator/hama/trunk/src/java/org/apache/hama/matrix/DenseMatrix.java
    incubator/hama/trunk/src/java/org/apache/hama/matrix/SparseMatrix.java
    incubator/hama/trunk/src/java/org/apache/hama/matrix/algebra/BlockMultReduce.java
    incubator/hama/trunk/src/java/org/apache/hama/matrix/algebra/DenseMatrixVectorMultReduce.java
    incubator/hama/trunk/src/java/org/apache/hama/matrix/algebra/JacobiInitMap.java
    incubator/hama/trunk/src/java/org/apache/hama/matrix/algebra/MatrixAdditionReduce.java
    incubator/hama/trunk/src/java/org/apache/hama/matrix/algebra/SparseMatrixVectorMultReduce.java
    incubator/hama/trunk/src/java/org/apache/hama/matrix/algebra/TransposeReduce.java

Modified: incubator/hama/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/CHANGES.txt?rev=915672&r1=915671&r2=915672&view=diff
==============================================================================
--- incubator/hama/trunk/CHANGES.txt (original)
+++ incubator/hama/trunk/CHANGES.txt Wed Feb 24 05:03:50 2010
@@ -42,6 +42,7 @@
 
   IMPROVEMENTS
 
+    HAMA-239: Remove unused class (edwardyoon)
     HAMA-237: Add project blog link on website (edwardyoon)
     HAMA-236: Add recent news on website (edwardyoon)
     HAMA-232: Add file multiplication example (edwardyoon)

Modified: incubator/hama/trunk/src/java/org/apache/hama/HamaMaster.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/java/org/apache/hama/HamaMaster.java?rev=915672&r1=915671&r2=915672&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/HamaMaster.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/HamaMaster.java Wed Feb 24 05:03:50 2010
@@ -32,7 +32,6 @@
 import org.apache.hadoop.fs.permission.FsPermission;
 import org.apache.hadoop.ipc.RPC;
 import org.apache.hadoop.ipc.Server;
-import org.apache.hadoop.mapred.JobTracker;
 import org.apache.hadoop.net.NetUtils;
 import org.apache.hadoop.security.AccessControlException;
 import org.apache.hadoop.util.StringUtils;

Modified: incubator/hama/trunk/src/java/org/apache/hama/mapreduce/RandomMatrixReducer.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/java/org/apache/hama/mapreduce/RandomMatrixReducer.java?rev=915672&r1=915671&r2=915672&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/mapreduce/RandomMatrixReducer.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/mapreduce/RandomMatrixReducer.java Wed Feb
24 05:03:50 2010
@@ -1,13 +1,17 @@
 package org.apache.hama.mapreduce;
 
 import java.io.IOException;
+import java.util.Map;
 
+import org.apache.hadoop.hbase.client.Put;
 import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
 import org.apache.hadoop.hbase.mapreduce.TableReducer;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.io.DoubleWritable;
 import org.apache.hadoop.io.IntWritable;
 import org.apache.hadoop.io.MapWritable;
 import org.apache.hadoop.io.Writable;
-import org.apache.hama.io.VectorUpdate;
+import org.apache.hama.Constants;
 import org.apache.hama.util.BytesUtil;
 import org.apache.log4j.Logger;
 
@@ -17,9 +21,14 @@
 
   public void reduce(IntWritable key, Iterable<MapWritable> values,
       Context context) throws IOException, InterruptedException {
-    VectorUpdate update = new VectorUpdate(key.get());
-    update.putAll(values.iterator().next());
+    Put put = new Put(BytesUtil.getRowIndex(key.get()));
+    for (Map.Entry<Writable, Writable> e : values.iterator().next().entrySet()) {
+      put.add(Constants.COLUMNFAMILY, Bytes.toBytes(String
+          .valueOf(((IntWritable) e.getKey()).get())), Bytes
+          .toBytes(((DoubleWritable) e.getValue()).get()));
+    }
+
     context.write(new ImmutableBytesWritable(BytesUtil.getRowIndex(key.get())),
-        update.getPut());
+        put);
   }
 }

Modified: incubator/hama/trunk/src/java/org/apache/hama/mapreduce/RotationInputFormat.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/java/org/apache/hama/mapreduce/RotationInputFormat.java?rev=915672&r1=915671&r2=915672&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/mapreduce/RotationInputFormat.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/mapreduce/RotationInputFormat.java Wed Feb
24 05:03:50 2010
@@ -12,6 +12,7 @@
 import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.client.Get;
 import org.apache.hadoop.hbase.client.HTable;
+import org.apache.hadoop.hbase.client.Put;
 import org.apache.hadoop.hbase.client.Result;
 import org.apache.hadoop.hbase.client.ResultScanner;
 import org.apache.hadoop.hbase.client.Scan;
@@ -25,7 +26,6 @@
 import org.apache.hadoop.mapreduce.TaskAttemptContext;
 import org.apache.hadoop.util.StringUtils;
 import org.apache.hama.Constants;
-import org.apache.hama.io.VectorUpdate;
 import org.apache.hama.util.BytesUtil;
 
 public class RotationInputFormat extends
@@ -169,7 +169,8 @@
       }
 
       double s1, s2;
-      VectorUpdate bu;
+      Put put;
+
       boolean hasMore = vv != null && vv.size() > 0;
       if (hasMore) {
         byte[] row = vv.getRow();
@@ -183,13 +184,15 @@
               Bytes.toBytes(Constants.EICOL),
               Bytes.toBytes(String.valueOf(pivotcol))));
 
-          bu = new VectorUpdate(rowId);
-          bu.put(Constants.EICOL, pivotrow, pivotcos * s1
-              - pivotsin * s2);
-          bu.put(Constants.EICOL, pivotcol, pivotsin * s1
-              + pivotcos * s2);
+          put = new Put(BytesUtil.getRowIndex(rowId));
+          put.add(Bytes.toBytes(Constants.EICOL), Bytes.toBytes(String
+              .valueOf(pivotrow)), Bytes.toBytes(new Double(pivotcos * s1
+              - pivotsin * s2)));
+          put.add(Bytes.toBytes(Constants.EICOL), Bytes.toBytes(String
+              .valueOf(pivotcol)), Bytes.toBytes(new Double(pivotsin * s1
+              + pivotcos * s2)));
 
-          htable.put(bu.getPut());
+          htable.put(put);
         } else if (rowId == pivotrow) {
           return true;
         } else if (rowId < pivotcol) {
@@ -203,15 +206,17 @@
               Bytes.toBytes(Constants.EICOL),
               Bytes.toBytes(String.valueOf(pivotcol))));
 
-          bu = new VectorUpdate(rowId);
-          bu.put(Constants.EICOL, pivotcol, pivotsin * s1
-              + pivotcos * s2);
-          htable.put(bu.getPut());
-
-          bu = new VectorUpdate(pivotrow);
-          bu.put(Constants.EICOL, rowId, pivotcos * s1 - pivotsin
-              * s2);
-          htable.put(bu.getPut());
+          put = new Put(BytesUtil.getRowIndex(rowId));
+          put.add(Bytes.toBytes(Constants.EICOL), Bytes.toBytes(String
+              .valueOf(pivotcol)), Bytes.toBytes(new Double(pivotsin * s1
+              + pivotcos * s2)));
+          htable.put(put);
+
+          put = new Put(BytesUtil.getRowIndex(pivotrow));
+          put.add(Bytes.toBytes(Constants.EICOL), Bytes.toBytes(String
+              .valueOf(rowId)), Bytes.toBytes(new Double(pivotcos * s1
+              - pivotsin * s2)));
+          htable.put(put);
 
         } else if (rowId == pivotcol) {
           for (int i = pivotcol + 1; i < size; i++) {
@@ -226,15 +231,18 @@
                 Bytes.toBytes(Constants.EICOL),
                 Bytes.toBytes(String.valueOf(i))));
 
-            bu = new VectorUpdate(pivotcol);
-            bu.put(Constants.EICOL, i, pivotsin * s1 + pivotcos
-                * s2);
-            htable.put(bu.getPut());
-
-            bu = new VectorUpdate(pivotrow);
-            bu.put(Constants.EICOL, i, pivotcos * s1 - pivotsin
-                * s2);
-            htable.put(bu.getPut());
+            put = new Put(BytesUtil.getRowIndex(pivotcol));
+            put.add(Bytes.toBytes(Constants.EICOL), Bytes.toBytes(String
+                .valueOf(i)), Bytes.toBytes(new Double(pivotsin * s1 + pivotcos
+                * s2)));
+            htable.put(put);
+
+            put = new Put(BytesUtil.getRowIndex(pivotrow));
+            put.add(Bytes.toBytes(Constants.EICOL), Bytes.toBytes(String
+                .valueOf(i)), Bytes.toBytes(new Double(pivotcos * s1 - pivotsin
+                * s2)));
+            htable.put(put);
+
           }
         } else { // rowId > pivotcol
           return false;

Modified: incubator/hama/trunk/src/java/org/apache/hama/matrix/AbstractMatrix.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/java/org/apache/hama/matrix/AbstractMatrix.java?rev=915672&r1=915671&r2=915672&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/matrix/AbstractMatrix.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/matrix/AbstractMatrix.java Wed Feb 24 05:03:50
2010
@@ -53,7 +53,6 @@
 import org.apache.hama.HamaAdmin;
 import org.apache.hama.HamaAdminImpl;
 import org.apache.hama.HamaConfiguration;
-import org.apache.hama.io.VectorUpdate;
 import org.apache.hama.matrix.algebra.MatrixNormMapReduce;
 import org.apache.hama.matrix.algebra.TransposeMap;
 import org.apache.hama.matrix.algebra.TransposeReduce;
@@ -381,9 +380,10 @@
 
   /** {@inheritDoc} */
   public void setRowLabel(int row, String name) throws IOException {
-    VectorUpdate update = new VectorUpdate(row);
-    update.put(Bytes.toString(Constants.ATTRIBUTE), "string", name);
-    table.put(update.getPut());
+    Put put = new Put(BytesUtil.getRowIndex(row));
+    put.add(Constants.ATTRIBUTE, Bytes.toBytes("string"), Bytes
+        .toBytes(name));
+    table.put(put);
   }
 
   /** {@inheritDoc} */
@@ -397,9 +397,10 @@
 
   /** {@inheritDoc} */
   public void add(int i, int j, double value) throws IOException {
-    VectorUpdate update = new VectorUpdate(i);
-    update.put(j, value + this.get(i, j));
-    table.put(update.getPut());
+    Put put = new Put(BytesUtil.getRowIndex(i));
+    put.add(Constants.COLUMNFAMILY, Bytes.toBytes(String.valueOf(j)),
+        Bytes.toBytes(value + this.get(i, j)));
+    table.put(put);
 
   }
 

Modified: incubator/hama/trunk/src/java/org/apache/hama/matrix/DenseMatrix.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/java/org/apache/hama/matrix/DenseMatrix.java?rev=915672&r1=915671&r2=915672&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/matrix/DenseMatrix.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/matrix/DenseMatrix.java Wed Feb 24 05:03:50
2010
@@ -57,7 +57,6 @@
 import org.apache.hama.HamaConfiguration;
 import org.apache.hama.io.BlockID;
 import org.apache.hama.io.Pair;
-import org.apache.hama.io.VectorUpdate;
 import org.apache.hama.mapreduce.CollectBlocksMapper;
 import org.apache.hama.mapreduce.DummyMapper;
 import org.apache.hama.mapreduce.PivotInputFormat;
@@ -91,7 +90,7 @@
    * @param m the number of rows.
    * @param n the number of columns.
    * @throws IOException throw the exception to let the user know what happend,
-   *                 if we didn't create the matrix successfully.
+   *           if we didn't create the matrix successfully.
    */
   public DenseMatrix(HamaConfiguration conf, int m, int n) throws IOException {
     setConfiguration(conf);
@@ -107,8 +106,8 @@
    * @param conf configuration object
    * @param matrixName the name of the matrix
    * @param force if force is true, a new matrix will be created no matter
-   *                'matrixName' has aliased to an existed matrix; otherwise,
-   *                just try to load an existed matrix alised 'matrixName'.
+   *          'matrixName' has aliased to an existed matrix; otherwise, just try
+   *          to load an existed matrix alised 'matrixName'.
    * @throws IOException
    */
   public DenseMatrix(HamaConfiguration conf, String matrixName, boolean force)
@@ -153,8 +152,8 @@
   }
 
   /**
-   * Load a matrix from an existed matrix table whose tablename is 'matrixpath' !!
-   * It is an internal used for map/reduce.
+   * Load a matrix from an existed matrix table whose tablename is 'matrixpath'
+   * !! It is an internal used for map/reduce.
    * 
    * @param conf configuration object
    * @param matrixpath
@@ -182,7 +181,7 @@
    * @param n the number of columns.
    * @param s fill the matrix with this scalar value.
    * @throws IOException throw the exception to let the user know what happend,
-   *                 if we didn't create the matrix successfully.
+   *           if we didn't create the matrix successfully.
    */
   public DenseMatrix(HamaConfiguration conf, int m, int n, double s)
       throws IOException {
@@ -392,9 +391,10 @@
     if (this.getRows() < i || this.getColumns() < j)
       throw new ArrayIndexOutOfBoundsException(this.getRows() + ", "
           + this.getColumns() + ": " + i + ", " + j);
-    VectorUpdate update = new VectorUpdate(i);
-    update.put(j, value);
-    table.put(update.getPut());
+    Put put = new Put(BytesUtil.getRowIndex(i));
+    put.add(Constants.COLUMNFAMILY, Bytes.toBytes(String.valueOf(j)), Bytes
+        .toBytes(value));
+    table.put(put);
   }
 
   /**
@@ -407,10 +407,13 @@
   public void setRow(int row, Vector vector) throws IOException {
     if (this.getRows() < row || this.getColumns() < vector.size())
       throw new ArrayIndexOutOfBoundsException(row);
-
-    VectorUpdate update = new VectorUpdate(row);
-    update.putAll(vector.getEntries());
-    table.put(update.getPut());
+    Put put = new Put(BytesUtil.getRowIndex(row));
+    for (Map.Entry<Writable, Writable> e : vector.getEntries().entrySet()) {
+      put.add(Constants.COLUMNFAMILY, Bytes.toBytes(String
+          .valueOf(((IntWritable) e.getKey()).get())), Bytes
+          .toBytes(((DoubleWritable) e.getValue()).get()));
+    }
+    table.put(put);
   }
 
   /**
@@ -427,9 +430,10 @@
     for (Map.Entry<Writable, Writable> e : vector.getEntries().entrySet()) {
       int key = ((IntWritable) e.getKey()).get();
       double value = ((DoubleWritable) e.getValue()).get();
-      VectorUpdate update = new VectorUpdate(key);
-      update.put(column, value);
-      table.put(update.getPut());
+      Put put = new Put(BytesUtil.getRowIndex(key));
+      put.add(Constants.COLUMNFAMILY, Bytes.toBytes(String.valueOf(column)),
+          Bytes.toBytes(value));
+      table.put(put);
     }
   }
 
@@ -599,8 +603,7 @@
 
     String collectionTable = "collect_" + RandomVariable.randMatrixPath();
     HTableDescriptor desc = new HTableDescriptor(collectionTable);
-    desc
-        .addFamily(new HColumnDescriptor(Bytes.toBytes(Constants.BLOCK)));
+    desc.addFamily(new HColumnDescriptor(Bytes.toBytes(Constants.BLOCK)));
     this.admin.createTable(desc);
     LOG.info("Collect Blocks");
 
@@ -798,7 +801,7 @@
     final FileSystem fs = FileSystem.get(config);
     Pair pivotPair = new Pair();
     DoubleWritable pivotWritable = new DoubleWritable();
-    VectorUpdate vu;
+    Put put;
 
     // loop
     int size = this.getRows();
@@ -860,29 +863,25 @@
       }
       fs.delete(outDir, true);
       fs.delete(outDir.getParent(), true);
-      
-      if(pivot_row == 0 && pivot_col == 0)
+
+      if (pivot_row == 0 && pivot_col == 0)
         break; // stop the iterations
-      
+
       /*
-       * Calculation
-       * 
-       * Compute the rotation parameters of next rotation.
+       * Calculation Compute the rotation parameters of next rotation.
        */
       Get get = new Get(BytesUtil.getRowIndex(pivot_row));
       get.addFamily(Bytes.toBytes(Constants.EI));
       Result r = table.get(get);
-      double e1 = Bytes.toDouble(r.getValue(Bytes
-          .toBytes(Constants.EI), Bytes
+      double e1 = Bytes.toDouble(r.getValue(Bytes.toBytes(Constants.EI), Bytes
           .toBytes(Constants.EIVAL)));
 
       get = new Get(BytesUtil.getRowIndex(pivot_col));
       get.addFamily(Bytes.toBytes(Constants.EI));
       r = table.get(get);
-      double e2 = Bytes.toDouble(r.getValue(Bytes
-          .toBytes(Constants.EI), Bytes
+      double e2 = Bytes.toDouble(r.getValue(Bytes.toBytes(Constants.EI), Bytes
           .toBytes(Constants.EIVAL)));
-      
+
       y = (e2 - e1) / 2;
       t = Math.abs(y) + Math.sqrt(pivot * pivot + y * y);
       s = Math.sqrt(pivot * pivot + t * t);
@@ -897,10 +896,11 @@
       /*
        * Upate the pivot and the eigen values indexed by the pivot
        */
-      vu = new VectorUpdate(pivot_row);
-      vu.put(Constants.EICOL, pivot_col, 0);
-      table.put(vu.getPut());
-
+      put = new Put(BytesUtil.getRowIndex(pivot_row));
+      put.add(Bytes.toBytes(Constants.EICOL), Bytes.toBytes(String.valueOf(pivot_col)), Bytes
+          .toBytes(0.0));
+      table.put(put);
+      
       state = update(pivot_row, -t, state);
       state = update(pivot_col, t, state);
 
@@ -939,21 +939,21 @@
       for (int i = 0; i < size; i++) {
         get = new Get(BytesUtil.getRowIndex(pivot_row));
         e1 = Bytes.toDouble(table.get(get).getValue(
-            Bytes.toBytes(Constants.EIVEC),
-            Bytes.toBytes(String.valueOf(i))));
+            Bytes.toBytes(Constants.EIVEC), Bytes.toBytes(String.valueOf(i))));
 
         get = new Get(BytesUtil.getRowIndex(pivot_col));
         e2 = Bytes.toDouble(table.get(get).getValue(
-            Bytes.toBytes(Constants.EIVEC),
-            Bytes.toBytes(String.valueOf(i))));
+            Bytes.toBytes(Constants.EIVEC), Bytes.toBytes(String.valueOf(i))));
 
-        vu = new VectorUpdate(pivot_row);
-        vu.put(Constants.EIVEC, i, c * e1 - s * e2);
-        table.put(vu.getPut());
-
-        vu = new VectorUpdate(pivot_col);
-        vu.put(Constants.EIVEC, i, s * e1 + c * e2);
-        table.put(vu.getPut());
+        put = new Put(BytesUtil.getRowIndex(pivot_row));
+        put.add(Bytes.toBytes(Constants.EIVEC), Bytes.toBytes(String.valueOf(i)), Bytes
+            .toBytes(new Double(c * e1 - s * e2)));
+        table.put(put);
+        
+        put = new Put(BytesUtil.getRowIndex(pivot_col));
+        put.add(Bytes.toBytes(Constants.EIVEC), Bytes.toBytes(String.valueOf(i)), Bytes
+            .toBytes(new Double(s * e1 + c * e2)));
+        table.put(put);
       }
 
       LOG.info("update index...");
@@ -970,14 +970,12 @@
       get = new Get(BytesUtil.getRowIndex(row));
 
       double max = Bytes.toDouble(table.get(get).getValue(
-          Bytes.toBytes(Constants.EICOL),
-          Bytes.toBytes(String.valueOf(m))));
+          Bytes.toBytes(Constants.EICOL), Bytes.toBytes(String.valueOf(m))));
       double val;
       for (int i = row + 2; i < size; i++) {
         get = new Get(BytesUtil.getRowIndex(row));
         val = Bytes.toDouble(table.get(get).getValue(
-            Bytes.toBytes(Constants.EICOL),
-            Bytes.toBytes(String.valueOf(i))));
+            Bytes.toBytes(Constants.EICOL), Bytes.toBytes(String.valueOf(i))));
         if (Math.abs(val) > Math.abs(max)) {
           m = i;
           max = val;
@@ -985,39 +983,39 @@
       }
     }
 
-    VectorUpdate vu = new VectorUpdate(row);
-    vu.put(Constants.EI, "ind", String.valueOf(m));
-    table.put(vu.getPut());
+    Put put = new Put(BytesUtil.getRowIndex(row));
+    put.add(Bytes.toBytes(Constants.EI), Bytes.toBytes("ind"), Bytes
+        .toBytes(String.valueOf(m)));
+    table.put(put);
   }
 
   int update(int row, double value, int state) throws IOException {
     Get get = new Get(BytesUtil.getRowIndex(row));
     double e = Bytes.toDouble(table.get(get).getValue(
-        Bytes.toBytes(Constants.EI),
-        Bytes.toBytes(Constants.EIVAL)));
+        Bytes.toBytes(Constants.EI), Bytes.toBytes(Constants.EIVAL)));
     int changed = BytesUtil.bytesToInt(table.get(get).getValue(
-        Bytes.toBytes(Constants.EI),
-        Bytes.toBytes("changed")));
+        Bytes.toBytes(Constants.EI), Bytes.toBytes("changed")));
     double y = e;
     e += value;
-    
-    VectorUpdate vu = new VectorUpdate(row);
-    vu.put(Constants.EI, Constants.EIVAL, e);
 
+    Put put = new Put(BytesUtil.getRowIndex(row));
+    put.add(Bytes.toBytes(Constants.EI), Bytes.toBytes(Constants.EIVAL), Bytes
+        .toBytes(e));
+    
     if (changed == 1 && (Math.abs(y - e) < .0000001)) { // y == e) {
       changed = 0;
-      vu.put(Constants.EI,
-          Constants.EICHANGED, String.valueOf(changed));
-
+      put.add(Bytes.toBytes(Constants.EI), Bytes.toBytes(Constants.EICHANGED), Bytes
+          .toBytes(String.valueOf(changed)));
+      
       state--;
     } else if (changed == 0 && (Math.abs(y - e) > .0000001)) {
       changed = 1;
-      vu.put(Constants.EI,
-          Constants.EICHANGED, String.valueOf(changed));
-
+      put.add(Bytes.toBytes(Constants.EI), Bytes.toBytes(Constants.EICHANGED), Bytes
+          .toBytes(String.valueOf(changed)));
+      
       state++;
     }
-    table.put(vu.getPut());
+    table.put(put);
     return state;
   }
 
@@ -1028,8 +1026,7 @@
     Get get = null;
     for (int i = 0; i < e.length; i++) {
       get = new Get(BytesUtil.getRowIndex(i));
-      e1 = Bytes.toDouble(table.get(get).getValue(
-          Bytes.toBytes(Constants.EI),
+      e1 = Bytes.toDouble(table.get(get).getValue(Bytes.toBytes(Constants.EI),
           Bytes.toBytes(Constants.EIVAL)));
       success &= ((Math.abs(e1 - e[i]) < .0000001));
       if (!success)
@@ -1038,8 +1035,7 @@
       for (int j = 0; j < E[i].length; j++) {
         get = new Get(BytesUtil.getRowIndex(i));
         ev = Bytes.toDouble(table.get(get).getValue(
-            Bytes.toBytes(Constants.EIVEC),
-            Bytes.toBytes(String.valueOf(j))));
+            Bytes.toBytes(Constants.EIVEC), Bytes.toBytes(String.valueOf(j))));
         success &= ((Math.abs(ev - E[i][j]) < .0000001));
         if (!success)
           return success;

Modified: incubator/hama/trunk/src/java/org/apache/hama/matrix/SparseMatrix.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/java/org/apache/hama/matrix/SparseMatrix.java?rev=915672&r1=915671&r2=915672&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/matrix/SparseMatrix.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/matrix/SparseMatrix.java Wed Feb 24 05:03:50
2010
@@ -22,18 +22,21 @@
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
 import java.util.Random;
 
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.hbase.client.Get;
 import org.apache.hadoop.hbase.client.HTable;
+import org.apache.hadoop.hbase.client.Put;
 import org.apache.hadoop.hbase.client.Result;
 import org.apache.hadoop.hbase.client.Scan;
 import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
 import org.apache.hadoop.hbase.mapreduce.TableMapReduceUtil;
 import org.apache.hadoop.hbase.mapreduce.TableOutputFormat;
 import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.io.DoubleWritable;
 import org.apache.hadoop.io.IntWritable;
 import org.apache.hadoop.io.MapWritable;
 import org.apache.hadoop.io.SequenceFile;
@@ -44,7 +47,6 @@
 import org.apache.hadoop.mapreduce.lib.input.SequenceFileInputFormat;
 import org.apache.hama.Constants;
 import org.apache.hama.HamaConfiguration;
-import org.apache.hama.io.VectorUpdate;
 import org.apache.hama.mapreduce.RandomMatrixMapper;
 import org.apache.hama.mapreduce.RandomMatrixReducer;
 import org.apache.hama.matrix.algebra.SparseMatrixVectorMultMap;
@@ -227,9 +229,10 @@
   /** {@inheritDoc} */
   public void set(int i, int j, double value) throws IOException {
     if (value != 0) {
-      VectorUpdate update = new VectorUpdate(i);
-      update.put(j, value);
-      table.put(update.getPut());
+      Put put = new Put(BytesUtil.getRowIndex(i));
+      put.add(Constants.COLUMNFAMILY, Bytes.toBytes(String.valueOf(j)),
+          Bytes.toBytes(value));
+      table.put(put);
     }
   }
 
@@ -326,9 +329,12 @@
       throw new ArrayIndexOutOfBoundsException(row);
 
     if (vector.size() > 0) { // stores if size > 0
-      VectorUpdate update = new VectorUpdate(row);
-      update.putAll(((SparseVector) vector).getEntries());
-      table.put(update.getPut());
+      Put put = new Put(BytesUtil.getRowIndex(row));
+      for (Map.Entry<Writable, Writable> e : ((SparseVector) vector).getEntries().entrySet())
{
+        put.add(Constants.COLUMNFAMILY, Bytes.toBytes(String.valueOf(((IntWritable) e.getKey()).get())),
+            Bytes.toBytes(((DoubleWritable) e.getValue()).get()));
+      }
+      table.put(put);
     }
   }
 

Modified: incubator/hama/trunk/src/java/org/apache/hama/matrix/algebra/BlockMultReduce.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/java/org/apache/hama/matrix/algebra/BlockMultReduce.java?rev=915672&r1=915671&r2=915672&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/matrix/algebra/BlockMultReduce.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/matrix/algebra/BlockMultReduce.java Wed
Feb 24 05:03:50 2010
@@ -2,12 +2,14 @@
 
 import java.io.IOException;
 
+import org.apache.hadoop.hbase.client.Put;
 import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
 import org.apache.hadoop.hbase.mapreduce.TableReducer;
+import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.hadoop.io.BytesWritable;
 import org.apache.hadoop.io.Writable;
+import org.apache.hama.Constants;
 import org.apache.hama.io.BlockID;
-import org.apache.hama.io.VectorUpdate;
 import org.apache.hama.matrix.SubMatrix;
 import org.apache.hama.util.BytesUtil;
 
@@ -31,13 +33,14 @@
     int startColumn = key.getColumn() * s.getColumns();
 
     for (int i = 0; i < s.getRows(); i++) {
-      VectorUpdate update = new VectorUpdate(i + startRow);
+      Put put = new Put(BytesUtil.getRowIndex(i + startRow));
       for (int j = 0; j < s.getColumns(); j++) {
-        update.put(j + startColumn, s.get(i, j));
+        put.add(Constants.COLUMNFAMILY, Bytes.toBytes(String.valueOf(j + startColumn)),
+            Bytes.toBytes(s.get(i, j)));
       }
 
       context.write(new ImmutableBytesWritable(BytesUtil.getRowIndex(key
-          .getRow())), update.getPut());
+          .getRow())), put);
     }
   }
 }

Modified: incubator/hama/trunk/src/java/org/apache/hama/matrix/algebra/DenseMatrixVectorMultReduce.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/java/org/apache/hama/matrix/algebra/DenseMatrixVectorMultReduce.java?rev=915672&r1=915671&r2=915672&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/matrix/algebra/DenseMatrixVectorMultReduce.java
(original)
+++ incubator/hama/trunk/src/java/org/apache/hama/matrix/algebra/DenseMatrixVectorMultReduce.java
Wed Feb 24 05:03:50 2010
@@ -20,13 +20,17 @@
 package org.apache.hama.matrix.algebra;
 
 import java.io.IOException;
+import java.util.Map;
 
+import org.apache.hadoop.hbase.client.Put;
 import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
 import org.apache.hadoop.hbase.mapreduce.TableReducer;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.io.DoubleWritable;
 import org.apache.hadoop.io.IntWritable;
 import org.apache.hadoop.io.MapWritable;
 import org.apache.hadoop.io.Writable;
-import org.apache.hama.io.VectorUpdate;
+import org.apache.hama.Constants;
 import org.apache.hama.matrix.DenseVector;
 import org.apache.hama.util.BytesUtil;
 
@@ -40,8 +44,8 @@
 
     for (MapWritable value : values) {
       DenseVector nVector = new DenseVector(value);
-      
-      if(sum.size() == 0) {
+
+      if (sum.size() == 0) {
         sum.zeroFill(nVector.size());
         sum.add(nVector);
       } else {
@@ -49,10 +53,14 @@
       }
     }
 
-    VectorUpdate update = new VectorUpdate(key.get());
-    update.putAll(sum.getEntries());
+    Put put = new Put(BytesUtil.getRowIndex(key.get()));
+    for (Map.Entry<Writable, Writable> e : sum.getEntries().entrySet()) {
+      put.add(Constants.COLUMNFAMILY, Bytes.toBytes(String
+          .valueOf(((IntWritable) e.getKey()).get())), Bytes
+          .toBytes(((DoubleWritable) e.getValue()).get()));
+    }
 
     context.write(new ImmutableBytesWritable(BytesUtil.getRowIndex(key.get())),
-        update.getPut());
+        put);
   }
-}
\ No newline at end of file
+}

Modified: incubator/hama/trunk/src/java/org/apache/hama/matrix/algebra/JacobiInitMap.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/java/org/apache/hama/matrix/algebra/JacobiInitMap.java?rev=915672&r1=915671&r2=915672&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/matrix/algebra/JacobiInitMap.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/matrix/algebra/JacobiInitMap.java Wed Feb
24 05:03:50 2010
@@ -10,7 +10,6 @@
 import org.apache.hadoop.hbase.mapreduce.TableMapper;
 import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.hama.Constants;
-import org.apache.hama.io.VectorUpdate;
 import org.apache.hama.util.BytesUtil;
 
 /**
@@ -32,7 +31,7 @@
       throws IOException, InterruptedException {
     int row, col;
     row = BytesUtil.getRowIndex(key.get());
-    VectorUpdate vu = new VectorUpdate(row);
+    Put put = new Put(BytesUtil.getRowIndex(row));
 
     double val;
     double maxVal = Double.MIN_VALUE;
@@ -46,11 +45,15 @@
       val = Bytes.toDouble(e.getValue());
       col = BytesUtil.bytesToInt(e.getKey());
       // copy the original matrix to "EICOL" family
-      vu.put(Constants.EICOL, col, val);
+      put.add(Bytes.toBytes(Constants.EICOL), Bytes.toBytes(String.valueOf(col)), Bytes
+          .toBytes(val));
       // make the "EIVEC" a dialog matrix
-      vu.put(Constants.EIVEC, col, col == row ? 1 : 0);
+      put.add(Bytes.toBytes(Constants.EIVEC), Bytes.toBytes(String.valueOf(col)), Bytes
+          .toBytes(col == row ? new Double(1) : new Double(0)));
+      
       if (col == row) {
-        vu.put(Constants.EI, Constants.EIVAL, val);
+        put.add(Bytes.toBytes(Constants.EI), Bytes.toBytes(Constants.EIVAL), Bytes
+            .toBytes(val));
       }
       // find the max index
       if (col > row) {
@@ -68,9 +71,12 @@
     }
 
     // index array
-    vu.put(Constants.EI, Constants.EIIND, String.valueOf(maxInd));
+    put.add(Bytes.toBytes(Constants.EI), Bytes.toBytes(Constants.EIIND), Bytes
+        .toBytes(String.valueOf(maxInd)));
     // Changed Array set to be true during initialization
-    vu.put(Constants.EI, Constants.EICHANGED, String.valueOf(1));
-    context.write(key, vu.getPut());
+    put.add(Bytes.toBytes(Constants.EI), Bytes.toBytes(Constants.EICHANGED), Bytes
+        .toBytes(String.valueOf(1)));
+    
+    context.write(key, put);
   }
 }

Modified: incubator/hama/trunk/src/java/org/apache/hama/matrix/algebra/MatrixAdditionReduce.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/java/org/apache/hama/matrix/algebra/MatrixAdditionReduce.java?rev=915672&r1=915671&r2=915672&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/matrix/algebra/MatrixAdditionReduce.java
(original)
+++ incubator/hama/trunk/src/java/org/apache/hama/matrix/algebra/MatrixAdditionReduce.java
Wed Feb 24 05:03:50 2010
@@ -1,28 +1,37 @@
 package org.apache.hama.matrix.algebra;
 
 import java.io.IOException;
+import java.util.Map;
 
+import org.apache.hadoop.hbase.client.Put;
 import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
 import org.apache.hadoop.hbase.mapreduce.TableReducer;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.io.DoubleWritable;
 import org.apache.hadoop.io.IntWritable;
 import org.apache.hadoop.io.MapWritable;
 import org.apache.hadoop.io.Writable;
-import org.apache.hama.io.VectorUpdate;
+import org.apache.hama.Constants;
 import org.apache.hama.util.BytesUtil;
 
 public class MatrixAdditionReduce extends
-TableReducer<IntWritable, MapWritable, Writable> {
-  
+    TableReducer<IntWritable, MapWritable, Writable> {
+
   @Override
   public void reduce(IntWritable key, Iterable<MapWritable> values,
       Context context) throws IOException, InterruptedException {
 
-    VectorUpdate update = new VectorUpdate(key.get());
+    Put put = new Put(BytesUtil.getRowIndex(key.get()));
     for (MapWritable value : values) {
-      update.putAll(value);
+      for (Map.Entry<Writable, Writable> e : value.entrySet()) {
+
+        put.add(Constants.COLUMNFAMILY, Bytes.toBytes(String
+            .valueOf(((IntWritable) e.getKey()).get())), Bytes
+            .toBytes(((DoubleWritable) e.getValue()).get()));
+      }
     }
-    
+
     context.write(new ImmutableBytesWritable(BytesUtil.getRowIndex(key.get())),
-        update.getPut());
+        put);
   }
 }

Modified: incubator/hama/trunk/src/java/org/apache/hama/matrix/algebra/SparseMatrixVectorMultReduce.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/java/org/apache/hama/matrix/algebra/SparseMatrixVectorMultReduce.java?rev=915672&r1=915671&r2=915672&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/matrix/algebra/SparseMatrixVectorMultReduce.java
(original)
+++ incubator/hama/trunk/src/java/org/apache/hama/matrix/algebra/SparseMatrixVectorMultReduce.java
Wed Feb 24 05:03:50 2010
@@ -20,13 +20,17 @@
 package org.apache.hama.matrix.algebra;
 
 import java.io.IOException;
+import java.util.Map;
 
+import org.apache.hadoop.hbase.client.Put;
 import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
 import org.apache.hadoop.hbase.mapreduce.TableReducer;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.io.DoubleWritable;
 import org.apache.hadoop.io.IntWritable;
 import org.apache.hadoop.io.MapWritable;
 import org.apache.hadoop.io.Writable;
-import org.apache.hama.io.VectorUpdate;
+import org.apache.hama.Constants;
 import org.apache.hama.matrix.SparseVector;
 import org.apache.hama.util.BytesUtil;
 
@@ -42,10 +46,14 @@
       sum.add(new SparseVector(value));
     }
 
-    VectorUpdate update = new VectorUpdate(key.get());
-    update.putAll(sum.getEntries());
+    Put put = new Put(BytesUtil.getRowIndex(key.get()));
+    for (Map.Entry<Writable, Writable> e : sum.getEntries().entrySet()) {
+      put.add(Constants.COLUMNFAMILY, Bytes.toBytes(String
+          .valueOf(((IntWritable) e.getKey()).get())), Bytes
+          .toBytes(((DoubleWritable) e.getValue()).get()));
+    }
 
     context.write(new ImmutableBytesWritable(BytesUtil.getRowIndex(key.get())),
-        update.getPut());
+        put);
   }
 }

Modified: incubator/hama/trunk/src/java/org/apache/hama/matrix/algebra/TransposeReduce.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/java/org/apache/hama/matrix/algebra/TransposeReduce.java?rev=915672&r1=915671&r2=915672&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/matrix/algebra/TransposeReduce.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/matrix/algebra/TransposeReduce.java Wed
Feb 24 05:03:50 2010
@@ -22,15 +22,18 @@
 import java.io.IOException;
 import java.util.Map;
 
+import org.apache.hadoop.hbase.client.Put;
 import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
 import org.apache.hadoop.hbase.mapreduce.TableReducer;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.io.DoubleWritable;
 import org.apache.hadoop.io.IntWritable;
 import org.apache.hadoop.io.MapWritable;
 import org.apache.hadoop.io.Writable;
-import org.apache.hama.io.VectorUpdate;
+import org.apache.hama.Constants;
 import org.apache.hama.util.BytesUtil;
 
-public class TransposeReduce  extends
+public class TransposeReduce extends
     TableReducer<IntWritable, MapWritable, Writable> {
 
   @Override
@@ -44,11 +47,15 @@
       }
     }
 
-    VectorUpdate update = new VectorUpdate(key.get());
-    update.putAll(sum);
+    Put put = new Put(BytesUtil.getRowIndex(key.get()));
+    for (Map.Entry<Writable, Writable> e : sum.entrySet()) {
+      put.add(Constants.COLUMNFAMILY, Bytes.toBytes(String
+          .valueOf(((IntWritable) e.getKey()).get())), Bytes
+          .toBytes(((DoubleWritable) e.getValue()).get()));
+    }
 
     context.write(new ImmutableBytesWritable(BytesUtil.getRowIndex(key.get())),
-        update.getPut());
+        put);
   }
 
-}
\ No newline at end of file
+}



Mime
View raw message