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 2008/08/25 09:57:55 UTC
svn commit: r688643 - in /incubator/hama/trunk/src:
docs/src/documentation/content/xdocs/ examples/org/apache/hama/examples/
java/org/apache/hama/ java/org/apache/hama/algebra/
java/org/apache/hama/io/ java/org/apache/hama/mapred/
test/org/apache/hama/...
Author: edwardyoon
Date: Mon Aug 25 00:57:54 2008
New Revision: 688643
URL: http://svn.apache.org/viewvc?rev=688643&view=rev
Log:
Color Logo.
Added:
incubator/hama/trunk/src/java/org/apache/hama/DenseMatrix.java
incubator/hama/trunk/src/java/org/apache/hama/DenseVector.java
incubator/hama/trunk/src/java/org/apache/hama/mapred/DenseMap.java
Modified:
incubator/hama/trunk/src/docs/src/documentation/content/xdocs/index.xml
incubator/hama/trunk/src/docs/src/documentation/content/xdocs/who_we_are.xml
incubator/hama/trunk/src/examples/org/apache/hama/examples/MatrixAddition.java
incubator/hama/trunk/src/java/org/apache/hama/AbstractMatrix.java
incubator/hama/trunk/src/java/org/apache/hama/Matrix.java
incubator/hama/trunk/src/java/org/apache/hama/MatrixInterface.java
incubator/hama/trunk/src/java/org/apache/hama/Vector.java
incubator/hama/trunk/src/java/org/apache/hama/VectorInterface.java
incubator/hama/trunk/src/java/org/apache/hama/algebra/AdditionMap.java
incubator/hama/trunk/src/java/org/apache/hama/algebra/AdditionReduce.java
incubator/hama/trunk/src/java/org/apache/hama/io/VectorWritable.java
incubator/hama/trunk/src/java/org/apache/hama/mapred/MatrixInputFormatBase.java
incubator/hama/trunk/src/java/org/apache/hama/mapred/MatrixMap.java
incubator/hama/trunk/src/test/org/apache/hama/TestMatrix.java
incubator/hama/trunk/src/test/org/apache/hama/TestVector.java
incubator/hama/trunk/src/test/org/apache/hama/mapred/TestMatrixMapReduce.java
Modified: incubator/hama/trunk/src/docs/src/documentation/content/xdocs/index.xml
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/docs/src/documentation/content/xdocs/index.xml?rev=688643&r1=688642&r2=688643&view=diff
==============================================================================
--- incubator/hama/trunk/src/docs/src/documentation/content/xdocs/index.xml (original)
+++ incubator/hama/trunk/src/docs/src/documentation/content/xdocs/index.xml Mon Aug 25 00:57:54 2008
@@ -28,7 +28,7 @@
<section>
<title> Introduction </title>
<table class="NonBorderTable">
- <tr><td><img src="./images/hama_logo.png" alt="Hama Logo" /></td>
+ <tr><td><img src="./images/hama_paint_logo.png" alt="Hama Logo" /></td>
<td><strong>Hama</strong> (means a hippopotamus in Korean) is a
parallel matrix computational package,
which provides an library of matrix operations for the large-scale
Modified: incubator/hama/trunk/src/docs/src/documentation/content/xdocs/who_we_are.xml
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/docs/src/documentation/content/xdocs/who_we_are.xml?rev=688643&r1=688642&r2=688643&view=diff
==============================================================================
--- incubator/hama/trunk/src/docs/src/documentation/content/xdocs/who_we_are.xml (original)
+++ incubator/hama/trunk/src/docs/src/documentation/content/xdocs/who_we_are.xml Mon Aug 25 00:57:54 2008
@@ -114,7 +114,8 @@
<title>Contributors</title>
<p>Contributors are:</p>
<ul>
- <li>Su-kyung Kim, a contributor of Hama logos artwork.</li>
+ <li>Su-kyung Kim, a contributor of Hama logo sketch.</li>
+ <li>Morakot, a contributor of Hama logo paint.</li>
</ul>
</section>
Modified: incubator/hama/trunk/src/examples/org/apache/hama/examples/MatrixAddition.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/examples/org/apache/hama/examples/MatrixAddition.java?rev=688643&r1=688642&r2=688643&view=diff
==============================================================================
--- incubator/hama/trunk/src/examples/org/apache/hama/examples/MatrixAddition.java (original)
+++ incubator/hama/trunk/src/examples/org/apache/hama/examples/MatrixAddition.java Mon Aug 25 00:57:54 2008
@@ -19,6 +19,7 @@
*/
package org.apache.hama.examples;
+import org.apache.hama.DenseMatrix;
import org.apache.hama.HamaConfiguration;
import org.apache.hama.Matrix;
@@ -35,8 +36,8 @@
HamaConfiguration conf = new HamaConfiguration();
- Matrix a = Matrix.random(conf, row, column);
- Matrix b = Matrix.random(conf, row, column);
+ Matrix a = DenseMatrix.random(conf, row, column);
+ Matrix b = DenseMatrix.random(conf, row, column);
Matrix c = a.add(b);
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=688643&r1=688642&r2=688643&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/AbstractMatrix.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/AbstractMatrix.java Mon Aug 25 00:57:54 2008
@@ -36,7 +36,7 @@
/**
* Methods of the matrix classes
*/
-public abstract class AbstractMatrix implements MatrixInterface {
+public abstract class AbstractMatrix implements Matrix {
static final Logger LOG = Logger.getLogger(AbstractMatrix.class);
/** Hama Configuration */
@@ -94,25 +94,6 @@
}
/** {@inheritDoc} */
- public Vector getRow(int row) {
- try {
- return new Vector(row, table.getRow(String.valueOf(row)));
- } catch (IOException e) {
- LOG.error(e, e);
- }
- return null;
- }
-
- public Vector getRow(byte[] row) {
- try {
- return new Vector(Numeric.bytesToInt(row), table.getRow(row));
- } catch (IOException e) {
- LOG.error(e, e);
- }
- return null;
- }
-
- /** {@inheritDoc} */
public int getRows() {
Cell rows = null;
try {
Added: 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=688643&view=auto
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/DenseMatrix.java (added)
+++ incubator/hama/trunk/src/java/org/apache/hama/DenseMatrix.java Mon Aug 25 00:57:54 2008
@@ -0,0 +1,185 @@
+/**
+ * Copyright 2007 The Apache Software Foundation
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hama;
+
+import java.io.IOException;
+
+import org.apache.hadoop.hbase.HColumnDescriptor;
+import org.apache.hadoop.hbase.HTableDescriptor;
+import org.apache.hadoop.hbase.client.HTable;
+import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
+import org.apache.hadoop.mapred.JobClient;
+import org.apache.hadoop.mapred.JobConf;
+import org.apache.hama.algebra.AdditionMap;
+import org.apache.hama.algebra.AdditionReduce;
+import org.apache.hama.mapred.DenseMap;
+import org.apache.hama.mapred.MatrixReduce;
+import org.apache.hama.util.RandomVariable;
+
+public class DenseMatrix extends AbstractMatrix implements Matrix {
+
+ /**
+ * Construct
+ *
+ * @param conf configuration object
+ */
+ public DenseMatrix(HamaConfiguration conf) {
+ setConfiguration(conf);
+ }
+
+ /**
+ * Construct an matrix
+ *
+ * @param conf configuration object
+ * @param matrixName the name of the matrix
+ */
+ public DenseMatrix(HamaConfiguration conf, String matrixName) {
+ try {
+ setConfiguration(conf);
+ this.matrixName = matrixName;
+
+ if (!admin.tableExists(matrixName)) {
+ tableDesc = new HTableDescriptor(matrixName.toString());
+ tableDesc.addFamily(new HColumnDescriptor(Constants.COLUMN.toString()));
+ create();
+ }
+
+ table = new HTable(config, matrixName);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Construct an m-by-n constant matrix.
+ *
+ * @param conf configuration object
+ * @param m the number of rows.
+ * @param n the number of columns.
+ * @param s fill the matrix with this scalar value.
+ */
+ public DenseMatrix(HamaConfiguration conf, int m, int n, double s) {
+ try {
+ setConfiguration(conf);
+ matrixName = RandomVariable.randMatrixName();
+
+ if (!admin.tableExists(matrixName)) {
+ tableDesc = new HTableDescriptor(matrixName.toString());
+ tableDesc.addFamily(new HColumnDescriptor(Constants.COLUMN.toString()));
+ create();
+ }
+
+ table = new HTable(config, matrixName);
+
+ for (int i = 0; i < m; i++) {
+ for (int j = 0; j < n; j++) {
+ set(i, j, s);
+ }
+ }
+
+ setDimension(m, n);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Generate matrix with random elements
+ *
+ * @param conf configuration object
+ * @param m the number of rows.
+ * @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) {
+ String name = RandomVariable.randMatrixName();
+ Matrix rand = new DenseMatrix(conf, name);
+ for (int i = 0; i < m; i++) {
+ for (int j = 0; j < n; j++) {
+ rand.set(i, j, RandomVariable.rand());
+ }
+ }
+
+ rand.setDimension(m, n);
+ LOG.info("Create the " + m + " * " + n + " random matrix : " + name);
+ return rand;
+ }
+
+ public Matrix add(Matrix B) {
+ String output = RandomVariable.randMatrixName();
+ Matrix C = new DenseMatrix(config, output);
+
+ JobConf jobConf = new JobConf(config);
+ jobConf.setJobName("addition MR job");
+
+ DenseMap.initJob(this.getName(), B.getName(), AdditionMap.class,
+ ImmutableBytesWritable.class, DenseVector.class, jobConf);
+ MatrixReduce.initJob(C.getName(), AdditionReduce.class, jobConf);
+
+ try {
+ JobClient.runJob(jobConf);
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ return C;
+ }
+
+ public Matrix add(double alpha, Matrix B) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public DenseVector getRow(int row) {
+ try {
+ return new DenseVector(row, table.getRow(String.valueOf(row)));
+ } catch (IOException e) {
+ LOG.error(e, e);
+ }
+ return null;
+ }
+
+ public Matrix mult(Matrix B) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Matrix multAdd(double alpha, Matrix B, Matrix C) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public double norm(Norm type) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public Matrix set(double alpha, Matrix B) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Matrix set(Matrix B) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
Added: incubator/hama/trunk/src/java/org/apache/hama/DenseVector.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/java/org/apache/hama/DenseVector.java?rev=688643&view=auto
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/DenseVector.java (added)
+++ incubator/hama/trunk/src/java/org/apache/hama/DenseVector.java Mon Aug 25 00:57:54 2008
@@ -0,0 +1,154 @@
+package org.apache.hama;
+
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.hadoop.hbase.io.Cell;
+import org.apache.hadoop.hbase.io.HbaseMapWritable;
+import org.apache.hadoop.hbase.io.RowResult;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hama.io.VectorWritable;
+import org.apache.hama.util.Numeric;
+import org.apache.log4j.Logger;
+
+public class DenseVector extends VectorWritable implements Vector {
+ static final Logger LOG = Logger.getLogger(Vector.class);
+
+ public DenseVector() {
+ this(null, new HbaseMapWritable<byte[], Cell>());
+ }
+
+ public DenseVector(final byte[] row, final HbaseMapWritable<byte[], Cell> m) {
+ this.row = row;
+ this.cells = m;
+ }
+
+ public DenseVector(int row, RowResult rowResult) {
+ this.cells = new HbaseMapWritable<byte[], Cell>();
+ this.row = Numeric.intToBytes(row);
+ for (Map.Entry<byte[], Cell> f : rowResult.entrySet()) {
+ this.cells.put(f.getKey(), f.getValue());
+ }
+ }
+
+ /**
+ * Get the row for this Vector
+ */
+ public byte[] getRow() {
+ return row;
+ }
+
+ public HbaseMapWritable<byte[], Cell> getCells() {
+ return cells;
+ }
+
+ public void add(int index, double value) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public Vector add(double alpha, Vector v) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Vector add(Vector v2) {
+ HbaseMapWritable<byte[], Cell> trunk = new HbaseMapWritable<byte[], Cell>();
+ for (int i = 0; i < this.size(); i++) {
+ double value = (this.get(i) + v2.get(i));
+ Cell cValue = new Cell(String.valueOf(value), System.currentTimeMillis());
+ trunk.put(Bytes.toBytes("column:" + i), cValue);
+ }
+
+ return new DenseVector(row, trunk);
+ }
+
+ public double dot(Vector v) {
+ double cosine = 0.0;
+ double q_i, d_i;
+ for (int i = 0; i < Math.min(this.size(), v.size()); i++) {
+ q_i = v.get(i);
+ d_i = this.get(i);
+ cosine += q_i * d_i;
+ }
+ return cosine / (this.getNorm2() * ((DenseVector) v).getNorm2());
+ }
+
+ public Vector scale(double alpha) {
+ Set<byte[]> keySet = cells.keySet();
+ Iterator<byte[]> it = keySet.iterator();
+
+ while (it.hasNext()) {
+ byte[] key = it.next();
+ double oValue = Numeric.bytesToDouble(get(key).getValue());
+ double nValue = oValue * alpha;
+ Cell cValue = new Cell(String.valueOf(nValue), System.currentTimeMillis());
+ cells.put(key, cValue);
+ }
+
+ return this;
+ }
+
+ public double get(int index) {
+ return Numeric.bytesToDouble(cells.get(Numeric.getColumnIndex(index))
+ .getValue());
+ }
+
+ public double norm(Norm type) {
+ if (type == Norm.One)
+ return getNorm1();
+ else if (type == Norm.Two)
+ return getNorm2();
+ else if (type == Norm.TwoRobust)
+ return getNorm2Robust();
+ else
+ return getNormInf();
+ }
+
+ public void set(int index, double value) {
+ Cell cValue = new Cell(String.valueOf(value), System.currentTimeMillis());
+ cells.put(Numeric.getColumnIndex(index), cValue);
+ }
+
+ public DenseVector set(Vector v) {
+ return new DenseVector(((DenseVector) v).getRow(), ((DenseVector) v).getCells());
+ }
+
+ public double getNorm1() {
+ double sum = 0.0;
+
+ Set<byte[]> keySet = cells.keySet();
+ Iterator<byte[]> it = keySet.iterator();
+
+ while (it.hasNext()) {
+ sum += Numeric.bytesToDouble(get(it.next()).getValue());
+ }
+
+ return sum;
+ }
+
+ public double getNorm2() {
+ double square_sum = 0.0;
+
+ Set<byte[]> keySet = cells.keySet();
+ Iterator<byte[]> it = keySet.iterator();
+
+ while (it.hasNext()) {
+ double value = Numeric.bytesToDouble(get(it.next()).getValue());
+ square_sum += value * value;
+ }
+
+ return Math.sqrt(square_sum);
+ }
+
+ public double getNorm2Robust() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public double getNormInf() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+}
\ No newline at end of file
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=688643&r1=688642&r2=688643&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/Matrix.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/Matrix.java Mon Aug 25 00:57:54 2008
@@ -19,160 +19,140 @@
*/
package org.apache.hama;
-import java.io.IOException;
-
-import org.apache.hadoop.hbase.HColumnDescriptor;
-import org.apache.hadoop.hbase.HTableDescriptor;
-import org.apache.hadoop.hbase.client.HTable;
-import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
-import org.apache.hadoop.mapred.JobClient;
-import org.apache.hadoop.mapred.JobConf;
-import org.apache.hama.algebra.AdditionMap;
-import org.apache.hama.algebra.AdditionReduce;
-import org.apache.hama.mapred.MatrixMap;
-import org.apache.hama.mapred.MatrixReduce;
-import org.apache.hama.util.RandomVariable;
-
/**
- * A library for mathematical operations on matrices of double.
+ * Basic matrix interface.
*/
-public class Matrix extends AbstractMatrix {
+public interface Matrix {
+
+ /**
+ * Gets the double value of (i, j)
+ *
+ * @param i ith row of the matrix
+ * @param j jth column of the matrix
+ * @return the value of entry
+ */
+ public double get(int i, int j);
/**
- * Construct
+ * Gets the vector of row
*
- * @param conf configuration object
+ * @param row the row index of the matrix
+ * @return the feature vector of row
*/
- public Matrix(HamaConfiguration conf) {
- setConfiguration(conf);
- }
+ public Vector getRow(int row);
/**
- * Construct an matrix
+ * Get a number of row of the matrix from the meta-data column
*
- * @param conf configuration object
- * @param matrixName the name of the matrix
+ * @return a number of rows of the matrix
*/
- public Matrix(HamaConfiguration conf, String matrixName) {
- try {
- setConfiguration(conf);
- this.matrixName = matrixName;
-
- if (!admin.tableExists(matrixName)) {
- tableDesc = new HTableDescriptor(matrixName.toString());
- tableDesc.addFamily(new HColumnDescriptor(Constants.COLUMN.toString()));
- create();
- }
-
- table = new HTable(config, matrixName);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
+ public int getRows();
/**
- * Construct an m-by-n constant matrix.
+ * Get a number of column of the matrix from the meta-data column
*
- * @param conf configuration object
- * @param m the number of rows.
- * @param n the number of columns.
- * @param s fill the matrix with this scalar value.
- */
- public Matrix(HamaConfiguration conf, int m, int n, double s) {
- try {
- setConfiguration(conf);
- matrixName = RandomVariable.randMatrixName();
-
- if (!admin.tableExists(matrixName)) {
- tableDesc = new HTableDescriptor(matrixName.toString());
- tableDesc.addFamily(new HColumnDescriptor(Constants.COLUMN.toString()));
- create();
- }
-
- table = new HTable(config, matrixName);
-
- for (int i = 0; i < m; i++) {
- for (int j = 0; j < n; j++) {
- set(i, j, s);
- }
- }
-
- setDimension(m, n);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
+ * @return a number of columns of the matrix
+ */
+ public int getColumns();
/**
- * Generate matrix with random elements
+ * Sets the double value of (i, j)
*
- * @param conf configuration object
- * @param m the number of rows.
- * @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) {
- String name = RandomVariable.randMatrixName();
- Matrix rand = new Matrix(conf, name);
- for (int i = 0; i < m; i++) {
- for (int j = 0; j < n; j++) {
- rand.set(i, j, RandomVariable.rand());
- }
- }
-
- rand.setDimension(m, n);
- LOG.info("Create the " + m + " * " + n + " random matrix : " + name);
- return rand;
- }
+ * @param i ith row of the matrix
+ * @param j jth column of the matrix
+ * @param value the value of entry
+ */
+ public void set(int i, int j, double value);
- public Matrix add(Matrix B) {
- String output = RandomVariable.randMatrixName();
- Matrix C = new Matrix(config, output);
-
- JobConf jobConf = new JobConf(config);
- jobConf.setJobName("addition MR job");
-
- MatrixMap.initJob(this.getName(), B.getName(), AdditionMap.class,
- ImmutableBytesWritable.class, Vector.class, jobConf);
- MatrixReduce.initJob(C.getName(), AdditionReduce.class, jobConf);
-
- try {
- JobClient.runJob(jobConf);
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
+ /**
+ * A=alpha*B
+ *
+ * @param alpha
+ * @param B
+ * @return A
+ */
+ public Matrix set(double alpha, Matrix B);
- return C;
- }
+ /**
+ * A=B
+ *
+ * @param B
+ * @return A
+ */
+ public Matrix set(Matrix B);
- public Matrix add(double alpha, Matrix B) {
- // TODO Auto-generated method stub
- return null;
- }
+ /**
+ * Sets the dimension of matrix
+ *
+ * @param rows the number of rows
+ * @param columns the number of columns
+ */
+ public void setDimension(int rows, int columns);
- public Matrix mult(Matrix B) {
- // TODO Auto-generated method stub
- return null;
- }
+ /**
+ * A(i, j) += value
+ *
+ * @param i
+ * @param j
+ * @param value
+ */
+ public void add(int i, int j, double value);
- public Matrix multAdd(double alpha, Matrix B, Matrix C) {
- // TODO Auto-generated method stub
- return null;
- }
+ /**
+ * A = B + A
+ *
+ * @param B
+ * @return A
+ */
+ public Matrix add(Matrix B);
- public double norm(Norm type) {
- // TODO Auto-generated method stub
- return 0;
- }
+ /**
+ * A = alpha*B + A
+ *
+ * @param alpha
+ * @param B
+ * @return A
+ */
+ public Matrix add(double alpha, Matrix B);
- public Matrix set(double alpha, Matrix B) {
- // TODO Auto-generated method stub
- return null;
- }
+ /**
+ * C = A*B
+ *
+ * @param B
+ * @return C
+ */
+ public Matrix mult(Matrix B);
+
+ /**
+ * C = alpha*A*B + C
+ *
+ * @param alpha
+ * @param B
+ * @param C
+ * @return C
+ */
+ public Matrix multAdd(double alpha, Matrix B, Matrix C);
+
+ /**
+ * Computes the given norm of the matrix
+ *
+ * @param type
+ * @return norm of the matrix
+ */
+ public double norm(Norm type);
- public Matrix set(Matrix B) {
- // TODO Auto-generated method stub
- return null;
+ /**
+ * Supported matrix-norms.
+ */
+ enum Norm {
+ /** Largest entry in absolute value */
+ Infinity
}
+
+ /**
+ * Return the matrix name
+ *
+ * @return the name of the matrix
+ */
+ public String getName();
}
Modified: incubator/hama/trunk/src/java/org/apache/hama/MatrixInterface.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/java/org/apache/hama/MatrixInterface.java?rev=688643&r1=688642&r2=688643&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/MatrixInterface.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/MatrixInterface.java Mon Aug 25 00:57:54 2008
@@ -19,9 +19,7 @@
*/
package org.apache.hama;
-/**
- * Basic matrix interface.
- */
+@Deprecated
public interface MatrixInterface {
/**
Modified: incubator/hama/trunk/src/java/org/apache/hama/Vector.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/java/org/apache/hama/Vector.java?rev=688643&r1=688642&r2=688643&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/Vector.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/Vector.java Mon Aug 25 00:57:54 2008
@@ -19,155 +19,110 @@
*/
package org.apache.hama;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.hadoop.hbase.io.Cell;
-import org.apache.hadoop.hbase.io.HbaseMapWritable;
-import org.apache.hadoop.hbase.io.RowResult;
-import org.apache.hadoop.hbase.util.Bytes;
-import org.apache.hama.io.VectorWritable;
-import org.apache.hama.util.Numeric;
-import org.apache.log4j.Logger;
-
-public class Vector extends VectorWritable implements VectorInterface {
- static final Logger LOG = Logger.getLogger(Vector.class);
-
- public Vector() {
- this(null, new HbaseMapWritable<byte[], Cell>());
- }
-
- public Vector(final byte[] row, final HbaseMapWritable<byte[], Cell> m) {
- this.row = row;
- this.cells = m;
- }
-
- public Vector(int row, RowResult rowResult) {
- this.cells = new HbaseMapWritable<byte[], Cell>();
- this.row = Numeric.intToBytes(row);
- for (Map.Entry<byte[], Cell> f : rowResult.entrySet()) {
- this.cells.put(f.getKey(), f.getValue());
- }
- }
+/**
+ * Basic vector interface.
+ */
+public interface Vector {
/**
- * Get the row for this Vector
+ * Size of the vector
+ *
+ * @return size of the vector
*/
- public byte[] getRow() {
- return row;
- }
-
- public HbaseMapWritable<byte[], Cell> getCells() {
- return cells;
- }
-
- public void add(int index, double value) {
- // TODO Auto-generated method stub
-
- }
-
- public Vector add(double alpha, Vector v) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public Vector add(Vector v2) {
- HbaseMapWritable<byte[], Cell> trunk = new HbaseMapWritable<byte[], Cell>();
- for (int i = 0; i < this.size(); i++) {
- double value = (this.get(i) + v2.get(i));
- Cell cValue = new Cell(String.valueOf(value), System.currentTimeMillis());
- trunk.put(Bytes.toBytes("column:" + i), cValue);
- }
-
- return new Vector(row, trunk);
- }
-
- public double dot(Vector v) {
- double cosine = 0.0;
- double q_i, d_i;
- for (int i = 0; i < Math.min(this.size(), v.size()); i++) {
- q_i = v.get(i);
- d_i = this.get(i);
- cosine += q_i * d_i;
- }
- return cosine / (this.getNorm2() * v.getNorm2());
- }
-
- public Vector scale(double alpha) {
- Set<byte[]> keySet = cells.keySet();
- Iterator<byte[]> it = keySet.iterator();
-
- while (it.hasNext()) {
- byte[] key = it.next();
- double oValue = Numeric.bytesToDouble(get(key).getValue());
- double nValue = oValue * alpha;
- Cell cValue = new Cell(String.valueOf(nValue), System.currentTimeMillis());
- cells.put(key, cValue);
- }
-
- return this;
- }
-
- public double get(int index) {
- return Numeric.bytesToDouble(cells.get(Numeric.getColumnIndex(index))
- .getValue());
- }
+ public int size();
- public double norm(Norm type) {
- if (type == Norm.One)
- return getNorm1();
- else if (type == Norm.Two)
- return getNorm2();
- else if (type == Norm.TwoRobust)
- return getNorm2Robust();
- else
- return getNormInf();
- }
+ /**
+ * Gets the value of index
+ *
+ * @param index
+ * @return v(index)
+ */
+ public double get(int index);
- public void set(int index, double value) {
- Cell cValue = new Cell(String.valueOf(value), System.currentTimeMillis());
- cells.put(Numeric.getColumnIndex(index), cValue);
- }
+ /**
+ * Sets the value of index
+ *
+ * @param index
+ * @param value
+ */
+ public void set(int index, double value);
- public Vector set(Vector v) {
- return new Vector(v.getRow(), v.getCells());
- }
+ /**
+ * Sets the vector
+ *
+ * @param v
+ * @return x = v
+ */
+ public Vector set(Vector v);
- public double getNorm1() {
- double sum = 0.0;
+ /**
+ * Adds the value to v(index)
+ *
+ * @param index
+ * @param value
+ */
+ public void add(int index, double value);
- Set<byte[]> keySet = cells.keySet();
- Iterator<byte[]> it = keySet.iterator();
+ /**
+ * x = alpha*v + x
+ *
+ * @param alpha
+ * @param v
+ * @return x = alpha*v + x
+ */
+ public Vector add(double alpha, Vector v);
- while (it.hasNext()) {
- sum += Numeric.bytesToDouble(get(it.next()).getValue());
- }
+ /**
+ * x = v + x
+ *
+ * @param v
+ * @return x = v + x
+ */
+ public Vector add(Vector v);
- return sum;
- }
+ /**
+ * x dot v
+ *
+ * @param v
+ * @return x dot v
+ */
+ public double dot(Vector v);
- public double getNorm2() {
- double square_sum = 0.0;
+ /**
+ * v = alpha*v
+ *
+ * @param alpha
+ * @return v = alpha*v
+ */
+ public Vector scale(double alpha);
+
+
+ /**
+ * Computes the given norm of the vector
+ *
+ * @param type
+ * @return norm of the vector
+ */
+ public double norm(Norm type);
- Set<byte[]> keySet = cells.keySet();
- Iterator<byte[]> it = keySet.iterator();
+ /**
+ * Supported vector-norms.
+ */
+ enum Norm {
- while (it.hasNext()) {
- double value = Numeric.bytesToDouble(get(it.next()).getValue());
- square_sum += value * value;
- }
+ /** Sum of the absolute values of the entries */
+ One,
- return Math.sqrt(square_sum);
- }
+ /** The root of sum of squares */
+ Two,
- public double getNorm2Robust() {
- // TODO Auto-generated method stub
- return 0;
- }
+ /**
+ * As the 2 norm may overflow, an overflow resistant version is also
+ * available. Note that it may be slower.
+ */
+ TwoRobust,
- public double getNormInf() {
- // TODO Auto-generated method stub
- return 0;
+ /** Largest entry in absolute value */
+ Infinity
}
}
Modified: incubator/hama/trunk/src/java/org/apache/hama/VectorInterface.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/java/org/apache/hama/VectorInterface.java?rev=688643&r1=688642&r2=688643&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/VectorInterface.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/VectorInterface.java Mon Aug 25 00:57:54 2008
@@ -19,9 +19,7 @@
*/
package org.apache.hama;
-/**
- * Basic vector interface.
- */
+@Deprecated
public interface VectorInterface {
/**
Modified: incubator/hama/trunk/src/java/org/apache/hama/algebra/AdditionMap.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/java/org/apache/hama/algebra/AdditionMap.java?rev=688643&r1=688642&r2=688643&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/algebra/AdditionMap.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/algebra/AdditionMap.java Mon Aug 25 00:57:54 2008
@@ -24,18 +24,20 @@
import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
import org.apache.hadoop.mapred.OutputCollector;
import org.apache.hadoop.mapred.Reporter;
+import org.apache.hama.DenseVector;
import org.apache.hama.Vector;
-import org.apache.hama.mapred.MatrixMap;
+import org.apache.hama.mapred.DenseMap;
+import org.apache.hama.util.Numeric;
-public class AdditionMap extends MatrixMap<ImmutableBytesWritable, Vector> {
+public class AdditionMap extends DenseMap<ImmutableBytesWritable, DenseVector> {
+ @Override
public void map(ImmutableBytesWritable key, Vector value,
- OutputCollector<ImmutableBytesWritable, Vector> output,
+ OutputCollector<ImmutableBytesWritable, DenseVector> output,
Reporter reporter) throws IOException {
-
- Vector v1 = B.getRow(key.get());
- output.collect(key, v1.add(value));
-
- }
+ Vector v1 = MATRIX_B.getRow(Numeric.bytesToInt(key.get()));
+ output.collect(key, (DenseVector) v1.add(value));
+
+ }
}
Modified: incubator/hama/trunk/src/java/org/apache/hama/algebra/AdditionReduce.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/java/org/apache/hama/algebra/AdditionReduce.java?rev=688643&r1=688642&r2=688643&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/algebra/AdditionReduce.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/algebra/AdditionReduce.java Mon Aug 25 00:57:54 2008
@@ -28,19 +28,19 @@
import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
import org.apache.hadoop.mapred.OutputCollector;
import org.apache.hadoop.mapred.Reporter;
-import org.apache.hama.Vector;
+import org.apache.hama.DenseVector;
import org.apache.hama.mapred.MatrixReduce;
public class AdditionReduce extends
- MatrixReduce<ImmutableBytesWritable, Vector> {
+ MatrixReduce<ImmutableBytesWritable, DenseVector> {
@Override
- public void reduce(ImmutableBytesWritable key, Iterator<Vector> values,
+ public void reduce(ImmutableBytesWritable key, Iterator<DenseVector> values,
OutputCollector<ImmutableBytesWritable, BatchUpdate> output,
Reporter reporter) throws IOException {
BatchUpdate b = new BatchUpdate(key.get());
- Vector vector = values.next();
+ DenseVector vector = values.next();
for (Map.Entry<byte[], Cell> f : vector.entrySet()) {
b.put(f.getKey(), f.getValue().getValue());
}
Modified: incubator/hama/trunk/src/java/org/apache/hama/io/VectorWritable.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/java/org/apache/hama/io/VectorWritable.java?rev=688643&r1=688642&r2=688643&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/io/VectorWritable.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/io/VectorWritable.java Mon Aug 25 00:57:54 2008
@@ -196,5 +196,4 @@
}
}
-
}
Added: incubator/hama/trunk/src/java/org/apache/hama/mapred/DenseMap.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/java/org/apache/hama/mapred/DenseMap.java?rev=688643&view=auto
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/mapred/DenseMap.java (added)
+++ incubator/hama/trunk/src/java/org/apache/hama/mapred/DenseMap.java Mon Aug 25 00:57:54 2008
@@ -0,0 +1,43 @@
+package org.apache.hama.mapred;
+
+import java.io.IOException;
+
+import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
+import org.apache.hadoop.io.Writable;
+import org.apache.hadoop.io.WritableComparable;
+import org.apache.hadoop.mapred.FileInputFormat;
+import org.apache.hadoop.mapred.JobConf;
+import org.apache.hadoop.mapred.MapReduceBase;
+import org.apache.hadoop.mapred.Mapper;
+import org.apache.hadoop.mapred.OutputCollector;
+import org.apache.hadoop.mapred.Reporter;
+import org.apache.hama.Constants;
+import org.apache.hama.DenseMatrix;
+import org.apache.hama.HamaConfiguration;
+import org.apache.hama.Matrix;
+import org.apache.hama.Vector;
+
+@SuppressWarnings("unchecked")
+public abstract class DenseMap<K extends WritableComparable, V extends Writable>
+ extends MapReduceBase implements
+ Mapper<ImmutableBytesWritable, Vector, K, V> {
+ protected static Matrix MATRIX_B;
+
+ public static void initJob(String matrixA, String matrixB,
+ Class<? extends DenseMap> mapper,
+ Class<? extends WritableComparable> outputKeyClass,
+ Class<? extends Writable> outputValueClass, JobConf job) {
+
+ job.setInputFormat(MatrixInputFormat.class);
+ job.setMapOutputValueClass(outputValueClass);
+ job.setMapOutputKeyClass(outputKeyClass);
+ job.setMapperClass(mapper);
+ FileInputFormat.addInputPaths(job, matrixA);
+
+ MATRIX_B = new DenseMatrix(new HamaConfiguration(), matrixB);
+ job.set(MatrixInputFormat.COLUMN_LIST, Constants.COLUMN);
+ }
+
+ public abstract void map(ImmutableBytesWritable key, Vector value,
+ OutputCollector<K, V> output, Reporter reporter) throws IOException;
+}
Modified: incubator/hama/trunk/src/java/org/apache/hama/mapred/MatrixInputFormatBase.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/java/org/apache/hama/mapred/MatrixInputFormatBase.java?rev=688643&r1=688642&r2=688643&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/mapred/MatrixInputFormatBase.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/mapred/MatrixInputFormatBase.java Mon Aug 25 00:57:54 2008
@@ -22,11 +22,10 @@
import org.apache.hadoop.mapred.JobConf;
import org.apache.hadoop.mapred.RecordReader;
import org.apache.hadoop.mapred.Reporter;
-import org.apache.hama.Vector;
-import org.apache.hama.io.VectorWritable;
+import org.apache.hama.DenseVector;
public abstract class MatrixInputFormatBase implements
- InputFormat<ImmutableBytesWritable, Vector> {
+ InputFormat<ImmutableBytesWritable, DenseVector> {
private final Log LOG = LogFactory.getLog(MatrixInputFormatBase.class);
private byte[][] inputColumns;
private HTable table;
@@ -34,10 +33,10 @@
private RowFilterInterface rowFilter;
/**
- * Iterate over an HBase table data, return (Text, VectorResult) pairs
+ * Iterate over an HBase table data, return (Text, DenseVector) pairs
*/
protected class TableRecordReader implements
- RecordReader<ImmutableBytesWritable, Vector> {
+ RecordReader<ImmutableBytesWritable, DenseVector> {
private byte[] startRow;
private byte[] endRow;
private RowFilterInterface trrRowFilter;
@@ -77,7 +76,7 @@
}
/**
- * @param inputColumns the columns to be placed in {@link VectorWritable}.
+ * @param inputColumns the columns to be placed in {@link DenseVector}.
*/
public void setInputColumns(final byte[][] inputColumns) {
this.trrInputColumns = inputColumns;
@@ -120,12 +119,12 @@
}
/**
- * @return VectorResult
+ * @return DenseVector
*
* @see org.apache.hadoop.mapred.RecordReader#createValue()
*/
- public Vector createValue() {
- return new Vector();
+ public DenseVector createValue() {
+ return new DenseVector();
}
/** {@inheritDoc} */
@@ -145,13 +144,13 @@
* @param key HStoreKey as input key.
* @param value MapWritable as input value
*
- * Converts Scanner.next() to Text, VectorResult
+ * Converts Scanner.next() to Text, DenseVector
*
* @return true if there was more data
* @throws IOException
*/
@SuppressWarnings("unchecked")
- public boolean next(ImmutableBytesWritable key, Vector value)
+ public boolean next(ImmutableBytesWritable key, DenseVector value)
throws IOException {
RowResult result = this.scanner.next();
boolean hasMore = result != null && result.size() > 0;
@@ -170,7 +169,7 @@
* @see org.apache.hadoop.mapred.InputFormat#getRecordReader(InputSplit,
* JobConf, Reporter)
*/
- public RecordReader<ImmutableBytesWritable, Vector> getRecordReader(
+ public RecordReader<ImmutableBytesWritable, DenseVector> getRecordReader(
InputSplit split, @SuppressWarnings("unused") JobConf job,
@SuppressWarnings("unused") Reporter reporter) throws IOException {
TableSplit tSplit = (TableSplit) split;
@@ -238,7 +237,7 @@
}
/**
- * @param inputColumns to be passed in {@link VectorWritable} to the map task.
+ * @param inputColumns to be passed in {@link DenseVector} to the map task.
*/
protected void setInputColums(byte[][] inputColumns) {
this.inputColumns = inputColumns;
Modified: incubator/hama/trunk/src/java/org/apache/hama/mapred/MatrixMap.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/java/org/apache/hama/mapred/MatrixMap.java?rev=688643&r1=688642&r2=688643&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/mapred/MatrixMap.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/mapred/MatrixMap.java Mon Aug 25 00:57:54 2008
@@ -31,18 +31,19 @@
import org.apache.hadoop.mapred.OutputCollector;
import org.apache.hadoop.mapred.Reporter;
import org.apache.hama.Constants;
+import org.apache.hama.DenseMatrix;
import org.apache.hama.HamaConfiguration;
import org.apache.hama.Matrix;
import org.apache.hama.Vector;
-@SuppressWarnings("unchecked")
+@Deprecated
public abstract class MatrixMap<K extends WritableComparable, V extends Writable>
extends MapReduceBase implements
Mapper<ImmutableBytesWritable, Vector, K, V> {
- protected static Matrix B;
+ protected static Matrix MATRIX_B;
public static void initJob(String matrixA, String matrixB,
- Class<? extends MatrixMap> mapper,
+ Class<? extends DenseMap> mapper,
Class<? extends WritableComparable> outputKeyClass,
Class<? extends Writable> outputValueClass, JobConf job) {
@@ -52,7 +53,7 @@
job.setMapperClass(mapper);
FileInputFormat.addInputPaths(job, matrixA);
- B = new Matrix(new HamaConfiguration(), matrixB);
+ MATRIX_B = new DenseMatrix(new HamaConfiguration(), matrixB);
job.set(MatrixInputFormat.COLUMN_LIST, Constants.COLUMN);
}
Modified: incubator/hama/trunk/src/test/org/apache/hama/TestMatrix.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/test/org/apache/hama/TestMatrix.java?rev=688643&r1=688642&r2=688643&view=diff
==============================================================================
--- incubator/hama/trunk/src/test/org/apache/hama/TestMatrix.java (original)
+++ incubator/hama/trunk/src/test/org/apache/hama/TestMatrix.java Mon Aug 25 00:57:54 2008
@@ -28,7 +28,7 @@
* Random matrix creation test
*/
public void testRandomMatrix() {
- Matrix rand = Matrix.random(conf, SIZE, SIZE);
+ Matrix rand = DenseMatrix.random(conf, SIZE, SIZE);
assertTrue(rand.getRows() == SIZE);
}
}
Modified: incubator/hama/trunk/src/test/org/apache/hama/TestVector.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/test/org/apache/hama/TestVector.java?rev=688643&r1=688642&r2=688643&view=diff
==============================================================================
--- incubator/hama/trunk/src/test/org/apache/hama/TestVector.java (original)
+++ incubator/hama/trunk/src/test/org/apache/hama/TestVector.java Mon Aug 25 00:57:54 2008
@@ -24,12 +24,13 @@
private final double norm1 = 12.0;
private final double norm2 = 6.782329983125268;
private double[][] values = { { 2, 5, 1, 4 }, { 4, 1, 3, 3 } };
+ private final String m = "dotTest";
/**
* Test vector
*/
public void testGetVector() {
- Matrix m1 = new Matrix(conf, "dotTest");
+ Matrix m1 = new DenseMatrix(conf, m);
for (int i = 0; i < 2; i++) {
for (int j = 0; j < 4; j++) {
@@ -58,11 +59,11 @@
}
private void norm1Test(Vector v1, Vector v2) {
- assertEquals(norm1, v1.getNorm1());
+ assertEquals(norm1, ((DenseVector) v1).getNorm1());
}
private void norm2Test(Vector v1, Vector v2) {
- assertEquals(norm2, v1.getNorm2());
+ assertEquals(norm2, ((DenseVector) v1).getNorm2());
}
private void scalingTest(Vector v2) {
@@ -74,7 +75,7 @@
}
public void testGetSet() {
- Vector v1 = new Vector();
+ Vector v1 = new DenseVector();
v1.set(0, 0.2);
assertEquals(v1.get(0), 0.2);
}
Modified: incubator/hama/trunk/src/test/org/apache/hama/mapred/TestMatrixMapReduce.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/test/org/apache/hama/mapred/TestMatrixMapReduce.java?rev=688643&r1=688642&r2=688643&view=diff
==============================================================================
--- incubator/hama/trunk/src/test/org/apache/hama/mapred/TestMatrixMapReduce.java (original)
+++ incubator/hama/trunk/src/test/org/apache/hama/mapred/TestMatrixMapReduce.java Mon Aug 25 00:57:54 2008
@@ -24,9 +24,10 @@
import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
import org.apache.hadoop.mapred.JobClient;
import org.apache.hadoop.mapred.JobConf;
+import org.apache.hama.DenseMatrix;
+import org.apache.hama.DenseVector;
import org.apache.hama.HamaTestCase;
import org.apache.hama.Matrix;
-import org.apache.hama.Vector;
import org.apache.hama.algebra.AdditionMap;
import org.apache.hama.algebra.AdditionReduce;
import org.apache.log4j.Logger;
@@ -46,11 +47,11 @@
}
public void testMatrixMapReduce() throws IOException {
- Matrix matrixA = new Matrix(conf, A);
+ Matrix matrixA = new DenseMatrix(conf, A);
matrixA.set(0, 0, 1);
matrixA.set(0, 1, 0);
- Matrix matrixB = new Matrix(conf, B);
+ Matrix matrixB = new DenseMatrix(conf, B);
matrixB.set(0, 0, 1);
matrixB.set(0, 1, 1);
@@ -58,13 +59,13 @@
}
public void miniMRJob() throws IOException {
- Matrix c = new Matrix(conf, output);
+ Matrix c = new DenseMatrix(conf, output);
JobConf jobConf = new JobConf(conf, TestMatrixMapReduce.class);
jobConf.setJobName("test MR job");
- MatrixMap.initJob(A, B, AdditionMap.class, ImmutableBytesWritable.class,
- Vector.class, jobConf);
+ DenseMap.initJob(A, B, AdditionMap.class, ImmutableBytesWritable.class,
+ DenseVector.class, jobConf);
MatrixReduce.initJob(output, AdditionReduce.class, jobConf);
jobConf.setNumMapTasks(1);