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/10/30 10:52:07 UTC
svn commit: r831245 - in /incubator/hama/trunk: ./
src/java/org/apache/hama/graph/ src/java/org/apache/hama/mapreduce/
src/java/org/apache/hama/matrix/algebra/ src/test/org/apache/hama/graph/
src/test/org/apache/hama/matrix/ src/test/org/apache/hama/util/
Author: edwardyoon
Date: Fri Oct 30 09:52:06 2009
New Revision: 831245
URL: http://svn.apache.org/viewvc?rev=831245&view=rev
Log:
Replacement for deprecated API of Map/Reduce
Removed:
incubator/hama/trunk/src/java/org/apache/hama/graph/Graph.java
incubator/hama/trunk/src/java/org/apache/hama/graph/SparseGraph.java
incubator/hama/trunk/src/test/org/apache/hama/graph/TestGraph.java
Modified:
incubator/hama/trunk/CHANGES.txt
incubator/hama/trunk/src/java/org/apache/hama/mapreduce/CollectBlocksMapper.java
incubator/hama/trunk/src/java/org/apache/hama/matrix/algebra/MatrixNormMapReduce.java
incubator/hama/trunk/src/test/org/apache/hama/matrix/TestAbstractMatrix.java
incubator/hama/trunk/src/test/org/apache/hama/matrix/TestSingularValueDecomposition.java
incubator/hama/trunk/src/test/org/apache/hama/util/TestNumeric.java
Modified: incubator/hama/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/CHANGES.txt?rev=831245&r1=831244&r2=831245&view=diff
==============================================================================
--- incubator/hama/trunk/CHANGES.txt (original)
+++ incubator/hama/trunk/CHANGES.txt Fri Oct 30 09:52:06 2009
@@ -42,6 +42,8 @@
IMPROVEMENTS
+ HAMA-202: Replacement for deprecated API of Map/Reduce (edwardyoon)
+ HAMA-206: Replacement of JacobiEigenValueMap/Reduce (edwardyoon)
HAMA-217: Replacement of Block Multiplication Map/Reduce (edwardyoon)
HAMA-205: Replacement of NormMap/Reduce (edwardyoon)
HAMA-207: Replacement of Mat-Mat addition Map/Reduce (edwardyoon)
Modified: incubator/hama/trunk/src/java/org/apache/hama/mapreduce/CollectBlocksMapper.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/java/org/apache/hama/mapreduce/CollectBlocksMapper.java?rev=831245&r1=831244&r2=831245&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/mapreduce/CollectBlocksMapper.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/mapreduce/CollectBlocksMapper.java Fri Oct 30 09:52:06 2009
@@ -19,7 +19,7 @@
public static final String BLOCK_SIZE = "hama.blocking.size";
public static final String ROWS = "hama.blocking.rows";
public static final String COLUMNS = "hama.blocking.columns";
- public static final String MATRIX_POS = "a.ore.b";
+ public static final String MATRIX_POS = "a.or.b";
private int mBlockNum;
private int mBlockRowSize;
Modified: incubator/hama/trunk/src/java/org/apache/hama/matrix/algebra/MatrixNormMapReduce.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/java/org/apache/hama/matrix/algebra/MatrixNormMapReduce.java?rev=831245&r1=831244&r2=831245&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/matrix/algebra/MatrixNormMapReduce.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/matrix/algebra/MatrixNormMapReduce.java Fri Oct 30 09:52:06 2009
@@ -21,6 +21,7 @@
/** Infinity Norm */
public static class MatrixInfinityNormMapper extends
TableMapper<IntWritable, DoubleWritable> {
+ private DoubleWritable nValue = new DoubleWritable();
@Override
public void map(ImmutableBytesWritable key, Result value, Context context)
@@ -33,7 +34,8 @@
rowSum += Math.abs(BytesUtil.bytesToDouble(e.getValue()));
}
- context.write(MatrixNormMapReduce.nKey, new DoubleWritable(rowSum));
+ nValue.set(rowSum);
+ context.write(MatrixNormMapReduce.nKey, nValue);
}
}
@@ -44,6 +46,7 @@
Reducer<IntWritable, DoubleWritable, IntWritable, DoubleWritable> {
static final Logger LOG = Logger.getLogger(MatrixInfinityNormReduce.class);
private double max = 0;
+ private DoubleWritable nValue = new DoubleWritable();
public void reduce(IntWritable key, Iterable<DoubleWritable> values,
Context context) throws IOException, InterruptedException {
@@ -51,13 +54,16 @@
max = Math.max(val.get(), max);
}
- context.write(MatrixNormMapReduce.nKey, new DoubleWritable(max));
+ nValue.set(max);
+ context.write(MatrixNormMapReduce.nKey, nValue);
}
}
/** One Norm Mapper */
public static class MatrixOneNormMapper extends
TableMapper<IntWritable, DoubleWritable> {
+ private IntWritable newkey = new IntWritable();
+ private DoubleWritable nValue = new DoubleWritable();
@Override
public void map(ImmutableBytesWritable key, Result value, Context context)
@@ -66,8 +72,9 @@
NavigableMap<byte[], byte[]> v = value
.getFamilyMap(Constants.COLUMNFAMILY);
for (Map.Entry<byte[], byte[]> e : v.entrySet()) {
- context.write(new IntWritable(BytesUtil.bytesToInt(e.getKey())),
- new DoubleWritable(BytesUtil.bytesToDouble(e.getValue())));
+ newkey.set(BytesUtil.bytesToInt(e.getKey()));
+ nValue.set(BytesUtil.bytesToDouble(e.getValue()));
+ context.write(newkey, nValue);
}
}
}
@@ -75,6 +82,7 @@
/** One Norm Combiner * */
public static class MatrixOneNormCombiner extends
Reducer<IntWritable, DoubleWritable, IntWritable, DoubleWritable> {
+ private DoubleWritable nValue = new DoubleWritable();
@Override
public void reduce(IntWritable key, Iterable<DoubleWritable> values,
@@ -85,7 +93,8 @@
partialColSum += val.get();
}
- context.write(key, new DoubleWritable(partialColSum));
+ nValue.set(partialColSum);
+ context.write(key, nValue);
}
}
@@ -115,6 +124,7 @@
/** Frobenius Norm Mapper */
public static class MatrixFrobeniusNormMapper extends
TableMapper<IntWritable, DoubleWritable> {
+ private DoubleWritable nValue = new DoubleWritable();
@Override
public void map(ImmutableBytesWritable key, Result value, Context context)
@@ -128,7 +138,8 @@
rowSqrtSum += (cellValue * cellValue);
}
- context.write(MatrixNormMapReduce.nKey, new DoubleWritable(rowSqrtSum));
+ nValue.set(rowSqrtSum);
+ context.write(MatrixNormMapReduce.nKey, nValue);
}
}
@@ -136,7 +147,8 @@
public static class MatrixFrobeniusNormCombiner extends
Reducer<IntWritable, DoubleWritable, IntWritable, DoubleWritable> {
private double sqrtSum = 0;
-
+ private DoubleWritable nValue = new DoubleWritable();
+
@Override
public void reduce(IntWritable key, Iterable<DoubleWritable> values,
Context context) throws IOException, InterruptedException {
@@ -144,7 +156,8 @@
sqrtSum += val.get();
}
- context.write(MatrixNormMapReduce.nKey, new DoubleWritable(sqrtSum));
+ nValue.set(sqrtSum);
+ context.write(MatrixNormMapReduce.nKey, nValue);
}
}
@@ -168,7 +181,8 @@
/** MaxValue Norm Mapper * */
public static class MatrixMaxValueNormMapper extends
TableMapper<IntWritable, DoubleWritable> {
-
+ private DoubleWritable nValue = new DoubleWritable();
+
@Override
public void map(ImmutableBytesWritable key, Result value, Context context)
throws IOException, InterruptedException {
@@ -181,7 +195,8 @@
max = cellValue > max ? cellValue : max;
}
- context.write(MatrixNormMapReduce.nKey, new DoubleWritable(max));
+ nValue.set(max);
+ context.write(MatrixNormMapReduce.nKey, nValue);
}
}
@@ -189,7 +204,8 @@
public static class MatrixMaxValueNormReducer extends
Reducer<IntWritable, DoubleWritable, IntWritable, DoubleWritable> {
private double max = 0;
-
+ private DoubleWritable nValue = new DoubleWritable();
+
@Override
public void reduce(IntWritable key, Iterable<DoubleWritable> values,
Context context) throws IOException, InterruptedException {
@@ -197,7 +213,8 @@
max = Math.max(val.get(), max);
}
- context.write(MatrixNormMapReduce.nKey, new DoubleWritable(max));
+ nValue.set(max);
+ context.write(MatrixNormMapReduce.nKey, nValue);
}
}
}
Modified: incubator/hama/trunk/src/test/org/apache/hama/matrix/TestAbstractMatrix.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/test/org/apache/hama/matrix/TestAbstractMatrix.java?rev=831245&r1=831244&r2=831245&view=diff
==============================================================================
--- incubator/hama/trunk/src/test/org/apache/hama/matrix/TestAbstractMatrix.java (original)
+++ incubator/hama/trunk/src/test/org/apache/hama/matrix/TestAbstractMatrix.java Fri Oct 30 09:52:06 2009
@@ -48,7 +48,6 @@
}
public void normTest(Matrix matrix) throws IOException {
-
double norm1 = matrix.norm(Norm.One);
double verify_norm1 = MatrixTestCommon.verifyNorm1(matrix);
gap = norm1 - verify_norm1;
Modified: incubator/hama/trunk/src/test/org/apache/hama/matrix/TestSingularValueDecomposition.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/test/org/apache/hama/matrix/TestSingularValueDecomposition.java?rev=831245&r1=831244&r2=831245&view=diff
==============================================================================
--- incubator/hama/trunk/src/test/org/apache/hama/matrix/TestSingularValueDecomposition.java (original)
+++ incubator/hama/trunk/src/test/org/apache/hama/matrix/TestSingularValueDecomposition.java Fri Oct 30 09:52:06 2009
@@ -84,8 +84,7 @@
Result r = table.get(get);
double eigenvalue = BytesUtil.bytesToDouble(r.getValue(Bytes
- .toBytes(Constants.EI), Bytes
- .toBytes(Constants.EIVAL)));
+ .toBytes(Constants.EI), Bytes.toBytes(Constants.EIVAL)));
assertTrue(Math.abs(eigenvalues[x] - eigenvalue) < .0000001);
assertTrue(Math.abs(Math.pow(eigenvalue, 0.5) - singularvalues[x]) < .0000001);
}
Modified: incubator/hama/trunk/src/test/org/apache/hama/util/TestNumeric.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/test/org/apache/hama/util/TestNumeric.java?rev=831245&r1=831244&r2=831245&view=diff
==============================================================================
--- incubator/hama/trunk/src/test/org/apache/hama/util/TestNumeric.java (original)
+++ incubator/hama/trunk/src/test/org/apache/hama/util/TestNumeric.java Fri Oct 30 09:52:06 2009
@@ -21,9 +21,6 @@
import junit.framework.TestCase;
-import org.apache.hadoop.hbase.util.Bytes;
-import org.apache.hama.Constants;
-
public class TestNumeric extends TestCase {
final static int TEST_INT = 3;
final static double TEST_DOUBLE = 0.4;