Author: edwardyoon
Date: Sun Oct 5 22:12:19 2008
New Revision: 701947
URL: http://svn.apache.org/viewvc?rev=701947&view=rev
Log: (empty)
Added:
incubator/hama/trunk/src/java/org/apache/hama/AbstractVector.java
Modified:
incubator/hama/trunk/src/java/org/apache/hama/AbstractMatrix.java
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/algebra/Add1DLayoutMap.java
incubator/hama/trunk/src/java/org/apache/hama/algebra/Add1DLayoutReduce.java
incubator/hama/trunk/src/java/org/apache/hama/algebra/Mult1DLayoutMap.java
incubator/hama/trunk/src/java/org/apache/hama/algebra/Mult1DLayoutReduce.java
incubator/hama/trunk/src/java/org/apache/hama/io/VectorWritable.java
incubator/hama/trunk/src/java/org/apache/hama/mapred/DenseMap.java
incubator/hama/trunk/src/java/org/apache/hama/mapred/MatrixInputFormatBase.java
incubator/hama/trunk/src/java/org/apache/hama/mapred/MatrixReduce.java
incubator/hama/trunk/src/test/org/apache/hama/TestDenseMatrix.java
incubator/hama/trunk/src/test/org/apache/hama/mapred/TestMatrixMapReduce.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=701947&r1=701946&r2=701947&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/AbstractMatrix.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/AbstractMatrix.java Sun Oct
5 22:12:19 2008
@@ -49,7 +49,7 @@
/** Matrix attribute description */
protected HTableDescriptor tableDesc;
public HamaAdmin hAdmin;
-
+
/**
* Sets the job configuration
*
@@ -62,7 +62,7 @@
} catch (MasterNotRunningException e) {
LOG.error(e, e);
}
-
+
hAdmin = new HamaAdmin(conf, admin);
}
@@ -72,7 +72,7 @@
protected void create() throws IOException {
this.tableDesc.addFamily(new HColumnDescriptor(Constants.COLUMN));
this.tableDesc.addFamily(new HColumnDescriptor(Constants.ATTRIBUTE));
-
+
LOG.info("Initializing the matrix storage.");
this.admin.createTable(this.tableDesc);
}
@@ -137,8 +137,7 @@
public String getColumnAttribute(int column) throws IOException {
Cell rows = null;
- rows = table.get(Constants.CINDEX,
- (Constants.ATTRIBUTE + column));
+ rows = table.get(Constants.CINDEX, (Constants.ATTRIBUTE + column));
return (rows != null) ? Bytes.toString(rows.getValue()) : null;
}
@@ -152,7 +151,7 @@
public String getName() {
return (matrixName != null) ? matrixName : null;
}
-
+
public void clear() throws IOException {
admin.deleteTable(matrixName);
}
Added: 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=701947&view=auto
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/AbstractVector.java (added)
+++ incubator/hama/trunk/src/java/org/apache/hama/AbstractVector.java Sun Oct
5 22:12:19 2008
@@ -0,0 +1,50 @@
+/**
+ * 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.util.Iterator;
+
+import org.apache.hama.io.VectorEntry;
+import org.apache.hama.io.VectorMapWritable;
+
+public abstract class AbstractVector {
+ public VectorMapWritable<Integer, VectorEntry> entries;
+
+ public double get(int index) {
+ return this.entries.get(index).getValue();
+ }
+
+ public void add(int index, double value) {
+ // TODO Auto-generated method stub
+ }
+
+ /**
+ * Returns an Iterator.
+ *
+ * @return iterator
+ */
+ public Iterator<VectorEntry> iterator() {
+ return entries.values().iterator();
+ }
+
+ public int size() {
+ return this.entries.size();
+ }
+}
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=701947&r1=701946&r2=701947&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/DenseMatrix.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/DenseMatrix.java Sun Oct 5
22:12:19 2008
@@ -36,6 +36,7 @@
import org.apache.hama.io.VectorEntry;
import org.apache.hama.io.VectorMapWritable;
import org.apache.hama.io.VectorUpdate;
+import org.apache.hama.io.VectorWritable;
import org.apache.hama.mapred.MatrixReduce;
import org.apache.hama.util.JobManager;
import org.apache.hama.util.Numeric;
@@ -141,7 +142,7 @@
jobConf.setJobName("addition MR job" + result.getName());
Add1DLayoutMap.initJob(this.getName(), B.getName(), Add1DLayoutMap.class,
- IntWritable.class, DenseVector.class, jobConf);
+ IntWritable.class, VectorWritable.class, jobConf);
MatrixReduce.initJob(result.getName(), Add1DLayoutReduce.class, jobConf);
JobManager.execute(jobConf, result);
@@ -154,7 +155,7 @@
}
public DenseVector getRow(int row) throws IOException {
- return new DenseVector(row, table.getRow(String.valueOf(row)));
+ return new DenseVector(table.getRow(String.valueOf(row)));
}
public Vector getColumn(int column) throws IOException {
@@ -180,7 +181,7 @@
jobConf.setJobName("multiplication MR job : " + result.getName());
Mult1DLayoutMap.initJob(this.getName(), B.getName(),
- Mult1DLayoutMap.class, IntWritable.class, DenseVector.class, jobConf);
+ Mult1DLayoutMap.class, IntWritable.class, VectorWritable.class,
jobConf);
MatrixReduce.initJob(result.getName(), Mult1DLayoutReduce.class, jobConf);
JobManager.execute(jobConf, result);
return result;
Modified: 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=701947&r1=701946&r2=701947&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/DenseVector.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/DenseVector.java Sun Oct 5
22:12:19 2008
@@ -27,13 +27,12 @@
import org.apache.hadoop.hbase.io.RowResult;
import org.apache.hama.io.VectorEntry;
import org.apache.hama.io.VectorMapWritable;
-import org.apache.hama.io.VectorWritable;
import org.apache.hama.util.Numeric;
import org.apache.log4j.Logger;
-public class DenseVector extends VectorWritable implements Vector {
+public class DenseVector extends AbstractVector implements Vector {
static final Logger LOG = Logger.getLogger(Vector.class);
-
+
public DenseVector() {
this(new VectorMapWritable<Integer, VectorEntry>());
}
@@ -42,9 +41,8 @@
this.entries = m;
}
- public DenseVector(int row, RowResult rowResult) {
+ public DenseVector(RowResult rowResult) {
this.entries = new VectorMapWritable<Integer, VectorEntry>();
- this.row = row;
for (Map.Entry<byte[], Cell> f : rowResult.entrySet()) {
VectorEntry entry = new VectorEntry(f.getValue());
this.entries.put(Numeric.getColumnIndex(f.getKey()), entry);
@@ -55,10 +53,6 @@
return this.entries;
}
- 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;
@@ -67,7 +61,6 @@
public Vector add(Vector v2) {
if (this.size() == 0) {
DenseVector trunk = (DenseVector) v2;
- this.row = trunk.row;
this.entries = trunk.entries;
return this;
}
@@ -109,10 +102,6 @@
return this;
}
- public double get(int index) {
- return this.entries.get(index).getValue();
- }
-
public double norm(Norm type) {
if (type == Norm.One)
return getNorm1();
@@ -139,7 +128,7 @@
Iterator<Integer> it = keySet.iterator();
while (it.hasNext()) {
- sum += this.get(it.next()).getValue();
+ sum += get(it.next());
}
return sum;
@@ -152,7 +141,7 @@
Iterator<Integer> it = keySet.iterator();
while (it.hasNext()) {
- double value = this.get(it.next()).getValue();
+ double value = get(it.next()); //this.get(it.next()).getValue();
square_sum += value * value;
}
Modified:
incubator/hama/trunk/src/java/org/apache/hama/algebra/Add1DLayoutMap.java
URL:
http://svn.apache.org/viewvc/incubator/hama/trunk/src/java/org/apache/hama/algebra/Add1DLayoutMap.java?rev=701947&r1=701946&r2=701947&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/algebra/Add1DLayoutMap.java
(original)
+++ incubator/hama/trunk/src/java/org/apache/hama/algebra/Add1DLayoutMap.java
Sun Oct 5 22:12:19 2008
@@ -30,39 +30,39 @@
import org.apache.hama.HamaConfiguration;
import org.apache.hama.Matrix;
import org.apache.hama.Vector;
+import org.apache.hama.io.VectorWritable;
import org.apache.hama.mapred.DenseMap;
import org.apache.log4j.Logger;
-public class Add1DLayoutMap extends DenseMap<IntWritable, DenseVector> {
+public class Add1DLayoutMap extends DenseMap<IntWritable, VectorWritable> {
static final Logger LOG = Logger.getLogger(Add1DLayoutMap.class);
protected Matrix matrix_b;
public static final String MATRIX_B = "hama.addition.matrix.b";
-
+
public void configure(JobConf job) {
matrix_b = new DenseMatrix(new HamaConfiguration(), job.get(MATRIX_B, ""));
}
public static void initJob(String matrix_a, String matrix_b,
- Class<Add1DLayoutMap> map,
- Class<IntWritable> outputKeyClass,
- Class<DenseVector> outputValueClass,
- JobConf jobConf) {
-
+ Class<Add1DLayoutMap> map, Class<IntWritable> outputKeyClass,
+ Class<VectorWritable> outputValueClass, JobConf jobConf) {
+
jobConf.setMapOutputValueClass(outputValueClass);
jobConf.setMapOutputKeyClass(outputKeyClass);
jobConf.setMapperClass(map);
jobConf.set(MATRIX_B, matrix_b);
-
+
initJob(matrix_a, map, jobConf);
}
@Override
- public void map(IntWritable key, DenseVector value,
- OutputCollector<IntWritable, DenseVector> output, Reporter reporter)
+ public void map(IntWritable key, VectorWritable value,
+ OutputCollector<IntWritable, VectorWritable> output, Reporter reporter)
throws IOException {
Vector v1 = matrix_b.getRow(key.get());
- output.collect(key, (DenseVector) v1.add(value));
+ output.collect(key, new VectorWritable(key.get(), (DenseVector) v1
+ .add(value.getDenseVector())));
}
Modified:
incubator/hama/trunk/src/java/org/apache/hama/algebra/Add1DLayoutReduce.java
URL:
http://svn.apache.org/viewvc/incubator/hama/trunk/src/java/org/apache/hama/algebra/Add1DLayoutReduce.java?rev=701947&r1=701946&r2=701947&view=diff
==============================================================================
---
incubator/hama/trunk/src/java/org/apache/hama/algebra/Add1DLayoutReduce.java
(original)
+++
incubator/hama/trunk/src/java/org/apache/hama/algebra/Add1DLayoutReduce.java
Sun Oct 5 22:12:19 2008
@@ -26,20 +26,20 @@
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.mapred.OutputCollector;
import org.apache.hadoop.mapred.Reporter;
-import org.apache.hama.DenseVector;
import org.apache.hama.io.VectorEntry;
import org.apache.hama.io.VectorUpdate;
+import org.apache.hama.io.VectorWritable;
import org.apache.hama.mapred.MatrixReduce;
-public class Add1DLayoutReduce extends MatrixReduce<IntWritable, DenseVector> {
+public class Add1DLayoutReduce extends MatrixReduce<IntWritable,
VectorWritable> {
@Override
- public void reduce(IntWritable key, Iterator<DenseVector> values,
+ public void reduce(IntWritable key, Iterator<VectorWritable> values,
OutputCollector<IntWritable, VectorUpdate> output, Reporter reporter)
throws IOException {
VectorUpdate update = new VectorUpdate(key.get());
- DenseVector vector = values.next();
+ VectorWritable vector = values.next();
for (Map.Entry<Integer, VectorEntry> f : vector.entrySet()) {
update.put(f.getKey(), f.getValue().getValue());
Modified:
incubator/hama/trunk/src/java/org/apache/hama/algebra/Mult1DLayoutMap.java
URL:
http://svn.apache.org/viewvc/incubator/hama/trunk/src/java/org/apache/hama/algebra/Mult1DLayoutMap.java?rev=701947&r1=701946&r2=701947&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/algebra/Mult1DLayoutMap.java
(original)
+++ incubator/hama/trunk/src/java/org/apache/hama/algebra/Mult1DLayoutMap.java
Sun Oct 5 22:12:19 2008
@@ -32,45 +32,46 @@
import org.apache.hama.Matrix;
import org.apache.hama.Vector;
import org.apache.hama.io.VectorEntry;
+import org.apache.hama.io.VectorWritable;
import org.apache.hama.mapred.DenseMap;
import org.apache.log4j.Logger;
/**
- * 1D Block Layout version
+ * 1D Block Layout version
*/
-public class Mult1DLayoutMap extends DenseMap<IntWritable, DenseVector> {
+public class Mult1DLayoutMap extends DenseMap<IntWritable, VectorWritable> {
static final Logger LOG = Logger.getLogger(Mult1DLayoutMap.class);
protected Matrix matrix_b;
public static final String MATRIX_B = "hama.multiplication.matrix.b";
-
+
public void configure(JobConf job) {
matrix_b = new DenseMatrix(new HamaConfiguration(), job.get(MATRIX_B, ""));
}
-
+
public static void initJob(String matrix_a, String matrix_b,
- Class<Mult1DLayoutMap> map,
- Class<IntWritable> outputKeyClass,
- Class<DenseVector> outputValueClass,
- JobConf jobConf) {
-
+ Class<Mult1DLayoutMap> map, Class<IntWritable> outputKeyClass,
+ Class<VectorWritable> outputValueClass, JobConf jobConf) {
+
jobConf.setMapOutputValueClass(outputValueClass);
jobConf.setMapOutputKeyClass(outputKeyClass);
jobConf.setMapperClass(map);
jobConf.set(MATRIX_B, matrix_b);
-
+
initJob(matrix_a, map, jobConf);
}
-
+
@Override
- public void map(IntWritable key, DenseVector value,
- OutputCollector<IntWritable, DenseVector> output, Reporter reporter)
+ public void map(IntWritable key, VectorWritable value,
+ OutputCollector<IntWritable, VectorWritable> output, Reporter reporter)
throws IOException {
- Iterator<VectorEntry> it = value.iterator();
+ Iterator<VectorEntry> it = value.getDenseVector().iterator();
int i = 0;
while (it.hasNext()) {
Vector v = matrix_b.getRow(i);
- output.collect(key, (DenseVector) v.scale(it.next().getValue()));
+
+ output.collect(key, new VectorWritable(key.get(), (DenseVector) v
+ .scale(it.next().getValue())));
i++;
}
}
Modified:
incubator/hama/trunk/src/java/org/apache/hama/algebra/Mult1DLayoutReduce.java
URL:
http://svn.apache.org/viewvc/incubator/hama/trunk/src/java/org/apache/hama/algebra/Mult1DLayoutReduce.java?rev=701947&r1=701946&r2=701947&view=diff
==============================================================================
---
incubator/hama/trunk/src/java/org/apache/hama/algebra/Mult1DLayoutReduce.java
(original)
+++
incubator/hama/trunk/src/java/org/apache/hama/algebra/Mult1DLayoutReduce.java
Sun Oct 5 22:12:19 2008
@@ -27,23 +27,23 @@
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.mapred.OutputCollector;
import org.apache.hadoop.mapred.Reporter;
-import org.apache.hama.DenseVector;
import org.apache.hama.io.VectorUpdate;
+import org.apache.hama.io.VectorWritable;
import org.apache.hama.mapred.MatrixReduce;
import org.apache.log4j.Logger;
public class Mult1DLayoutReduce extends
- MatrixReduce<IntWritable, DenseVector> {
+ MatrixReduce<IntWritable, VectorWritable> {
static final Logger LOG = Logger.getLogger(Mult1DLayoutReduce.class);
@Override
- public void reduce(IntWritable key, Iterator<DenseVector> values,
+ public void reduce(IntWritable key, Iterator<VectorWritable> values,
OutputCollector<IntWritable, VectorUpdate> output, Reporter reporter)
throws IOException {
VectorUpdate update = new VectorUpdate(key.get());
- DenseVector sum;
+ VectorWritable sum;
Map<Integer, Double> buffer = new HashMap<Integer, Double>();
// Summation
@@ -51,9 +51,9 @@
sum = values.next();
for (int i = 0; i < sum.size(); i++) {
if (buffer.containsKey(i)) {
- buffer.put(i, sum.get(i) + buffer.get(i));
+ buffer.put(i, sum.get(i).getValue() + buffer.get(i));
} else {
- buffer.put(i, sum.get(i));
+ buffer.put(i, sum.get(i).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=701947&r1=701946&r2=701947&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 Sun
Oct 5 22:12:19 2008
@@ -25,24 +25,38 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
-import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
-import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.util.Bytes;
-import org.apache.hadoop.hbase.util.Writables;
import org.apache.hadoop.io.Writable;
+import org.apache.hama.DenseVector;
import org.apache.hama.Vector;
import org.apache.hama.util.Numeric;
-public abstract class VectorWritable implements Writable,
- Map<Integer, VectorEntry> {
+public class VectorWritable implements Writable, Map<Integer, VectorEntry> {
public Integer row;
public VectorMapWritable<Integer, VectorEntry> entries;
+ public VectorWritable() {
+ this(new VectorMapWritable<Integer, VectorEntry>());
+ }
+
+ public VectorWritable(VectorMapWritable<Integer, VectorEntry> entries) {
+ this.entries = entries;
+ }
+
+ public VectorWritable(int row, DenseVector v) {
+ this.row = row;
+ this.entries = v.entries;
+ }
+
+ public DenseVector getDenseVector() {
+ return new DenseVector(entries);
+ }
+
public VectorEntry put(Integer key, VectorEntry value) {
throw new UnsupportedOperationException("VectorWritable is read-only!");
}
@@ -116,66 +130,10 @@
return this.entries.get(column);
}
- /**
- * Get the VectorEntry that corresponds to column, using a String key
- */
- public VectorEntry get(String key) {
- return get(Bytes.toBytes(key));
- }
-
- /**
- * Get the double value without timestamp
- */
- public double get(int key) {
- return this.get(Numeric.intToBytes(key)).getValue();
- }
-
public int size() {
return this.entries.size();
}
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder();
- sb.append("row=");
- sb.append(", cells={");
- boolean moreThanOne = false;
- for (Map.Entry<Integer, VectorEntry> e : this.entries.entrySet()) {
- if (moreThanOne) {
- sb.append(", ");
- } else {
- moreThanOne = true;
- }
- sb.append("(column=");
- sb.append(String.valueOf(e.getKey()));
- sb.append(", timestamp=");
- sb.append(Long.toString(e.getValue().getTimestamp()));
- sb.append(", value=");
- byte[] value = Numeric.doubleToBytes(e.getValue().getValue());
- if (Bytes.equals(Numeric.intToBytes(e.getKey()),
HConstants.COL_REGIONINFO)) {
- try {
- sb.append(Writables.getHRegionInfo(value).toString());
- } catch (IOException ioe) {
- sb.append(ioe.toString());
- }
- } else {
- sb.append(Bytes.toString(value));
- }
- sb.append(")");
- }
- sb.append("}");
- return sb.toString();
- }
-
- /**
- * Returns an Iterator.
- *
- * @return iterator
- */
- public Iterator<VectorEntry> iterator() {
- return entries.values().iterator();
- }
-
/**
*
* The inner class for an entry of row.
Modified: 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=701947&r1=701946&r2=701947&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/mapred/DenseMap.java
(original)
+++ incubator/hama/trunk/src/java/org/apache/hama/mapred/DenseMap.java Sun Oct
5 22:12:19 2008
@@ -31,13 +31,13 @@
import org.apache.hadoop.mapred.OutputCollector;
import org.apache.hadoop.mapred.Reporter;
import org.apache.hama.Constants;
-import org.apache.hama.DenseVector;
import org.apache.hama.Matrix;
+import org.apache.hama.io.VectorWritable;
@SuppressWarnings("unchecked")
public abstract class DenseMap<K extends WritableComparable, V extends
Writable>
extends MapReduceBase implements
- Mapper<IntWritable, DenseVector, K, V> {
+ Mapper<IntWritable, VectorWritable, K, V> {
public static Matrix MATRIX_B;
public static void initJob(String matrixA,
@@ -51,6 +51,6 @@
job.set(MatrixInputFormat.COLUMN_LIST, Constants.COLUMN);
}
- public abstract void map(IntWritable key, DenseVector value,
+ public abstract void map(IntWritable key, VectorWritable 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=701947&r1=701946&r2=701947&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
Sun Oct 5 22:12:19 2008
@@ -40,21 +40,21 @@
import org.apache.hadoop.mapred.RecordReader;
import org.apache.hadoop.mapred.Reporter;
import org.apache.hama.Constants;
-import org.apache.hama.DenseVector;
+import org.apache.hama.io.VectorWritable;
import org.apache.hama.util.Numeric;
public abstract class MatrixInputFormatBase implements
- InputFormat<IntWritable, DenseVector> {
+ InputFormat<IntWritable, VectorWritable> {
private byte[][] inputColumns;
private HTable table;
private TableRecordReader tableRecordReader;
private RowFilterInterface rowFilter;
/**
- * Iterate over an HBase table data, return (Text, DenseVector) pairs
+ * Iterate over an HBase table data, return (Text, VectorWritable) pairs
*/
protected static class TableRecordReader implements
- RecordReader<IntWritable, DenseVector> {
+ RecordReader<IntWritable, VectorWritable> {
private byte[] startRow;
private byte[] endRow;
private RowFilterInterface trrRowFilter;
@@ -94,7 +94,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) {
byte[][] columns = inputColumns;
@@ -140,12 +140,12 @@
}
/**
- * @return DenseVector
+ * @return VectorWritable
*
* @see org.apache.hadoop.mapred.RecordReader#createValue()
*/
- public DenseVector createValue() {
- return new DenseVector();
+ public VectorWritable createValue() {
+ return new VectorWritable();
}
/** [EMAIL PROTECTED] */
@@ -163,14 +163,14 @@
/**
* @param key IntWritable as input key.
- * @param value DenseVector as input value
+ * @param value VectorWritable as input value
*
- * Converts Scanner.next() to IntWritable, DenseVector
+ * Converts Scanner.next() to IntWritable, VectorWritable
*
* @return true if there was more data
* @throws IOException
*/
- public boolean next(IntWritable key, DenseVector value) throws IOException
{
+ public boolean next(IntWritable key, VectorWritable value) throws
IOException {
RowResult result = this.scanner.next();
boolean hasMore = result != null && result.size() > 0;
if (hasMore) {
@@ -188,7 +188,7 @@
* @see org.apache.hadoop.mapred.InputFormat#getRecordReader(InputSplit,
* JobConf, Reporter)
*/
- public RecordReader<IntWritable, DenseVector> getRecordReader(
+ public RecordReader<IntWritable, VectorWritable> getRecordReader(
InputSplit split, JobConf job, Reporter reporter) throws IOException {
TableSplit tSplit = (TableSplit) split;
TableRecordReader trr = this.tableRecordReader;
@@ -229,7 +229,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/MatrixReduce.java
URL:
http://svn.apache.org/viewvc/incubator/hama/trunk/src/java/org/apache/hama/mapred/MatrixReduce.java?rev=701947&r1=701946&r2=701947&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/mapred/MatrixReduce.java
(original)
+++ incubator/hama/trunk/src/java/org/apache/hama/mapred/MatrixReduce.java Sun
Oct 5 22:12:19 2008
@@ -37,8 +37,8 @@
public abstract class MatrixReduce<K extends WritableComparable, V extends
Writable>
extends MapReduceBase implements Reducer<K, V, IntWritable, VectorUpdate> {
/**
- * Use this before submitting a TableReduce job. It will
- * appropriately set up the JobConf.
+ * Use this before submitting a TableReduce job. It will appropriately set up
+ * the JobConf.
*
* @param table
* @param reducer
@@ -62,6 +62,6 @@
* @throws IOException
*/
public abstract void reduce(K key, Iterator<V> values,
- OutputCollector<IntWritable, VectorUpdate> output, Reporter reporter)
- throws IOException;
-}
\ No newline at end of file
+ OutputCollector<IntWritable, VectorUpdate> output, Reporter reporter)
+ throws IOException;
+}
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=701947&r1=701946&r2=701947&view=diff
==============================================================================
--- incubator/hama/trunk/src/test/org/apache/hama/TestDenseMatrix.java
(original)
+++ incubator/hama/trunk/src/test/org/apache/hama/TestDenseMatrix.java Sun Oct
5 22:12:19 2008
@@ -177,8 +177,8 @@
for (int i = 0; i < SIZE; i++) {
for (int j = 0; j < SIZE; j++) {
- assertEquals(String.valueOf(result.get(i, j)).substring(0, 14),
- String.valueOf(C[i][j]).substring(0, 14));
+ assertEquals(String.valueOf(result.get(i, j)).substring(0, 14), String
+ .valueOf(C[i][j]).substring(0, 14));
}
}
}
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=701947&r1=701946&r2=701947&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
Sun Oct 5 22:12:19 2008
@@ -25,11 +25,11 @@
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.HCluster;
import org.apache.hama.Matrix;
import org.apache.hama.algebra.Add1DLayoutMap;
import org.apache.hama.algebra.Add1DLayoutReduce;
+import org.apache.hama.io.VectorWritable;
import org.apache.log4j.Logger;
/**
@@ -67,7 +67,7 @@
jobConf.setJobName("test MR job");
Add1DLayoutMap.initJob(A, B, Add1DLayoutMap.class, IntWritable.class,
- DenseVector.class, jobConf);
+ VectorWritable.class, jobConf);
MatrixReduce.initJob(output, Add1DLayoutReduce.class, jobConf);
jobConf.setNumMapTasks(1);