You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hama.apache.org by ed...@apache.org on 2009/02/23 08:29:09 UTC
svn commit: r746907 - in /incubator/hama/trunk: ./ src/java/org/apache/hama/
src/test/org/apache/hama/ src/test/org/apache/hama/mapred/
Author: edwardyoon
Date: Mon Feb 23 07:29:09 2009
New Revision: 746907
URL: http://svn.apache.org/viewvc?rev=746907&view=rev
Log:
When out of index, should throw exception
Removed:
incubator/hama/trunk/src/test/org/apache/hama/mapred/TestMatrixMapReduce.java
Modified:
incubator/hama/trunk/CHANGES.txt
incubator/hama/trunk/src/java/org/apache/hama/AbstractVector.java
incubator/hama/trunk/src/java/org/apache/hama/DenseMatrix.java
incubator/hama/trunk/src/test/org/apache/hama/TestDenseMatrix.java
incubator/hama/trunk/src/test/org/apache/hama/TestDenseVector.java
Modified: incubator/hama/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/CHANGES.txt?rev=746907&r1=746906&r2=746907&view=diff
==============================================================================
--- incubator/hama/trunk/CHANGES.txt (original)
+++ incubator/hama/trunk/CHANGES.txt Mon Feb 23 07:29:09 2009
@@ -101,6 +101,7 @@
BUG FIXES
+ HAMA-155: When out of index, should throw exception (edwardyoon)
HAMA-147: Fix typos (edwardyoon)
HAMA-140: In subMatrix(), Scanner should be closed (edwardyoon)
HAMA-120: remove findbugs warning in shell package (samuel via edwardyoon)
Modified: incubator/hama/trunk/src/java/org/apache/hama/AbstractVector.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/java/org/apache/hama/AbstractVector.java?rev=746907&r1=746906&r2=746907&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/AbstractVector.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/AbstractVector.java Mon Feb 23 07:29:09 2009
@@ -44,7 +44,7 @@
try {
value = ((DoubleEntry) this.entries.get(new IntWritable(index))).getValue();
} catch (NullPointerException e) {
- throw new NullPointerException("v("+index+") : " + e.toString());
+ throw new ArrayIndexOutOfBoundsException(index);
}
return value;
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=746907&r1=746906&r2=746907&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/DenseMatrix.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/DenseMatrix.java Mon Feb 23 07:29:09 2009
@@ -337,6 +337,9 @@
* @throws IOException
*/
public double get(int i, int j) throws IOException {
+ if(this.getRows() < i || this.getColumns() < j)
+ throw new ArrayIndexOutOfBoundsException(i +", "+ j);
+
Cell c = table.get(BytesUtil.getRowIndex(i), BytesUtil.getColumnIndex(j));
return (c != null) ? BytesUtil.bytesToDouble(c.getValue()) : 0;
}
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=746907&r1=746906&r2=746907&view=diff
==============================================================================
--- incubator/hama/trunk/src/test/org/apache/hama/TestDenseMatrix.java (original)
+++ incubator/hama/trunk/src/test/org/apache/hama/TestDenseMatrix.java Mon Feb 23 07:29:09 2009
@@ -84,6 +84,17 @@
assertEquals(m1.get(1, 1), origin + 0.5);
}
+ public void testGet() throws IOException {
+ boolean ex = false;
+ try {
+ m1.get(SIZE + 1, SIZE + 1);
+ } catch (ArrayIndexOutOfBoundsException e) {
+ ex = true;
+ }
+ assertTrue(ex);
+ assertTrue(m1.get(0, 0) > 0);
+ }
+
/**
* Column vector test.
*
Modified: incubator/hama/trunk/src/test/org/apache/hama/TestDenseVector.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/test/org/apache/hama/TestDenseVector.java?rev=746907&r1=746906&r2=746907&view=diff
==============================================================================
--- incubator/hama/trunk/src/test/org/apache/hama/TestDenseVector.java (original)
+++ incubator/hama/trunk/src/test/org/apache/hama/TestDenseVector.java Mon Feb 23 07:29:09 2009
@@ -119,6 +119,13 @@
*/
public void testGetSet() throws IOException {
assertEquals(v1.get(0), values[0][0]);
+ boolean ex = false;
+ try {
+ v1.get(5);
+ } catch (ArrayIndexOutOfBoundsException e) {
+ ex = true;
+ }
+ assertTrue(ex);
assertEquals(m1.getColumn(0).size(), 2);
}