You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hama.apache.org by "Samuel Guo (JIRA)" <ji...@apache.org> on 2008/10/22 16:09:44 UTC

[jira] Commented: (HAMA-88) DenseMatrix.close should not delete the table that are aliased in HamaAdmin.

    [ https://issues.apache.org/jira/browse/HAMA-88?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12641873#action_12641873 ] 

Samuel Guo commented on HAMA-88:
--------------------------------

I am confusing about DenseMatrix.matrixname, DenseMatrix matrixpath.
I think we just need DenseMatrix.matrixpath in a DenseMatrix Object. It means the tablename of the matrix in HBase. It is a path point to hbase table.

A DenseMatrix can be created from scratch, 
or it can be created from an existed matrix table in hbase whose name is aliased in HamaAdmin.

  /**
   * Construct an matrix
   * 
   * @param conf configuration object
   * @param matrixName the name of the matrix
   */
  public DenseMatrix(HamaConfiguration conf, String matrixName) {
    try {
      setConfiguration(conf);
 >     this.matrixName = matrixName;  // we don't need it.
      if (store.matrixExists(matrixName)) { // we use matrixName to get the path of the existed matrix table in HBase, let matrixPath point to the table.
        this.matrixPath = store.getPath(matrixName);
      } else { // now we create a matrix table with a given name. so the path will be matrixName. 
        this.matrixPath = matrixName;
>     store.save(matrixName, matrixName);   // we can save it to HamaAdmin.
        tableDesc = new HTableDescriptor(matrixName);
        create();
      }

      table = new HTable(config, this.matrixPath);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }

so now we can say that : Matrix just contain a point to the table in HBase; HamaAdmin maintain a map between matrixname to matrixpath(tablename) for reuseable.

so when we use Matrix.close to close a Matrix, we just disconnect a connection to HBase's table. If the matrix is aliased in HamaAdmin, we needn't to delete the table in HBase. If the matrix is not aliased in HamaAdmin, it means that no one will use the table again, we can delete the table in HBase.

The use of matrix's save/load opertions will be clear.
1) 
String matrixname = "MatrixA";
Matrix a = DenseMatrix.random(conf, 10, 10); // the matrix path will be "rand****"
a.save(matrixname); // we aliase the matrix a as name "MatrixA", so we can reuse it.
a.close(); // we just disconnect Matrix a's connection to HBase table "rand*****", we don't delete it.

Matrix b = new DenseMatrix(conf, matrixname); // so, we can use it again.

2)
String matrixname = "MatrixB"
Matrix b = DenseMatrix.random(conf, 10, 10); 
b.close();

in the second case, we don't use Matrix b again. we will delete the table in HBase while we close the matrix.

3)
String matrixname = "MatrixC"
Matrix c = new DenseMatrix(conf, matrixname); // there is no Matrix aliased "MatrixC" in HamaAdmin. so we will create a Matrix named "MatrixC".
                                                                                     // Specifying a MatrixName means that we may reuse "MatrixC" to use the Matrix again and again.
                                                                                     // So during creating a table named "MatrixC" in HBase, we also added "MatrixC" to HamaAdmin.
c.close();

Matrix d = new DenseMatrix(conf, matrixname); // Matrix d will connect to the table "MatrixC" in HBase. Use it again.


Above are my thoughts. Welcome for comments.

> DenseMatrix.close should not delete the table that are aliased in HamaAdmin.
> ----------------------------------------------------------------------------
>
>                 Key: HAMA-88
>                 URL: https://issues.apache.org/jira/browse/HAMA-88
>             Project: Hama
>          Issue Type: Bug
>    Affects Versions: 0.1.0
>            Reporter: Samuel Guo
>             Fix For: 0.1.0
>
>
> for example:
> "
> String matrixname = "MatrixA";
> Matrix a = DenseMatrix.random(conf, 10, 10);
> a.save(matrixname);
> a.close();
> Matrix b = new DenseMatrix(conf, matrixname);
> "
> If we close a matrix, we alse delete the table in hbase. so we can use its aliase name keeped in HamaAdmin to reopen the matrix.
> so we need to identify if the matrix has been keeped in HamaAdmin. If the matrix has been aliased in HamaAdmin, we should not delete the table in Hbase. 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.