Author: edwardyoon
Date: Mon Aug 25 01:02:56 2008
New Revision: 688645
URL: http://svn.apache.org/viewvc?rev=688645&view=rev
Log: (empty)
Removed:
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/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
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=688645&r1=688644&r2=688645&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 01:02:56 2008
@@ -36,7 +36,7 @@
/**
* Methods of the matrix classes
*/
-public abstract class AbstractMatrix implements Matrix {
+public abstract class AbstractMatrix implements MatrixInterface {
static final Logger LOG = Logger.getLogger(AbstractMatrix.class);
/** Hama Configuration */
@@ -94,6 +94,25 @@
}
/** [EMAIL PROTECTED] */
+ 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;
+ }
+
+ /** [EMAIL PROTECTED] */
public int getRows() {
Cell rows = null;
try {
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=688645&r1=688644&r2=688645&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
01:02:56 2008
@@ -19,140 +19,160 @@
*/
package org.apache.hama;
-/**
- * Basic matrix interface.
- */
-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);
+import java.io.IOException;
- /**
- * Gets the vector of row
- *
- * @param row the row index of the matrix
- * @return the feature vector of row
- */
- public Vector getRow(int row);
-
- /**
- * Get a number of row of the matrix from the meta-data column
- *
- * @return a number of rows of the matrix
- */
- public int getRows();
+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;
- /**
- * Get a number of column of the matrix from the meta-data column
- *
- * @return a number of columns of the matrix
- */
- public int getColumns();
+/**
+ * A library for mathematical operations on matrices of double.
+ */
+public class Matrix extends AbstractMatrix {
/**
- * Sets the double value of (i, j)
+ * Construct
*
- * @param i ith row of the matrix
- * @param j jth column of the matrix
- * @param value the value of entry
+ * @param conf configuration object
*/
- public void set(int i, int j, double value);
+ public Matrix(HamaConfiguration conf) {
+ setConfiguration(conf);
+ }
/**
- * A=alpha*B
+ * Construct an matrix
*
- * @param alpha
- * @param B
- * @return A
+ * @param conf configuration object
+ * @param matrixName the name of the matrix
*/
- public Matrix set(double alpha, Matrix B);
+ 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();
+ }
+ }
/**
- * A=B
+ * Construct an m-by-n constant matrix.
*
- * @param B
- * @return A
- */
- public Matrix set(Matrix B);
+ * @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();
+ }
+ }
/**
- * Sets the dimension of matrix
+ * Generate matrix with random elements
*
- * @param rows the number of rows
- * @param columns the number of columns
- */
- public void setDimension(int rows, int columns);
+ * @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;
+ }
- /**
- * A(i, j) += value
- *
- * @param i
- * @param j
- * @param value
- */
- public void add(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 = B + A
- *
- * @param B
- * @return A
- */
- public Matrix add(Matrix B);
+ return C;
+ }
- /**
- * A = alpha*B + A
- *
- * @param alpha
- * @param B
- * @return A
- */
- public Matrix add(double alpha, Matrix B);
+ public Matrix add(double alpha, Matrix B) {
+ // TODO Auto-generated method stub
+ return null;
+ }
- /**
- * C = A*B
- *
- * @param B
- * @return C
- */
- public Matrix mult(Matrix B);
+ public Matrix mult(Matrix B) {
+ // TODO Auto-generated method stub
+ return null;
+ }
- /**
- * C = alpha*A*B + C
- *
- * @param alpha
- * @param B
- * @param C
- * @return C
- */
- public Matrix multAdd(double alpha, Matrix B, Matrix C);
+ public Matrix multAdd(double alpha, Matrix B, Matrix C) {
+ // TODO Auto-generated method stub
+ return null;
+ }
- /**
- * Computes the given norm of the matrix
- *
- * @param type
- * @return norm of the matrix
- */
- public double norm(Norm type);
+ public double norm(Norm type) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
- /**
- * Supported matrix-norms.
- */
- enum Norm {
- /** Largest entry in absolute value */
- Infinity
+ public Matrix set(double alpha, Matrix B) {
+ // TODO Auto-generated method stub
+ return null;
}
- /**
- * Return the matrix name
- *
- * @return the name of the matrix
- */
- public String getName();
+ public Matrix set(Matrix B) {
+ // TODO Auto-generated method stub
+ return null;
+ }
}
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=688645&r1=688644&r2=688645&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 01:02:56 2008
@@ -19,7 +19,9 @@
*/
package org.apache.hama;
[EMAIL PROTECTED]
+/**
+ * Basic matrix interface.
+ */
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=688645&r1=688644&r2=688645&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
01:02:56 2008
@@ -19,110 +19,155 @@
*/
package org.apache.hama;
-/**
- * Basic vector interface.
- */
-public interface Vector {
+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;
- /**
- * Size of the vector
- *
- * @return size of the vector
- */
- public int size();
+public class Vector extends VectorWritable implements VectorInterface {
+ static final Logger LOG = Logger.getLogger(Vector.class);
- /**
- * Gets the value of index
- *
- * @param index
- * @return v(index)
- */
- public double get(int index);
+ public Vector() {
+ this(null, new HbaseMapWritable<byte[], Cell>());
+ }
- /**
- * Sets the value of index
- *
- * @param index
- * @param value
- */
- public void set(int index, double value);
+ public Vector(final byte[] row, final HbaseMapWritable<byte[], Cell> m) {
+ this.row = row;
+ this.cells = m;
+ }
- /**
- * Sets the vector
- *
- * @param v
- * @return x = v
- */
- public Vector set(Vector v);
+ 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());
+ }
+ }
/**
- * Adds the value to v(index)
- *
- * @param index
- * @param value
+ * Get the row for this Vector
*/
- public void add(int index, double value);
+ public byte[] getRow() {
+ return row;
+ }
- /**
- * x = alpha*v + x
- *
- * @param alpha
- * @param v
- * @return x = alpha*v + x
- */
- public Vector add(double alpha, Vector v);
+ public HbaseMapWritable<byte[], Cell> getCells() {
+ return cells;
+ }
- /**
- * x = v + x
- *
- * @param v
- * @return x = v + x
- */
- public Vector add(Vector v);
+ public void add(int index, double value) {
+ // TODO Auto-generated method stub
- /**
- * x dot v
- *
- * @param v
- * @return x dot v
- */
- public double dot(Vector v);
+ }
- /**
- * 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);
+ public Vector add(double alpha, Vector v) {
+ // TODO Auto-generated method stub
+ return null;
+ }
- /**
- * Supported vector-norms.
- */
- enum Norm {
+ 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 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();
+ }
- /** Sum of the absolute values of the entries */
- One,
+ public void set(int index, double value) {
+ Cell cValue = new Cell(String.valueOf(value), System.currentTimeMillis());
+ cells.put(Numeric.getColumnIndex(index), cValue);
+ }
+
+ public Vector set(Vector v) {
+ return new Vector(v.getRow(), v.getCells());
+ }
+
+ public double getNorm1() {
+ double sum = 0.0;
- /** The root of sum of squares */
- Two,
+ Set<byte[]> keySet = cells.keySet();
+ Iterator<byte[]> it = keySet.iterator();
+
+ while (it.hasNext()) {
+ sum += Numeric.bytesToDouble(get(it.next()).getValue());
+ }
+
+ return sum;
+ }
- /**
- * As the 2 norm may overflow, an overflow resistant version is also
- * available. Note that it may be slower.
- */
- TwoRobust,
+ 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;
+ }
- /** Largest entry in absolute value */
- Infinity
+ public double getNormInf() {
+ // TODO Auto-generated method stub
+ return 0;
}
}
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=688645&r1=688644&r2=688645&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 01:02:56 2008
@@ -19,7 +19,9 @@
*/
package org.apache.hama;
[EMAIL PROTECTED]
+/**
+ * Basic vector interface.
+ */
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=688645&r1=688644&r2=688645&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 01:02:56 2008
@@ -24,20 +24,18 @@
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.DenseMap;
-import org.apache.hama.util.Numeric;
+import org.apache.hama.mapred.MatrixMap;
-public class AdditionMap extends DenseMap<ImmutableBytesWritable, DenseVector>
{
+public class AdditionMap extends MatrixMap<ImmutableBytesWritable, Vector> {
- @Override
public void map(ImmutableBytesWritable key, Vector value,
- OutputCollector<ImmutableBytesWritable, DenseVector> output,
+ OutputCollector<ImmutableBytesWritable, Vector> output,
Reporter reporter) throws IOException {
-
- Vector v1 = MATRIX_B.getRow(Numeric.bytesToInt(key.get()));
- output.collect(key, (DenseVector) v1.add(value));
-
+
+ Vector v1 = B.getRow(key.get());
+ output.collect(key, 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=688645&r1=688644&r2=688645&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 01:02:56 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.DenseVector;
+import org.apache.hama.Vector;
import org.apache.hama.mapred.MatrixReduce;
public class AdditionReduce extends
- MatrixReduce<ImmutableBytesWritable, DenseVector> {
+ MatrixReduce<ImmutableBytesWritable, Vector> {
@Override
- public void reduce(ImmutableBytesWritable key, Iterator<DenseVector> values,
+ public void reduce(ImmutableBytesWritable key, Iterator<Vector> values,
OutputCollector<ImmutableBytesWritable, BatchUpdate> output,
Reporter reporter) throws IOException {
BatchUpdate b = new BatchUpdate(key.get());
- DenseVector vector = values.next();
+ Vector 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=688645&r1=688644&r2=688645&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 01:02:56 2008
@@ -196,4 +196,5 @@
}
}
+
}
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=688645&r1=688644&r2=688645&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 01:02:56 2008
@@ -22,10 +22,11 @@
import org.apache.hadoop.mapred.JobConf;
import org.apache.hadoop.mapred.RecordReader;
import org.apache.hadoop.mapred.Reporter;
-import org.apache.hama.DenseVector;
+import org.apache.hama.Vector;
+import org.apache.hama.io.VectorWritable;
public abstract class MatrixInputFormatBase implements
- InputFormat<ImmutableBytesWritable, DenseVector> {
+ InputFormat<ImmutableBytesWritable, Vector> {
private final Log LOG = LogFactory.getLog(MatrixInputFormatBase.class);
private byte[][] inputColumns;
private HTable table;
@@ -33,10 +34,10 @@
private RowFilterInterface rowFilter;
/**
- * Iterate over an HBase table data, return (Text, DenseVector) pairs
+ * Iterate over an HBase table data, return (Text, VectorResult) pairs
*/
protected class TableRecordReader implements
- RecordReader<ImmutableBytesWritable, DenseVector> {
+ RecordReader<ImmutableBytesWritable, Vector> {
private byte[] startRow;
private byte[] endRow;
private RowFilterInterface trrRowFilter;
@@ -76,7 +77,7 @@
}
/**
- * @param inputColumns the columns to be placed in [EMAIL PROTECTED]
DenseVector}.
+ * @param inputColumns the columns to be placed in [EMAIL PROTECTED]
VectorWritable}.
*/
public void setInputColumns(final byte[][] inputColumns) {
this.trrInputColumns = inputColumns;
@@ -119,12 +120,12 @@
}
/**
- * @return DenseVector
+ * @return VectorResult
*
* @see org.apache.hadoop.mapred.RecordReader#createValue()
*/
- public DenseVector createValue() {
- return new DenseVector();
+ public Vector createValue() {
+ return new Vector();
}
/** [EMAIL PROTECTED] */
@@ -144,13 +145,13 @@
* @param key HStoreKey as input key.
* @param value MapWritable as input value
*
- * Converts Scanner.next() to Text, DenseVector
+ * Converts Scanner.next() to Text, VectorResult
*
* @return true if there was more data
* @throws IOException
*/
@SuppressWarnings("unchecked")
- public boolean next(ImmutableBytesWritable key, DenseVector value)
+ public boolean next(ImmutableBytesWritable key, Vector value)
throws IOException {
RowResult result = this.scanner.next();
boolean hasMore = result != null && result.size() > 0;
@@ -169,7 +170,7 @@
* @see org.apache.hadoop.mapred.InputFormat#getRecordReader(InputSplit,
* JobConf, Reporter)
*/
- public RecordReader<ImmutableBytesWritable, DenseVector> getRecordReader(
+ public RecordReader<ImmutableBytesWritable, Vector> getRecordReader(
InputSplit split, @SuppressWarnings("unused") JobConf job,
@SuppressWarnings("unused") Reporter reporter) throws IOException {
TableSplit tSplit = (TableSplit) split;
@@ -237,7 +238,7 @@
}
/**
- * @param inputColumns to be passed in [EMAIL PROTECTED] DenseVector} to the
map task.
+ * @param inputColumns to be passed in [EMAIL PROTECTED] VectorWritable} 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=688645&r1=688644&r2=688645&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 01:02:56 2008
@@ -31,19 +31,18 @@
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;
[EMAIL PROTECTED]
[EMAIL PROTECTED]("unchecked")
public abstract class MatrixMap<K extends WritableComparable, V extends
Writable>
extends MapReduceBase implements
Mapper<ImmutableBytesWritable, Vector, K, V> {
- protected static Matrix MATRIX_B;
+ protected static Matrix B;
public static void initJob(String matrixA, String matrixB,
- Class<? extends DenseMap> mapper,
+ Class<? extends MatrixMap> mapper,
Class<? extends WritableComparable> outputKeyClass,
Class<? extends Writable> outputValueClass, JobConf job) {
@@ -53,7 +52,7 @@
job.setMapperClass(mapper);
FileInputFormat.addInputPaths(job, matrixA);
- MATRIX_B = new DenseMatrix(new HamaConfiguration(), matrixB);
+ B = new Matrix(new HamaConfiguration(), matrixB);
job.set(MatrixInputFormat.COLUMN_LIST, Constants.COLUMN);
}