incubator-hama-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From edwardy...@apache.org
Subject svn commit: r824243 - in /incubator/hama/trunk/src: java/org/apache/hama/ java/org/apache/hama/io/ java/org/apache/hama/matrix/ java/org/apache/hama/matrix/algebra/ test/org/apache/hama/ test/org/apache/hama/matrix/
Date Mon, 12 Oct 2009 07:12:34 GMT
Author: edwardyoon
Date: Mon Oct 12 07:12:33 2009
New Revision: 824243

URL: http://svn.apache.org/viewvc?rev=824243&view=rev
Log:
Replacement for deprecated API of Hbase

Modified:
    incubator/hama/trunk/src/java/org/apache/hama/Constants.java
    incubator/hama/trunk/src/java/org/apache/hama/HamaAdminImpl.java
    incubator/hama/trunk/src/java/org/apache/hama/io/DoubleEntry.java
    incubator/hama/trunk/src/java/org/apache/hama/io/VectorUpdate.java
    incubator/hama/trunk/src/java/org/apache/hama/matrix/AbstractMatrix.java
    incubator/hama/trunk/src/java/org/apache/hama/matrix/AbstractVector.java
    incubator/hama/trunk/src/java/org/apache/hama/matrix/DenseMatrix.java
    incubator/hama/trunk/src/java/org/apache/hama/matrix/DenseVector.java
    incubator/hama/trunk/src/java/org/apache/hama/matrix/SparseMatrix.java
    incubator/hama/trunk/src/java/org/apache/hama/matrix/SparseVector.java
    incubator/hama/trunk/src/java/org/apache/hama/matrix/algebra/JacobiEigenValue.java
    incubator/hama/trunk/src/test/org/apache/hama/TestHbaseClient.java
    incubator/hama/trunk/src/test/org/apache/hama/matrix/TestAbstractMatrix.java
    incubator/hama/trunk/src/test/org/apache/hama/matrix/TestSingularValueDecomposition.java
    incubator/hama/trunk/src/test/org/apache/hama/matrix/TestSparseMatrix.java

Modified: incubator/hama/trunk/src/java/org/apache/hama/Constants.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/java/org/apache/hama/Constants.java?rev=824243&r1=824242&r2=824243&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/Constants.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/Constants.java Mon Oct 12 07:12:33 2009
@@ -33,16 +33,18 @@
   public final static String CINDEX = "cIndex";
 
   /** The attribute column family */
-  public final static String ATTRIBUTE = "attribute:";
+  public final static String ATTRIBUTE = "attribute";
 
   /** The number of the matrix rows */
+  @Deprecated
   public final static String METADATA_ROWS = "attribute:rows";
 
   /** The number of the matrix columns */
+  @Deprecated
   public final static String METADATA_COLUMNS = "attribute:columns";
 
   /** The type of the matrix */
-  public final static String METADATA_TYPE = "attribute:type";
+  public final static String METADATA_TYPE = "type";
   
   /** The reference of the matrix */
   /** (1) when we create a Matrix object, we set up a connection to hbase table,
@@ -57,17 +59,22 @@
    *          1) if the matrix table is aliased, we should not delete the table.
    *          2) if the matrix table is not aliased, we need to delete the table.
    */
+  @Deprecated
   public final static String METADATA_REFERENCE = "attribute:reference";
   
   /** The aliase names column family */
-  public final static String ALIASEFAMILY = "aliase:";
+  public final static String ALIASEFAMILY = "aliase";
   
   /** The aliase names of the matrix, sperated by "," */
+  @Deprecated
   public final static String ALIASENAME = "aliase:name";
 
   /** Default columnFamily name */
+  @Deprecated
   public final static String COLUMN = "column:";
 
+  public final static String COLUMN_FAMILY = "column";
+  
   /** Temporary random matrices name prefix */
   public final static String RANDOM = "rand";
 
@@ -75,7 +82,7 @@
   public final static String ADMINTABLE = "admin.table";
 
   /** Matrix path columnFamily */
-  public static final String PATHCOLUMN = "path:";
+  public static final String PATHCOLUMN = "path";
 
   /** Temporary Aliase name prefix in Hama Shell */
   public static final String RANDOMALIASE = "_";
@@ -90,6 +97,7 @@
   public static final int DEFAULT_TRY_TIMES = 10000000;
   
   /** block data column */
+  @Deprecated
   public static final String BLOCK = "block:";
   
   public static final Text ROWCOUNT= new Text("row");

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=824243&r1=824242&r2=824243&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/HamaAdminImpl.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/HamaAdminImpl.java Mon Oct 12 07:12:33 2009
@@ -25,12 +25,11 @@
 import org.apache.hadoop.hbase.HTableDescriptor;
 import org.apache.hadoop.hbase.MasterNotRunningException;
 import org.apache.hadoop.hbase.RegionException;
+import org.apache.hadoop.hbase.client.Delete;
 import org.apache.hadoop.hbase.client.Get;
 import org.apache.hadoop.hbase.client.HBaseAdmin;
 import org.apache.hadoop.hbase.client.HTable;
-import org.apache.hadoop.hbase.client.Result;
-import org.apache.hadoop.hbase.io.BatchUpdate;
-import org.apache.hadoop.hbase.io.Cell;
+import org.apache.hadoop.hbase.client.Put;
 import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.hama.matrix.DenseMatrix;
 import org.apache.hama.matrix.Matrix;
@@ -95,7 +94,10 @@
    */
   public String getPath(String name) {
     try {
-      byte[] result = table.get(name, Constants.PATHCOLUMN).getValue();
+      Get get = new Get(Bytes.toBytes(name));
+      get.addFamily(Bytes.toBytes(Constants.PATHCOLUMN));
+      byte[] result = table.get(get).getValue(
+          Bytes.toBytes(Constants.PATHCOLUMN), null);
       return Bytes.toString(result);
     } catch (IOException e) {
       e.printStackTrace();
@@ -105,7 +107,11 @@
 
   public boolean matrixExists(String matrixName) {
     try {
-      Cell result = table.get(matrixName, Constants.PATHCOLUMN);
+      Get get = new Get(Bytes.toBytes(matrixName));
+      get.addFamily(Bytes.toBytes(Constants.PATHCOLUMN));
+      byte[] result = table.get(get).getValue(
+          Bytes.toBytes(Constants.PATHCOLUMN), null);
+
       return (result == null) ? false : true;
     } catch (IOException e) {
       e.printStackTrace();
@@ -119,11 +125,13 @@
     // we just store the name -> path(tablename) here.
     // the matrix type is stored in its hbase table. we don't need to store
     // again.
-    BatchUpdate update = new BatchUpdate(aliaseName);
-    update.put(Constants.PATHCOLUMN, Bytes.toBytes(mat.getPath()));
+
+    Put put = new Put(Bytes.toBytes(aliaseName));
+    put.add(Bytes.toBytes(Constants.PATHCOLUMN), null, Bytes.toBytes(mat
+        .getPath()));
 
     try {
-      table.commit(update);
+      table.put(put);
 
       result = true;
     } catch (IOException e) {
@@ -135,22 +143,27 @@
 
   /** remove the entry of 'matrixName' in admin table. * */
   private void removeEntry(String matrixName) throws IOException {
-    table.deleteAll(matrixName);
+    Delete del = new Delete(Bytes.toBytes(matrixName));
+    table.delete(del);
   }
 
   private int getReference(String tableName) throws IOException {
     HTable matrix = new HTable(conf, tableName);
 
-    Cell rows = null;
-    rows = matrix.get(Constants.METADATA, Constants.METADATA_REFERENCE);
+    Get get = new Get(Bytes.toBytes(Constants.METADATA));
+    get.addFamily(Bytes.toBytes(Constants.ATTRIBUTE));
+    byte[] result = matrix.get(get).getValue(
+        Bytes.toBytes(Constants.ATTRIBUTE), Bytes.toBytes("reference"));
 
-    return (rows == null) ? 0 : Bytes.toInt(rows.getValue());
+    return (result == null) ? 0 : Bytes.toInt(result);
   }
 
   private void clearAliaseInfo(String tableName) throws IOException {
     HTable matrix = new HTable(conf, tableName);
-
-    matrix.deleteAll(Constants.METADATA, Constants.ALIASENAME);
+    Delete del = new Delete(Bytes.toBytes(Constants.METADATA));
+    del.deleteColumns(Bytes.toBytes(Constants.ALIASEFAMILY), Bytes
+        .toBytes("name"));
+    matrix.delete(del);
   }
 
   /**
@@ -199,7 +212,7 @@
   @Override
   public Matrix getMatrix(String matrixName) throws IOException {
     String path = getPath(matrixName);
-    if(getType(path).equals("SparseMatrix"))
+    if (getType(path).equals("SparseMatrix"))
       return new SparseMatrix(conf, path);
     else
       return new DenseMatrix(conf, path);
@@ -207,9 +220,13 @@
 
   private String getType(String path) {
     try {
-      HTable matrix = new HTable(conf, path);
-      byte[] result = matrix.get(Constants.METADATA,
-          Constants.ATTRIBUTE + "type").getValue();
+      HTable table = new HTable(conf, path);
+
+      Get get = new Get(Bytes.toBytes(Constants.METADATA));
+      get.addFamily(Bytes.toBytes(Constants.ATTRIBUTE));
+      byte[] result = table.get(get).getValue(
+          Bytes.toBytes(Constants.ATTRIBUTE), Bytes.toBytes("type"));
+
       return Bytes.toString(result);
     } catch (IOException e) {
       e.printStackTrace();

Modified: incubator/hama/trunk/src/java/org/apache/hama/io/DoubleEntry.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/java/org/apache/hama/io/DoubleEntry.java?rev=824243&r1=824242&r2=824243&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/io/DoubleEntry.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/io/DoubleEntry.java Mon Oct 12 07:12:33
2009
@@ -55,6 +55,13 @@
     this.timestamps[0] = System.currentTimeMillis();
   }
   
+  public DoubleEntry(byte[] value) {
+    this.values = new byte[1][];
+    this.values[0] = value;
+    this.timestamps = new long[1];
+    this.timestamps[0] = System.currentTimeMillis();
+  }
+  
   /** @return the current VectorEntry's value */
   public double getValue() {
     return BytesUtil.bytesToDouble(this.values[0]);

Modified: incubator/hama/trunk/src/java/org/apache/hama/io/VectorUpdate.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/java/org/apache/hama/io/VectorUpdate.java?rev=824243&r1=824242&r2=824243&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/io/VectorUpdate.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/io/VectorUpdate.java Mon Oct 12 07:12:33
2009
@@ -23,6 +23,7 @@
 import java.util.Set;
 import java.util.Map.Entry;
 
+import org.apache.hadoop.hbase.client.Put;
 import org.apache.hadoop.hbase.io.BatchUpdate;
 import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.hadoop.io.IntWritable;
@@ -33,9 +34,11 @@
 
 public class VectorUpdate {
   private BatchUpdate batchUpdate;
+  private Put put;
 
   public VectorUpdate(int i) {
     this.batchUpdate = new BatchUpdate(BytesUtil.getRowIndex(i));
+    this.put = new Put(BytesUtil.getRowIndex(i));
   }
 
   public VectorUpdate(String row) {
@@ -49,10 +52,13 @@
   public void put(int j, double value) {
     this.batchUpdate.put(BytesUtil.getColumnIndex(j), BytesUtil
         .doubleToBytes(value));
+    this.put.add(Bytes.toBytes(Constants.COLUMN_FAMILY), Bytes.toBytes(String
+        .valueOf(j)), BytesUtil.doubleToBytes(value));
   }
-  
+
   /**
    * Put the value in "cfName+j"
+   * 
    * @param cfName
    * @param j
    * @param value
@@ -60,11 +66,12 @@
   public void put(String cfName, int j, double value) {
     this.batchUpdate.put(Bytes.toBytes(cfName + j), Bytes.toBytes(value));
   }
-  
+
   public void put(String name, double value) {
     this.batchUpdate.put(Bytes.toBytes(name), Bytes.toBytes(value));
   }
 
+  @Deprecated
   public void put(int j, String name) {
     this.batchUpdate.put(Bytes.toBytes((Constants.ATTRIBUTE + j)), Bytes
         .toBytes(name));
@@ -73,6 +80,10 @@
   public void put(String j, String val) {
     this.batchUpdate.put(j, Bytes.toBytes(val));
   }
+  
+  public void put(String column, String qualifier, String val) {
+    this.put.add(Bytes.toBytes(column), Bytes.toBytes(qualifier), Bytes.toBytes(val));
+  }
 
   public void put(String row, int val) {
     this.batchUpdate.put(row, BytesUtil.intToBytes(val));
@@ -93,10 +104,15 @@
       put(e.getKey(), e.getValue().getValue());
     }
   }
-  
+
   public void putAll(MapWritable entries) {
     for (Map.Entry<Writable, Writable> e : entries.entrySet()) {
-      put(((IntWritable) e.getKey()).get(), ((DoubleEntry) e.getValue()).getValue());
+      put(((IntWritable) e.getKey()).get(), ((DoubleEntry) e.getValue())
+          .getValue());
     }
   }
+
+  public Put getPut() {
+    return this.put;
+  }
 }

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=824243&r1=824242&r2=824243&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 Mon Oct 12 07:12:33
2009
@@ -27,13 +27,13 @@
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.hbase.HColumnDescriptor;
-import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.HTableDescriptor;
 import org.apache.hadoop.hbase.MasterNotRunningException;
 import org.apache.hadoop.hbase.RegionException;
-import org.apache.hadoop.hbase.HColumnDescriptor.CompressionType;
+import org.apache.hadoop.hbase.client.Get;
 import org.apache.hadoop.hbase.client.HBaseAdmin;
 import org.apache.hadoop.hbase.client.HTable;
+import org.apache.hadoop.hbase.client.Put;
 import org.apache.hadoop.hbase.io.BatchUpdate;
 import org.apache.hadoop.hbase.io.Cell;
 import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
@@ -143,38 +143,24 @@
   protected void create() throws IOException {
     // It should run only when table doesn't exist.
     if (!admin.tableExists(matrixPath)) {
-      this.tableDesc.addFamily(new HColumnDescriptor(Bytes.toBytes(Constants.COLUMN)));
-      this.tableDesc.addFamily(new HColumnDescriptor(Bytes.toBytes(Constants.ATTRIBUTE)));
-      this.tableDesc.addFamily(new HColumnDescriptor(Bytes.toBytes(Constants.ALIASEFAMILY)));
-      
-      // It's a temporary data.
-      this.tableDesc.addFamily(new HColumnDescriptor(Bytes.toBytes(Constants.BLOCK)));
-     // the following families are used in JacobiEigenValue computation
-      this.tableDesc.addFamily(new HColumnDescriptor(Bytes.toBytes(JacobiEigenValue.EI)));
-      this.tableDesc.addFamily(new HColumnDescriptor(Bytes.toBytes(JacobiEigenValue.EICOL)));
-      this.tableDesc.addFamily(new HColumnDescriptor(Bytes.toBytes(JacobiEigenValue.EIVEC)));
-      
-      /*
       this.tableDesc.addFamily(new HColumnDescriptor(Bytes
-          .toBytes(Constants.COLUMN), 3, CompressionType.NONE, false, false,
-          Integer.MAX_VALUE, HConstants.FOREVER, false));
-      this.tableDesc.addFamily(new HColumnDescriptor(Constants.ATTRIBUTE));
-      this.tableDesc.addFamily(new HColumnDescriptor(Constants.ALIASEFAMILY));
+          .toBytes(Constants.COLUMN)));
+      this.tableDesc.addFamily(new HColumnDescriptor(Bytes
+          .toBytes(Constants.ATTRIBUTE)));
+      this.tableDesc.addFamily(new HColumnDescriptor(Bytes
+          .toBytes(Constants.ALIASEFAMILY)));
+
       // It's a temporary data.
       this.tableDesc.addFamily(new HColumnDescriptor(Bytes
-          .toBytes(Constants.BLOCK), 1, CompressionType.NONE, false, false,
-          Integer.MAX_VALUE, HConstants.FOREVER, false));
+          .toBytes(Constants.BLOCK)));
       // the following families are used in JacobiEigenValue computation
       this.tableDesc.addFamily(new HColumnDescriptor(Bytes
-          .toBytes(JacobiEigenValue.EI), 1, CompressionType.NONE, false, false,
-          Integer.MAX_VALUE, HConstants.FOREVER, false));
+          .toBytes(JacobiEigenValue.EI_COLUMNFAMILY)));
       this.tableDesc.addFamily(new HColumnDescriptor(Bytes
-          .toBytes(JacobiEigenValue.EICOL), 10, CompressionType.NONE, false,
-          false, Integer.MAX_VALUE, HConstants.FOREVER, false));
+          .toBytes(JacobiEigenValue.EICOL)));
       this.tableDesc.addFamily(new HColumnDescriptor(Bytes
-          .toBytes(JacobiEigenValue.EIVEC), 10, CompressionType.NONE, false,
-          false, Integer.MAX_VALUE, HConstants.FOREVER, false));
-      */
+          .toBytes(JacobiEigenValue.EIVEC)));
+
       LOG.info("Initializing the matrix storage.");
       this.admin.createTable(this.tableDesc);
       LOG.info("Create Matrix " + matrixPath);
@@ -184,11 +170,17 @@
       table.setAutoFlush(true);
 
       // Record the matrix type in METADATA_TYPE
-      BatchUpdate update = new BatchUpdate(Constants.METADATA);
-      update.put(Constants.METADATA_TYPE, Bytes.toBytes(this.getClass()
+      Put put = new Put(Bytes.toBytes(Constants.METADATA));
+      put.add(Bytes.toBytes(Constants.ATTRIBUTE), Bytes
+          .toBytes(Constants.METADATA_TYPE), Bytes.toBytes(this.getClass()
           .getSimpleName()));
+      table.put(put);
 
-      table.commit(update);
+      /*
+       * BatchUpdate update = new BatchUpdate(Constants.METADATA);
+       * update.put(Constants.METADATA_TYPE, Bytes.toBytes(this.getClass()
+       * .getSimpleName())); table.commit(update);
+       */
 
       // the new matrix's reference is 1.
       setReference(1);
@@ -347,38 +339,62 @@
 
   /** {@inheritDoc} */
   public int getRows() throws IOException {
-    Cell rows = null;
-    rows = table.get(Constants.METADATA, Constants.METADATA_ROWS);
-    return (rows != null) ? BytesUtil.bytesToInt(rows.getValue()) : 0;
+    Get get = new Get(Bytes.toBytes(Constants.METADATA));
+    get.addFamily(Bytes.toBytes(Constants.ATTRIBUTE));
+    byte[] result = table.get(get).getValue(Bytes.toBytes(Constants.ATTRIBUTE),
+        Bytes.toBytes("rows"));
+
+    return (result != null) ? BytesUtil.bytesToInt(result) : 0;
   }
 
   /** {@inheritDoc} */
   public int getColumns() throws IOException {
-    Cell columns = table.get(Constants.METADATA, Constants.METADATA_COLUMNS);
-    return BytesUtil.bytesToInt(columns.getValue());
+    Get get = new Get(Bytes.toBytes(Constants.METADATA));
+    get.addFamily(Bytes.toBytes(Constants.ATTRIBUTE));
+    byte[] result = table.get(get).getValue(Bytes.toBytes(Constants.ATTRIBUTE),
+        Bytes.toBytes("columns"));
+
+    return BytesUtil.bytesToInt(result);
   }
 
   /** {@inheritDoc} */
   public String getRowLabel(int row) throws IOException {
-    Cell rows = null;
-    rows = table.get(BytesUtil.getRowIndex(row), Bytes
-        .toBytes(Constants.ATTRIBUTE + "string"));
+    Get get = new Get(BytesUtil.getRowIndex(row));
+    get.addFamily(Bytes.toBytes(Constants.ATTRIBUTE));
+    byte[] result = table.get(get).getValue(Bytes.toBytes(Constants.ATTRIBUTE),
+        Bytes.toBytes("string"));
+
+    return (result != null) ? Bytes.toString(result) : null;
+  }
 
-    return (rows != null) ? Bytes.toString(rows.getValue()) : null;
+  /** {@inheritDoc} */
+  public void setColumnLabel(int column, String name) throws IOException {
+    /*
+     * VectorUpdate update = new VectorUpdate(Constants.CINDEX);
+     * update.put(column, name); table.commit(update.getBatchUpdate());
+     */
+
+    Put put = new Put(Bytes.toBytes(Constants.CINDEX));
+    put.add(Bytes.toBytes(Constants.ATTRIBUTE), Bytes.toBytes(String
+        .valueOf(column)), Bytes.toBytes(name));
+    table.put(put);
   }
 
   /** {@inheritDoc} */
   public String getColumnLabel(int column) throws IOException {
-    Cell rows = null;
-    rows = table.get(Constants.CINDEX, (Constants.ATTRIBUTE + column));
-    return (rows != null) ? Bytes.toString(rows.getValue()) : null;
+    Get get = new Get(Bytes.toBytes(Constants.CINDEX));
+    get.addFamily(Bytes.toBytes(Constants.ATTRIBUTE));
+    byte[] result = table.get(get).getValue(Bytes.toBytes(Constants.ATTRIBUTE),
+        Bytes.toBytes(String.valueOf(column)));
+
+    return (result != null) ? Bytes.toString(result) : null;
   }
 
   /** {@inheritDoc} */
   public void setRowLabel(int row, String name) throws IOException {
     VectorUpdate update = new VectorUpdate(row);
-    update.put(Constants.ATTRIBUTE + "string", name);
-    table.commit(update.getBatchUpdate());
+    update.put(Constants.ATTRIBUTE, "string", name);
+    table.put(update.getPut());
   }
 
   /** {@inheritDoc} */
@@ -394,7 +410,7 @@
   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.commit(update.getBatchUpdate());
+    table.put(update.getPut());
 
   }
 
@@ -476,13 +492,6 @@
   }
 
   /** {@inheritDoc} */
-  public void setColumnLabel(int column, String name) throws IOException {
-    VectorUpdate update = new VectorUpdate(Constants.CINDEX);
-    update.put(column, name);
-    table.commit(update.getBatchUpdate());
-  }
-
-  /** {@inheritDoc} */
   public String getPath() {
     return matrixPath;
   }
@@ -496,10 +505,14 @@
 
   protected int incrementAndGetRef() throws IOException {
     int reference = 1;
-    Cell rows = null;
-    rows = table.get(Constants.METADATA, Constants.METADATA_REFERENCE);
-    if (rows != null) {
-      reference = Bytes.toInt(rows.getValue());
+
+    Get get = new Get(Bytes.toBytes(Constants.METADATA));
+    get.addFamily(Bytes.toBytes(Constants.ATTRIBUTE));
+    byte[] result = table.get(get).getValue(
+        Bytes.toBytes(Constants.ATTRIBUTE), Bytes.toBytes("reference"));
+    
+    if (result != null) {
+      reference = Bytes.toInt(result);
       reference++;
     }
     setReference(reference);
@@ -508,10 +521,14 @@
 
   protected int decrementAndGetRef() throws IOException {
     int reference = 0;
-    Cell rows = null;
-    rows = table.get(Constants.METADATA, Constants.METADATA_REFERENCE);
-    if (rows != null) {
-      reference = Bytes.toInt(rows.getValue());
+    
+    Get get = new Get(Bytes.toBytes(Constants.METADATA));
+    get.addFamily(Bytes.toBytes(Constants.ATTRIBUTE));
+    byte[] result = table.get(get).getValue(
+        Bytes.toBytes(Constants.ATTRIBUTE), Bytes.toBytes("reference"));
+    
+    if (result != null) {
+      reference = Bytes.toInt(result);
       if (reference > 0) // reference==0, we need not to decrement it.
         reference--;
     }
@@ -520,9 +537,12 @@
   }
 
   protected boolean hasAliaseName() throws IOException {
-    Cell rows = null;
-    rows = table.get(Constants.METADATA, Constants.ALIASENAME);
-    return (rows != null) ? true : false;
+    Get get = new Get(Bytes.toBytes(Constants.METADATA));
+    get.addFamily(Bytes.toBytes(Constants.ALIASEFAMILY));
+    byte[] result = table.get(get).getValue(
+        Bytes.toBytes(Constants.ALIASEFAMILY), Bytes.toBytes("name"));
+
+    return (result != null) ? true : false;
   }
 
   public void close() throws IOException {
@@ -573,10 +593,12 @@
   public boolean save(String aliasename) throws IOException {
     // mark & update the aliase name in "alise:name" meta column.
     // ! one matrix has only one aliasename now.
-    BatchUpdate update = new BatchUpdate(Constants.METADATA);
-    update.put(Constants.ALIASENAME, Bytes.toBytes(aliasename));
-    update.put(Constants.ATTRIBUTE + "type", Bytes.toBytes(this.getType()));
-    table.commit(update);
+    Put put = new Put(Bytes.toBytes(Constants.METADATA));
+    put.add(Bytes.toBytes(Constants.ALIASEFAMILY), Bytes.toBytes("name"), Bytes
+        .toBytes(aliasename));
+    put.add(Bytes.toBytes(Constants.ATTRIBUTE), Bytes.toBytes("type"), Bytes
+        .toBytes(this.getType()));
+    table.put(put);
 
     return hamaAdmin.save(this, aliasename);
   }

Modified: incubator/hama/trunk/src/java/org/apache/hama/matrix/AbstractVector.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/java/org/apache/hama/matrix/AbstractVector.java?rev=824243&r1=824242&r2=824243&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/matrix/AbstractVector.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/matrix/AbstractVector.java Mon Oct 12 07:12:33
2009
@@ -21,13 +21,17 @@
 
 import java.util.Iterator;
 import java.util.Map;
+import java.util.NavigableMap;
 
+import org.apache.hadoop.hbase.client.Result;
 import org.apache.hadoop.hbase.io.Cell;
 import org.apache.hadoop.hbase.io.RowResult;
+import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.hadoop.io.IntWritable;
 import org.apache.hadoop.io.MapWritable;
 import org.apache.hadoop.io.Text;
 import org.apache.hadoop.io.Writable;
+import org.apache.hama.Constants;
 import org.apache.hama.io.DoubleEntry;
 import org.apache.hama.util.BytesUtil;
 import org.apache.log4j.Logger;
@@ -39,6 +43,7 @@
   static final Logger LOG = Logger.getLogger(AbstractVector.class);
   protected MapWritable entries;
 
+  @Deprecated
   public void initMap(RowResult row) {
     this.entries = new MapWritable();
     for (Map.Entry<byte[], Cell> f : row.entrySet()) {
@@ -46,7 +51,18 @@
           new DoubleEntry(f.getValue()));
     }
   }
-
+  
+  public void initMap(Result rs) {
+    this.entries = new MapWritable();
+    NavigableMap<byte[], byte[]> map = rs.getFamilyMap(Bytes.toBytes(Constants.COLUMN_FAMILY));
+    for (Map.Entry<byte[], byte[]> e : map.entrySet()) {
+      if(e != null) {
+        this.entries.put(new IntWritable(Integer.valueOf(Bytes.toString(e.getKey()))),
+            new DoubleEntry(e.getValue()));
+      }
+    }
+  }
+  
   /**
    * Returns an Iterator.
    * 

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=824243&r1=824242&r2=824243&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 Mon Oct 12 07:12:33
2009
@@ -28,7 +28,9 @@
 import org.apache.hadoop.hbase.HColumnDescriptor;
 import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.HTableDescriptor;
+import org.apache.hadoop.hbase.client.Get;
 import org.apache.hadoop.hbase.client.HTable;
+import org.apache.hadoop.hbase.client.Result;
 import org.apache.hadoop.hbase.client.Scanner;
 import org.apache.hadoop.hbase.io.Cell;
 import org.apache.hadoop.hbase.io.RowResult;
@@ -324,11 +326,15 @@
     if (this.getRows() < i || this.getColumns() < j)
       throw new ArrayIndexOutOfBoundsException(i + ", " + j);
 
-    Cell c = table.get(BytesUtil.getRowIndex(i), BytesUtil.getColumnIndex(j));
-    if (c == null)
+    Get get = new Get(BytesUtil.getRowIndex(i));
+    get.addColumn(Bytes.toBytes(Constants.COLUMN_FAMILY));
+    byte[] result = table.get(get).getValue(Bytes.toBytes(Constants.COLUMN_FAMILY),
+        Bytes.toBytes(String.valueOf(j)));
+    
+    if (result == null)
       throw new NullPointerException("Unexpected null");
 
-    return BytesUtil.bytesToDouble(c.getValue());
+    return BytesUtil.bytesToDouble(result);
   }
 
   /**
@@ -339,8 +345,10 @@
    * @throws IOException
    */
   public DenseVector getRow(int i) throws IOException {
-    return new DenseVector(table.getRow(BytesUtil.getRowIndex(i),
-        new byte[][] { Bytes.toBytes(Constants.COLUMN) }));
+    Get get = new Get(BytesUtil.getRowIndex(i));
+    get.addFamily(Bytes.toBytes(Constants.COLUMN_FAMILY));
+    Result r = table.get(get);
+    return new DenseVector(r);
   }
 
   /**
@@ -371,7 +379,7 @@
       throw new ArrayIndexOutOfBoundsException(i + ", " + j);
     VectorUpdate update = new VectorUpdate(i);
     update.put(j, value);
-    table.commit(update.getBatchUpdate());
+    table.put(update.getPut());
   }
 
   /**
@@ -502,11 +510,11 @@
   public DenseMatrix mult(Matrix B) throws IOException {
     ensureForMultiplication(B);
     int columns = 0;
-    if(B.getColumns() == 1 || this.getColumns() == 1)
+    if (B.getColumns() == 1 || this.getColumns() == 1)
       columns = 1;
     else
       columns = this.getColumns();
-    
+
     DenseMatrix result = new DenseMatrix(config, this.getRows(), columns);
 
     for (int i = 0; i < this.getRows(); i++) {
@@ -783,12 +791,19 @@
        * 
        * Compute the rotation parameters of next rotation.
        ************************************************************************/
-      double e1 = BytesUtil.bytesToDouble(table.get(
-          BytesUtil.getRowIndex(pivot_row),
-          Bytes.toBytes(JacobiEigenValue.EIVAL)).getValue());
-      double e2 = BytesUtil.bytesToDouble(table.get(
-          BytesUtil.getRowIndex(pivot_col),
-          Bytes.toBytes(JacobiEigenValue.EIVAL)).getValue());
+      Get get = new Get(BytesUtil.getRowIndex(pivot_row));
+      get.addFamily(Bytes.toBytes(JacobiEigenValue.EI_COLUMNFAMILY));
+      Result r = table.get(get);
+      double e1 = BytesUtil.bytesToDouble(r.getValue(Bytes
+          .toBytes(JacobiEigenValue.EI_COLUMNFAMILY), Bytes
+          .toBytes(JacobiEigenValue.EI_VAL)));
+
+      get = new Get(BytesUtil.getRowIndex(pivot_col));
+      get.addFamily(Bytes.toBytes(JacobiEigenValue.EI_COLUMNFAMILY));
+      r = table.get(get);
+      double e2 = BytesUtil.bytesToDouble(r.getValue(Bytes
+          .toBytes(JacobiEigenValue.EI_COLUMNFAMILY), Bytes
+          .toBytes(JacobiEigenValue.EI_VAL)));
 
       y = (e2 - e1) / 2;
       t = Math.abs(y) + Math.sqrt(pivot * pivot + y * y);

Modified: incubator/hama/trunk/src/java/org/apache/hama/matrix/DenseVector.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/java/org/apache/hama/matrix/DenseVector.java?rev=824243&r1=824242&r2=824243&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/matrix/DenseVector.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/matrix/DenseVector.java Mon Oct 12 07:12:33
2009
@@ -24,13 +24,13 @@
 import java.util.Map;
 import java.util.Set;
 
+import org.apache.hadoop.hbase.client.Result;
 import org.apache.hadoop.hbase.io.RowResult;
 import org.apache.hadoop.io.IntWritable;
 import org.apache.hadoop.io.MapWritable;
 import org.apache.hadoop.io.Writable;
 import org.apache.hama.Constants;
 import org.apache.hama.io.DoubleEntry;
-import org.apache.hama.matrix.Vector.Norm;
 import org.apache.log4j.Logger;
 
 /**
@@ -43,11 +43,15 @@
     this(new MapWritable());
   }
 
+  public DenseVector(RowResult row) {
+    this.initMap(row);
+  }
+  
   public DenseVector(MapWritable m) {
     this.entries = m;
   }
 
-  public DenseVector(RowResult row) {
+  public DenseVector(Result row) {
     this.initMap(row);
   }
 

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=824243&r1=824242&r2=824243&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 Mon Oct 12 07:12:33
2009
@@ -24,7 +24,9 @@
 
 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.Result;
 import org.apache.hadoop.hbase.io.Cell;
 import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.hadoop.io.IntWritable;
@@ -51,7 +53,7 @@
   static private final Path TMP_DIR = new Path(SparseMatrix.class
       .getSimpleName()
       + "_TMP_dir");
-  
+
   public SparseMatrix(HamaConfiguration conf, int m, int n) throws IOException {
     setConfiguration(conf);
 
@@ -81,7 +83,7 @@
     // we don't know where to call Matrix.close in Add & Mul map/reduce
     // process to decrement the reference. It seems difficulty.
   }
-  
+
   /**
    * Generate matrix with random elements
    * 
@@ -101,8 +103,8 @@
     for (int i = 0; i < m; i++) {
       vector.clear();
       for (int j = 0; j < n; j++) {
-        Random r = new Random(); 
-        if(r.nextInt(2) != 0)
+        Random r = new Random();
+        if (r.nextInt(2) != 0)
           vector.set(j, RandomVariable.rand());
       }
       rand.setRow(i, vector);
@@ -110,8 +112,9 @@
 
     return rand;
   }
-  
-  public static SparseMatrix random_mapred(HamaConfiguration conf, int m, int n, double percent)
throws IOException {
+
+  public static SparseMatrix random_mapred(HamaConfiguration conf, int m,
+      int n, double percent) throws IOException {
     SparseMatrix rand = new SparseMatrix(conf, m, n);
     LOG.info("Create the " + m + " * " + n + " random matrix : "
         + rand.getPath());
@@ -163,7 +166,7 @@
     fs.delete(TMP_DIR, true);
     return rand;
   }
-  
+
   @Override
   public Matrix add(Matrix B) throws IOException {
     // TODO Auto-generated method stub
@@ -178,11 +181,14 @@
 
   @Override
   public double get(int i, int j) throws IOException {
-    if(this.getRows() < i || this.getColumns() < j)
-      throw new ArrayIndexOutOfBoundsException(i +", "+ j);
-    
-    Cell c = table.get(BytesUtil.getRowIndex(i), BytesUtil.getColumnIndex(j));
-    return (c != null) ? BytesUtil.bytesToDouble(c.getValue()) : 0.0;
+    if (this.getRows() < i || this.getColumns() < j)
+      throw new ArrayIndexOutOfBoundsException(i + ", " + j);
+
+    Get get = new Get(BytesUtil.getRowIndex(i));
+    get.addColumn(Bytes.toBytes(Constants.COLUMN_FAMILY));
+    byte[] result = table.get(get).getValue(Bytes.toBytes(Constants.COLUMN_FAMILY),
+        Bytes.toBytes(String.valueOf(j)));
+    return (result != null) ? BytesUtil.bytesToDouble(result) : 0.0;
   }
 
   @Override
@@ -199,18 +205,22 @@
    * @throws IOException
    */
   public SparseVector getRow(int i) throws IOException {
-    return new SparseVector(table.getRow(BytesUtil.getRowIndex(i), new byte[][] { Bytes.toBytes(Constants.COLUMN)
}));
+    Get get = new Get(BytesUtil.getRowIndex(i));
+    get.addFamily(Bytes.toBytes(Constants.COLUMN_FAMILY));
+    Result r = table.get(get);
+    // return new SparseVector(r.getRowResult());
+    return new SparseVector(r);
   }
 
   /** {@inheritDoc} */
   public void set(int i, int j, double value) throws IOException {
-    if(value != 0) {
+    if (value != 0) {
       VectorUpdate update = new VectorUpdate(i);
       update.put(j, value);
-      table.commit(update.getBatchUpdate());
+      table.put(update.getPut());
     }
   }
-  
+
   /**
    * Returns type of matrix
    */
@@ -226,19 +236,22 @@
    * @throws IOException
    */
   public SparseMatrix mult(Matrix B) throws IOException {
-    SparseMatrix result = new SparseMatrix(config, this.getRows(), this.getColumns());
+    SparseMatrix result = new SparseMatrix(config, this.getRows(), this
+        .getColumns());
 
-    for(int i = 0; i < this.getRows(); i++) {
+    for (int i = 0; i < this.getRows(); i++) {
       JobConf jobConf = new JobConf(config);
-      jobConf.setJobName("multiplication MR job : " + result.getPath() + " " + i);
+      jobConf.setJobName("multiplication MR job : " + result.getPath() + " "
+          + i);
 
       jobConf.setNumMapTasks(config.getNumMapTasks());
       jobConf.setNumReduceTasks(config.getNumReduceTasks());
-      
-      SparseMatrixVectorMultMap.initJob(i, this.getPath(), B.getPath(), SparseMatrixVectorMultMap.class,
-          IntWritable.class, MapWritable.class, jobConf);
-      SparseMatrixVectorMultReduce.initJob(result.getPath(), SparseMatrixVectorMultReduce.class,
-          jobConf);
+
+      SparseMatrixVectorMultMap.initJob(i, this.getPath(), B.getPath(),
+          SparseMatrixVectorMultMap.class, IntWritable.class,
+          MapWritable.class, jobConf);
+      SparseMatrixVectorMultReduce.initJob(result.getPath(),
+          SparseMatrixVectorMultReduce.class, jobConf);
       JobManager.execute(jobConf);
     }
 
@@ -272,18 +285,18 @@
   @Override
   public void setColumn(int column, Vector vector) throws IOException {
     // TODO Auto-generated method stub
-    
+
   }
 
   @Override
   public void setRow(int row, Vector vector) throws IOException {
-    if(this.getRows() < row)
+    if (this.getRows() < row)
       throw new ArrayIndexOutOfBoundsException(row);
-    
-    if(vector.size() > 0) {  // stores if size > 0
+
+    if (vector.size() > 0) { // stores if size > 0
       VectorUpdate update = new VectorUpdate(row);
       update.putAll(((SparseVector) vector).getEntries());
-      table.commit(update.getBatchUpdate());
+      table.put(update.getPut());
     }
   }
 
@@ -293,4 +306,4 @@
     return null;
   }
 
-}
\ No newline at end of file
+}

Modified: incubator/hama/trunk/src/java/org/apache/hama/matrix/SparseVector.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/java/org/apache/hama/matrix/SparseVector.java?rev=824243&r1=824242&r2=824243&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/matrix/SparseVector.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/matrix/SparseVector.java Mon Oct 12 07:12:33
2009
@@ -22,7 +22,7 @@
 import java.io.IOException;
 import java.util.Map;
 
-import org.apache.hadoop.hbase.io.RowResult;
+import org.apache.hadoop.hbase.client.Result;
 import org.apache.hadoop.io.IntWritable;
 import org.apache.hadoop.io.MapWritable;
 import org.apache.hadoop.io.Writable;
@@ -43,10 +43,10 @@
     this.entries = m;
   }
 
-  public SparseVector(RowResult row) {
+  public SparseVector(Result row) {
     this.initMap(row);
   }
-
+  
   @Override
   public Vector add(double alpha, Vector v) {
     if (alpha == 0)

Modified: incubator/hama/trunk/src/java/org/apache/hama/matrix/algebra/JacobiEigenValue.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/java/org/apache/hama/matrix/algebra/JacobiEigenValue.java?rev=824243&r1=824242&r2=824243&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/matrix/algebra/JacobiEigenValue.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/matrix/algebra/JacobiEigenValue.java Mon
Oct 12 07:12:33 2009
@@ -48,9 +48,16 @@
   /** a matrix copy of the original copy collected in "eicol" family * */
   public static final String EICOL = "eicol:";
   /** a column family collect all values and statuses used during computation * */
+  @Deprecated
   public static final String EI = "eival:";
   /** a column collect all the eigen values * */
+  @Deprecated
   public static final String EIVAL = EI + "value";
+  
+  public static final String EI_COLUMNFAMILY = "eival";
+  public static final String EI_VAL = "value";
+  
+  
   /** a column identify whether the eigen values have been changed * */
   public static final String EICHANGED = EI + "changed";
   /** a column identify the index of the max absolute value each row * */

Modified: incubator/hama/trunk/src/test/org/apache/hama/TestHbaseClient.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/test/org/apache/hama/TestHbaseClient.java?rev=824243&r1=824242&r2=824243&view=diff
==============================================================================
--- incubator/hama/trunk/src/test/org/apache/hama/TestHbaseClient.java (original)
+++ incubator/hama/trunk/src/test/org/apache/hama/TestHbaseClient.java Mon Oct 12 07:12:33
2009
@@ -14,7 +14,6 @@
 import org.apache.hadoop.hbase.util.Bytes;
 
 public class TestHbaseClient extends HBaseClusterTestCase {
-
   private static final byte[] FAMILY = Bytes.toBytes("family");
   private static final byte[] ROW = Bytes.toBytes("row");
   private static final byte[] QUALIFIER = Bytes.toBytes("qualifier");
@@ -58,6 +57,7 @@
     get.addFamily(FAMILY);
     Result r = table.get(get);
     assertFalse(r.isEmpty());
+    assertEquals(Bytes.toString(VALUE), Bytes.toString(r.getValue(FAMILY, QUALIFIER)));
     System.out.println("Row retrieved successfully");
 
     get = new Get(MISSING_ROW);

Modified: incubator/hama/trunk/src/test/org/apache/hama/matrix/TestAbstractMatrix.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/test/org/apache/hama/matrix/TestAbstractMatrix.java?rev=824243&r1=824242&r2=824243&view=diff
==============================================================================
--- incubator/hama/trunk/src/test/org/apache/hama/matrix/TestAbstractMatrix.java (original)
+++ incubator/hama/trunk/src/test/org/apache/hama/matrix/TestAbstractMatrix.java Mon Oct 12
07:12:33 2009
@@ -52,6 +52,7 @@
     double norm1 = matrix.norm(Norm.One);
     double verify_norm1 = MatrixTestCommon.verifyNorm1(matrix);
     gap = norm1 - verify_norm1;
+    LOG.info(">>>>>> " + gap);
     assertTrue(gap < 0.000001 && gap > -0.000001);
 
     double normInfinity = matrix.norm(Norm.Infinity);

Modified: incubator/hama/trunk/src/test/org/apache/hama/matrix/TestSingularValueDecomposition.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/test/org/apache/hama/matrix/TestSingularValueDecomposition.java?rev=824243&r1=824242&r2=824243&view=diff
==============================================================================
--- incubator/hama/trunk/src/test/org/apache/hama/matrix/TestSingularValueDecomposition.java
(original)
+++ incubator/hama/trunk/src/test/org/apache/hama/matrix/TestSingularValueDecomposition.java
Mon Oct 12 07:12:33 2009
@@ -24,6 +24,7 @@
 
 import org.apache.hadoop.hbase.client.Get;
 import org.apache.hadoop.hbase.client.HTable;
+import org.apache.hadoop.hbase.client.Result;
 import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.hama.HamaCluster;
 import org.apache.hama.HamaConfiguration;
@@ -79,9 +80,12 @@
 
     for (int x = 0; x < 2; x++) {
       Get get = new Get(BytesUtil.getRowIndex(x));
-      get.addColumn(Bytes.toBytes(JacobiEigenValue.EIVAL));
-      double eigenvalue = BytesUtil.bytesToDouble(table.get(get).getCellValue()
-          .getValue());
+      get.addColumn(Bytes.toBytes(JacobiEigenValue.EI_COLUMNFAMILY));
+      Result r = table.get(get);
+
+      double eigenvalue = BytesUtil.bytesToDouble(r.getValue(Bytes
+          .toBytes(JacobiEigenValue.EI_COLUMNFAMILY), Bytes
+          .toBytes(JacobiEigenValue.EI_VAL)));
       assertTrue(Math.abs(eigenvalues[x] - eigenvalue) < .0000001);
       assertTrue(Math.abs(Math.pow(eigenvalue, 0.5) - singularvalues[x]) < .0000001);
     }

Modified: incubator/hama/trunk/src/test/org/apache/hama/matrix/TestSparseMatrix.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/test/org/apache/hama/matrix/TestSparseMatrix.java?rev=824243&r1=824242&r2=824243&view=diff
==============================================================================
--- incubator/hama/trunk/src/test/org/apache/hama/matrix/TestSparseMatrix.java (original)
+++ incubator/hama/trunk/src/test/org/apache/hama/matrix/TestSparseMatrix.java Mon Oct 12
07:12:33 2009
@@ -47,9 +47,21 @@
   public void testMult() throws IOException {
     assertTrue(m1.getRows() > 0);
     sparsity();
-    
+    m1.set(0, 0, -8);
+    assertEquals(m1.get(0, 0), -8.0);
+
     SparseMatrix result = m1.mult(m2);
     verifyMultResult(m1, m2, result);
+
+    SparseVector vector = new SparseVector();
+    vector.set(0, 3);
+    vector.set(1, -8);
+    m1.setRow(0, vector);
+    assertEquals(m1.get(0, 0), 3.0);
+    assertEquals(m1.get(0, 1), -8.0);
+    SparseVector vector2 = m1.getRow(0);
+    assertEquals(vector2.get(0), 3.0);
+    assertEquals(vector2.get(1), -8.0);
   }
   
   public void sparsity() throws IOException {



Mime
View raw message