Index: src/test/org/apache/hama/TestDenseMatrix.java =================================================================== --- src/test/org/apache/hama/TestDenseMatrix.java (revision 691826) +++ src/test/org/apache/hama/TestDenseMatrix.java (working copy) @@ -38,13 +38,13 @@ private static int SIZE = 5; private static Matrix m1; private static Matrix m2; - + public static Test suite() { TestSetup setup = new TestSetup(new TestSuite(TestDenseMatrix.class)) { protected void setUp() throws Exception { HCluster hCluster = new HCluster(); hCluster.setUp(); - + m1 = DenseMatrix.random(hCluster.conf, SIZE, SIZE); m2 = DenseMatrix.random(hCluster.conf, SIZE, SIZE); } @@ -55,7 +55,7 @@ }; return setup; } - + /** * Column vector test. * @@ -75,7 +75,7 @@ /** * Test matrices addition */ - public void testMatrixAdd() { + public void testMatrixAdd() throws IOException { Matrix result = m1.add(m2); for (int i = 0; i < SIZE; i++) { @@ -88,7 +88,7 @@ /** * Test matrices multiplication */ - public void testMatrixMult() { + public void testMatrixMult() throws IOException { Matrix result = m1.mult(m2); verifyMultResult(SIZE, m1, m2, result); @@ -102,7 +102,8 @@ * @param m2 * @param result */ - private void verifyMultResult(int size, Matrix m1, Matrix m2, Matrix result) { + private void verifyMultResult(int size, Matrix m1, Matrix m2, Matrix result) + throws IOException { double[][] C = new double[SIZE][SIZE]; for (int i = 0; i < SIZE; i++) Index: src/java/org/apache/hama/DenseMatrix.java =================================================================== --- src/java/org/apache/hama/DenseMatrix.java (revision 691826) +++ src/java/org/apache/hama/DenseMatrix.java (working copy) @@ -116,7 +116,8 @@ * @param n the number of columns. * @return an m-by-n matrix with uniformly distributed random elements. */ - public static Matrix random(HamaConfiguration conf, int m, int n) { + public static Matrix random(HamaConfiguration conf, int m, int n) + throws IOException { String name = RandomVariable.randMatrixName(); Matrix rand = new DenseMatrix(conf, name); for (int i = 0; i < m; i++) { @@ -158,7 +159,7 @@ public DenseVector getRow(int row) throws IOException { return new DenseVector(row, table.getRow(String.valueOf(row))); } - + public Vector getColumn(int column) throws IOException { byte[] columnKey = Numeric.getColumnIndex(column); byte[][] c = { columnKey }; @@ -167,13 +168,14 @@ VectorMapWritable trunk = new VectorMapWritable(); for (RowResult row : scan) { - trunk.put(Numeric.bytesToInt(row.getRow()), new VectorEntry(row.get(columnKey))); + trunk.put(Numeric.bytesToInt(row.getRow()), new VectorEntry(row + .get(columnKey))); } return new DenseVector(column, trunk); } - public Matrix mult(Matrix B) { + public Matrix mult(Matrix B) throws IOException { String output = RandomVariable.randMatrixName(); Matrix C = new DenseMatrix(config, output); @@ -184,12 +186,7 @@ IntWritable.class, DenseVector.class, jobConf); MatrixReduce.initJob(C.getName(), MultiplicationReduce.class, jobConf); - try { - JobClient.runJob(jobConf); - } catch (IOException e) { - e.printStackTrace(); - } - + JobClient.runJob(jobConf); return C; } Index: src/java/org/apache/hama/Matrix.java =================================================================== --- src/java/org/apache/hama/Matrix.java (revision 691826) +++ src/java/org/apache/hama/Matrix.java (working copy) @@ -33,7 +33,7 @@ * @param j jth column of the matrix * @return the value of entry */ - public double get(int i, int j); + public double get(int i, int j)throws IOException; /** * Gets the vector of row @@ -58,14 +58,14 @@ * * @return a number of rows of the matrix */ - public int getRows(); + public int getRows() throws IOException; /** * Get a number of column of the matrix from the meta-data column * * @return a number of columns of the matrix */ - public int getColumns(); + public int getColumns() throws IOException; /** * Sets the double value of (i, j) @@ -74,7 +74,7 @@ * @param j jth column of the matrix * @param value the value of entry */ - public void set(int i, int j, double value); + public void set(int i, int j, double value) throws IOException; /** * A=alpha*B @@ -83,7 +83,7 @@ * @param B * @return A */ - public Matrix set(double alpha, Matrix B); + public Matrix set(double alpha, Matrix B) throws IOException; /** * A=B @@ -91,7 +91,7 @@ * @param B * @return A */ - public Matrix set(Matrix B); + public Matrix set(Matrix B) throws IOException; /** * Sets the dimension of matrix @@ -99,7 +99,7 @@ * @param rows the number of rows * @param columns the number of columns */ - public void setDimension(int rows, int columns); + public void setDimension(int rows, int columns) throws IOException; /** * A(i, j) += value @@ -108,7 +108,7 @@ * @param j * @param value */ - public void add(int i, int j, double value); + public void add(int i, int j, double value) throws IOException; /** * A = B + A @@ -116,7 +116,7 @@ * @param B * @return A */ - public Matrix add(Matrix B); + public Matrix add(Matrix B) throws IOException; /** * A = alpha*B + A @@ -125,7 +125,7 @@ * @param B * @return A */ - public Matrix add(double alpha, Matrix B); + public Matrix add(double alpha, Matrix B) throws IOException; /** * C = A*B @@ -133,7 +133,7 @@ * @param B * @return C */ - public Matrix mult(Matrix B); + public Matrix mult(Matrix B) throws IOException; /** * C = alpha*A*B + C @@ -143,7 +143,7 @@ * @param C * @return C */ - public Matrix multAdd(double alpha, Matrix B, Matrix C); + public Matrix multAdd(double alpha, Matrix B, Matrix C) throws IOException; /** * Computes the given norm of the matrix @@ -151,7 +151,7 @@ * @param type * @return norm of the matrix */ - public double norm(Norm type); + public double norm(Norm type) throws IOException; /** * Supported matrix-norms. Index: src/java/org/apache/hama/AbstractMatrix.java =================================================================== --- src/java/org/apache/hama/AbstractMatrix.java (revision 691826) +++ src/java/org/apache/hama/AbstractMatrix.java (working copy) @@ -78,71 +78,50 @@ } /** {@inheritDoc} */ - public double get(int i, int j) { + public double get(int i, int j) throws IOException { Cell c; double result = -1; - try { - c = table.get(Bytes.toBytes(String.valueOf(i)), Numeric.getColumnIndex(j)); - if (c != null) { - result = Numeric.bytesToDouble(c.getValue()); - } - } catch (IOException e) { - LOG.error(e, e); + c = table.get(Bytes.toBytes(String.valueOf(i)), Numeric.getColumnIndex(j)); + if (c != null) { + result = Numeric.bytesToDouble(c.getValue()); } return result; } /** {@inheritDoc} */ - public int getRows() { + public int getRows() throws IOException { Cell rows = null; - try { - rows = table.get(Constants.METADATA, Constants.METADATA_ROWS); - } catch (IOException e) { - LOG.error(e, e); - } - + rows = table.get(Constants.METADATA, Constants.METADATA_ROWS); return Bytes.toInt(rows.getValue()); } /** {@inheritDoc} */ - public int getColumns() { + public int getColumns() throws IOException { Cell columns = null; - try { - columns = table.get(Constants.METADATA, Constants.METADATA_COLUMNS); - } catch (IOException e) { - LOG.error(e, e); - } + columns = table.get(Constants.METADATA, Constants.METADATA_COLUMNS); return Bytes.toInt(columns.getValue()); } /** {@inheritDoc} */ - public void set(int i, int j, double value) { + public void set(int i, int j, double value) throws IOException { BatchUpdate b = new BatchUpdate(new Text(String.valueOf(i))); b.put(new Text(Constants.COLUMN + String.valueOf(j)), Numeric .doubleToBytes(value)); - try { - table.commit(b); - } catch (IOException e) { - LOG.error(e, e); - } + table.commit(b); } /** {@inheritDoc} */ - public void add(int i, int j, double value) { + public void add(int i, int j, double value) throws IOException { // TODO Auto-generated method stub } /** {@inheritDoc} */ - public void setDimension(int rows, int columns) { + public void setDimension(int rows, int columns) throws IOException { BatchUpdate b = new BatchUpdate(Constants.METADATA); b.put(Constants.METADATA_ROWS, Bytes.toBytes(rows)); b.put(Constants.METADATA_COLUMNS, Bytes.toBytes(columns)); - try { - table.commit(b); - } catch (IOException e) { - LOG.error(e, e); - } + table.commit(b); } /** {@inheritDoc} */