incubator-hama-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From edwardy...@apache.org
Subject svn commit: r708072 - in /incubator/hama/trunk/src/java/org/apache/hama: AbstractMatrix.java Constants.java DenseMatrix.java HamaAdmin.java HamaAdminImpl.java Matrix.java
Date Mon, 27 Oct 2008 02:08:10 GMT
Author: edwardyoon
Date: Sun Oct 26 19:08:09 2008
New Revision: 708072

URL: http://svn.apache.org/viewvc?rev=708072&view=rev
Log:
Save type information.

Modified:
    incubator/hama/trunk/src/java/org/apache/hama/AbstractMatrix.java
    incubator/hama/trunk/src/java/org/apache/hama/Constants.java
    incubator/hama/trunk/src/java/org/apache/hama/DenseMatrix.java
    incubator/hama/trunk/src/java/org/apache/hama/HamaAdmin.java
    incubator/hama/trunk/src/java/org/apache/hama/HamaAdminImpl.java
    incubator/hama/trunk/src/java/org/apache/hama/Matrix.java

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=708072&r1=708071&r2=708072&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/AbstractMatrix.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/AbstractMatrix.java Sun Oct 26 19:08:09
2008
@@ -156,6 +156,6 @@
   }
 
   public boolean save(String name) throws IOException {
-    return store.save(this.matrixPath, name);
+    return store.save(this, name);
   }
 }

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=708072&r1=708071&r2=708072&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/Constants.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/Constants.java Sun Oct 26 19:08:09 2008
@@ -78,4 +78,6 @@
    * Temporary Aliase name prefix in Hama Shell
    */
   public static final String RANDOMALIASE = "_";
+
+  public static final String MATRIXTYPE = "type:";
 }

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=708072&r1=708071&r2=708072&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/DenseMatrix.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/DenseMatrix.java Sun Oct 26 19:08:09 2008
@@ -263,4 +263,8 @@
   public void setColumn(int column, Vector vector) throws IOException {
     // TODO Auto-generated method stub
   }
+
+  public String getType() {
+    return this.getClass().getSimpleName();
+  }
 }

Modified: incubator/hama/trunk/src/java/org/apache/hama/HamaAdmin.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/java/org/apache/hama/HamaAdmin.java?rev=708072&r1=708071&r2=708072&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/HamaAdmin.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/HamaAdmin.java Sun Oct 26 19:08:09 2008
@@ -24,13 +24,13 @@
 public interface HamaAdmin {
 
   /**
-   * Saves matrix
-   * 
-   * @param tempName
-   * @param name
+   * Saves matrix as name 'AliaseName'
+   *
+   * @param matrix
+   * @param aliaseName
    * @return true if it saved
    */
-  public boolean save(String tempName, String name);
+  public boolean save(Matrix matrix, String aliaseName); 
 
   /**
    * @param name

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=708072&r1=708071&r2=708072&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/HamaAdminImpl.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/HamaAdminImpl.java Sun Oct 26 19:08:09 2008
@@ -28,9 +28,10 @@
 import org.apache.hadoop.hbase.io.BatchUpdate;
 import org.apache.hadoop.hbase.io.Cell;
 import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.log4j.Logger;
 
 public class HamaAdminImpl implements HamaAdmin {
-
+  static final Logger LOG = Logger.getLogger(HamaAdminImpl.class);
   public HamaConfiguration conf;
   public HBaseAdmin admin;
   public HTable table;
@@ -51,6 +52,7 @@
       if (!admin.tableExists(Constants.ADMINTABLE)) {
         HTableDescriptor tableDesc = new HTableDescriptor(Constants.ADMINTABLE);
         tableDesc.addFamily(new HColumnDescriptor(Constants.PATHCOLUMN));
+        tableDesc.addFamily(new HColumnDescriptor(Constants.MATRIXTYPE));
         admin.createTable(tableDesc);
       }
 
@@ -84,11 +86,14 @@
     }
   }
 
-  public boolean save(String tempName, String name) {
+  public boolean save(Matrix mat, String aliaseName) {
     boolean result = false;
 
-    BatchUpdate update = new BatchUpdate(name);
-    update.put(Constants.PATHCOLUMN, Bytes.toBytes(tempName));
+    BatchUpdate update = new BatchUpdate(aliaseName);
+    update.put(Constants.PATHCOLUMN, Bytes.toBytes(mat.getName()));
+    // So, If we load a dense matrix, return the DenseMatrix.
+    update.put(Constants.MATRIXTYPE, Bytes.toBytes(mat.getType()));
+    
     try {
       table.commit(update);
       result = true;
@@ -101,12 +106,12 @@
 
   public void delete(String matrixName) throws IOException {
     String table;
-    if(matrixExists(matrixName)) {
+    if (matrixExists(matrixName)) {
       table = getPath(matrixName);
     } else {
       table = matrixName;
     }
-    
+
     if (admin.isTableEnabled(table)) {
       admin.disableTable(table);
       admin.deleteTable(table);

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=708072&r1=708071&r2=708072&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/Matrix.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/Matrix.java Sun Oct 26 19:08:09 2008
@@ -241,6 +241,10 @@
   public boolean save(String path) throws IOException;
 
   /**
+   * @return the matrix type
+   */
+  public String getType();
+  /**
    * Close current matrix.
    * 
    * @throws Exception



Mime
View raw message