[
https://issues.apache.org/jira/browse/HAMA-88?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12642370#action_12642370
]
Samuel Guo commented on HAMA-88:
--------------------------------
My proposal will be:
1. change Matrix.getName() to Matrix.getPath().
As my first comment, a path means the path to store the matrix'data. In
DenseMatrix, it means a tablename in HBase.
2. change the HamaAdmin interface to make the logic clear.
HamaAdmin is a manager of the mapping a matrix aliase name to a matrix's path.
public interface HamaAdmin {
/**
* Saves matrix as name 'AliaseName'
*
* @param matrix
* @param aliaseName
* @return true if it saved
*/
public boolean save(Matrix matrix, String aliaseName);
/**
* Get a matrix aliased as 'AliaseMatrixName'
*
* @param aliaseName
* @return Matrix, if there is a matrix aliased as "aliaseMatrixName",
otherwise null.
*/
public Matrix load(String aliaseMatrixName);
/**
* @param AliaseMatrixName
* @return true if matrix is exist
*/
public boolean matrixExists(String aliaseMatrixName);
/**
* remove the aliaseMatrixName.
* if the matrix has other aliaseMatrixNames, this method will not delete
matrix.
* if the matrix has no any more aliaseMatrixName, this method finally delete
the matrix.
*
* @param matrixName
* @throws IOException
*/
public void remove(String matrixName) throws IOException;
/**
* Deletes the matrix, and also remove all its aliaseMatrixNames store in
HamaAdmin.
*
* @param matrixName
* @throws IOException
*/
public void delete(String matrixName) throws IOException;
}
3. add an attribute in DenseMatrix "attribute:aliases" to count the number of
aliasename store in HamaAdmin.
so,
1) DenseMatrix.close() will see the "attribute:aliases" to see if any
aliasename stored in HamaAdmin aliase this matrix. if not, we delete the matrix
while we closing it. if so, we just disconnect the connnection to the matrix's
table in HBase.
2) HamaAdmin.save() will increment the "attribute:aliases" of a matrix.
HamaAdmin.decrement it. "attribute:aliase" acts like a reference count in
garbage collection. we will know when we doesn't need the matrix'table.
4. move "public DenseMatrix(HamaConfiguration conf, String matrixName)" to
"protected DenseMatrix(...)".
so we don't expose this constructor to the user. And this constructor is used
in HamaAdmin to load a matrix from an existed matrix's table.
Above are just 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.