Author: edwardyoon
Date: Thu Oct 9 02:52:32 2008
New Revision: 703111
URL: http://svn.apache.org/viewvc?rev=703111&view=rev
Log:
Remove load() since it duplicated with constructor
Modified:
incubator/hama/trunk/CHANGES.txt
incubator/hama/trunk/src/java/org/apache/hama/AbstractMatrix.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/Matrix.java
incubator/hama/trunk/src/test/org/apache/hama/TestDenseMatrix.java
Modified: incubator/hama/trunk/CHANGES.txt
URL:
http://svn.apache.org/viewvc/incubator/hama/trunk/CHANGES.txt?rev=703111&r1=703110&r2=703111&view=diff
==============================================================================
--- incubator/hama/trunk/CHANGES.txt (original)
+++ incubator/hama/trunk/CHANGES.txt Thu Oct 9 02:52:32 2008
@@ -25,6 +25,7 @@
IMPROVEMENTS
+ HAMA-76: Remove load() since it duplicated with constructor (edwardyoon)
HAMA-73: Add setNumMap/ReduceTasks() to HamaConfiguration (edwardyoon)
HAMA-60: Add an arguments for handle parallel degree to MatrixAddition
(edwardyoon)
HAMA-68: Shell parser JUnit test cases (samuel via edwardyoon)
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=703111&r1=703110&r2=703111&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/AbstractMatrix.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/AbstractMatrix.java Thu Oct
9 02:52:32 2008
@@ -70,11 +70,14 @@
* Create matrix space
*/
protected void create() throws IOException {
- this.tableDesc.addFamily(new HColumnDescriptor(Constants.COLUMN));
- this.tableDesc.addFamily(new HColumnDescriptor(Constants.ATTRIBUTE));
+ // It should run only when table doesn't exist.
+ if (!admin.tableExists(matrixName)) {
+ this.tableDesc.addFamily(new HColumnDescriptor(Constants.COLUMN));
+ this.tableDesc.addFamily(new HColumnDescriptor(Constants.ATTRIBUTE));
- LOG.info("Initializing the matrix storage.");
- this.admin.createTable(this.tableDesc);
+ LOG.info("Initializing the matrix storage.");
+ this.admin.createTable(this.tableDesc);
+ }
}
/** [EMAIL PROTECTED] */
@@ -153,7 +156,7 @@
}
public void close() throws IOException {
- if(admin.isTableEnabled(matrixName)) {
+ if (admin.isTableEnabled(matrixName)) {
admin.disableTable(matrixName);
admin.deleteTable(matrixName);
} else {
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=703111&r1=703110&r2=703111&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/DenseMatrix.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/DenseMatrix.java Thu Oct 9
02:52:32 2008
@@ -64,14 +64,15 @@
public DenseMatrix(HamaConfiguration conf, String matrixName) {
try {
setConfiguration(conf);
- this.matrixName = matrixName;
-
- if (!admin.tableExists(matrixName)) {
+ if(hAdmin.tableExists(matrixName)) {
+ this.matrixName = hAdmin.get(matrixName);
+ } else {
+ this.matrixName = matrixName;
tableDesc = new HTableDescriptor(matrixName);
create();
}
- table = new HTable(config, matrixName);
+ table = new HTable(config, this.matrixName);
} catch (Exception e) {
e.printStackTrace();
}
@@ -234,9 +235,4 @@
public void setColumn(int column, Vector vector) throws IOException {
// TODO Auto-generated method stub
}
-
- public void load(String path) throws IOException {
- matrixName = hAdmin.get(path);
- table = new HTable(matrixName);
- }
}
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=703111&r1=703110&r2=703111&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/HamaAdmin.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/HamaAdmin.java Thu Oct 9
02:52:32 2008
@@ -26,6 +26,7 @@
import org.apache.hadoop.hbase.client.HBaseAdmin;
import org.apache.hadoop.hbase.client.HTable;
import org.apache.hadoop.hbase.io.BatchUpdate;
+import org.apache.hadoop.hbase.io.Cell;
import org.apache.hadoop.hbase.util.Bytes;
/**
@@ -89,4 +90,14 @@
return null;
}
}
+
+ public boolean tableExists(String matrixName) {
+ try {
+ Cell result = table.get(matrixName, Constants.PATHCOLUMN);
+ return (result == null) ? false : true;
+ } catch (IOException e) {
+ e.printStackTrace();
+ return false;
+ }
+ }
}
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=703111&r1=703110&r2=703111&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/Matrix.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/Matrix.java Thu Oct 9
02:52:32 2008
@@ -241,14 +241,6 @@
public boolean save(String path) throws IOException;
/**
- * Load the matrix from a table or file
- *
- * @param path
- * @throws IOException
- */
- public void load(String path) throws IOException;
-
- /**
* Close current matrix.
*
* @throws Exception
Modified: incubator/hama/trunk/src/test/org/apache/hama/TestDenseMatrix.java
URL:
http://svn.apache.org/viewvc/incubator/hama/trunk/src/test/org/apache/hama/TestDenseMatrix.java?rev=703111&r1=703110&r2=703111&view=diff
==============================================================================
--- incubator/hama/trunk/src/test/org/apache/hama/TestDenseMatrix.java
(original)
+++ incubator/hama/trunk/src/test/org/apache/hama/TestDenseMatrix.java Thu Oct
9 02:52:32 2008
@@ -145,8 +145,7 @@
public void testLoadSave() throws IOException {
m1.save("udanax");
HCluster hCluster = new HCluster();
- DenseMatrix loadTest = new DenseMatrix(hCluster.conf);
- loadTest.load("udanax");
+ DenseMatrix loadTest = new DenseMatrix(hCluster.conf, "udanax");
for (int i = 0; i < loadTest.getRows(); i++) {
for (int j = 0; j < loadTest.getColumns(); j++) {