incubator-hama-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From edwardy...@apache.org
Subject svn commit: r683801 - in /incubator/hama/trunk/src: java/org/apache/hama/ java/org/apache/hama/algebra/ java/org/apache/hama/io/ java/org/apache/hama/mapred/ test/org/apache/hama/ test/org/apache/hama/mapred/
Date Fri, 08 Aug 2008 02:26:24 GMT
Author: edwardyoon
Date: Thu Aug  7 19:26:23 2008
New Revision: 683801

URL: http://svn.apache.org/viewvc?rev=683801&view=rev
Log:
Vector to Writable conversion.

Added:
    incubator/hama/trunk/src/java/org/apache/hama/io/VectorWritable.java
Removed:
    incubator/hama/trunk/src/java/org/apache/hama/io/VectorDatum.java
Modified:
    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/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/java/org/apache/hama/Vector.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/java/org/apache/hama/Vector.java?rev=683801&r1=683800&r2=683801&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/Vector.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/Vector.java Thu Aug  7 19:26:23 2008
@@ -19,54 +19,71 @@
  */
 package org.apache.hama;
 
-import java.util.Map;
-import java.util.Set;
-import java.util.SortedMap;
-import java.util.TreeMap;
-import java.util.Map.Entry;
-
 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.VectorDatum;
+import org.apache.hama.io.VectorWritable;
 import org.apache.log4j.Logger;
 
-public class Vector extends AbstractBase implements VectorInterface {
+public class Vector extends VectorWritable implements VectorInterface {
   static final Logger LOG = Logger.getLogger(Vector.class);
-  protected int[] m_dims;
-  protected double[] m_vals;
+
+  public enum Norm {
+    // TODO : Add types
+  }
+
+  public Vector() {
+    this(null, new HbaseMapWritable<byte[], Cell>());
+  }
+
+  /**
+   * Create a RowResult from a row and Cell map
+   */
+  public Vector(final byte[] row, final HbaseMapWritable<byte[], Cell> m) {
+    this.row = row;
+    this.cells = m;
+  }
+
+  public byte[] getRow() {
+    return row;
+  }
 
   public Vector(RowResult r) {
     parse(r.entrySet());
   }
 
-  public Vector(VectorDatum r) {
+  public Vector(VectorWritable r) {
     parse(r.entrySet());
   }
 
-  private void parse(Set<Entry<byte[], Cell>> entrySet) {
-    SortedMap<Integer, Double> m = new TreeMap<Integer, Double>();
-    for (Map.Entry<byte[], Cell> f : entrySet) {
-      m.put(getColumnIndex(f.getKey()), Double.parseDouble(Bytes.toString(f
-          .getValue().getValue())));
-    }
+  public Vector(byte[] rowKey, Matrix b) {
+    this.row = rowKey;
+    parse(b.getRowResult(this.row).entrySet());
+  }
+
+  public void add(int index, double value) {
+    // TODO Auto-generated method stub
+
+  }
 
-    this.m_dims = new int[m.keySet().size()];
-    this.m_vals = new double[m.keySet().size()];
+  public boolean add(double alpha, Vector v) {
+    // TODO Auto-generated method stub
+    return false;
+  }
 
-    int i = 0;
-    for (Map.Entry<Integer, Double> f : m.entrySet()) {
-      this.m_dims[i] = f.getKey();
-      this.m_vals[i] = f.getValue();
-      i++;
+  public Vector add(Vector v2) {
+    HbaseMapWritable<byte[], Cell> trunk = new HbaseMapWritable<byte[], Cell>();
+    for (int i = 0; i < this.size(); i++) {
+      double value = (this.getValueAt(i) + v2.getValueAt(i));
+      Cell cValue = new Cell(String.valueOf(value), 0);
+      trunk.put(Bytes.toBytes("column:" + i), cValue);
     }
+
+    return new Vector(row, trunk);
   }
 
-  /**
-   * Returns the cosine similarity between two feature vectors.
-   */
-  public double getCosine(Vector v) {
+  public double dot(Vector v) {
     double cosine = 0.0;
     int dim;
     double q_i, d_i;
@@ -79,6 +96,26 @@
     return cosine / (this.getL2Norm() * v.getL2Norm());
   }
 
+  public double get(int index) {
+    // TODO Auto-generated method stub
+    return 0;
+  }
+
+  public double norm(Norm type) {
+    // TODO Auto-generated method stub
+    return 0;
+  }
+
+  public void set(int index, double value) {
+    // TODO Auto-generated method stub
+
+  }
+
+  public Vector set(Vector v) {
+    // TODO Auto-generated method stub
+    return null;
+  }
+
   /**
    * Returns the linear norm factor of this vector's values (i.e., the sum of
    * it's values).
@@ -109,19 +146,4 @@
   public double getValueAt(int index) {
     return m_vals[index];
   }
-
-  public int size() {
-    return m_dims.length;
-  }
-
-  public VectorDatum addition(byte[] bs, Vector v2) {
-    HbaseMapWritable<byte[], Cell> trunk = new HbaseMapWritable<byte[], Cell>();
-    for (int i = 0; i < this.size(); i++) {
-      double value = (this.getValueAt(i) + v2.getValueAt(i));
-      Cell cValue = new Cell(String.valueOf(value), 0);
-      trunk.put(Bytes.toBytes("column:" + i), cValue);
-    }
-
-    return new VectorDatum(bs, trunk);
-  }
 }

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=683801&r1=683800&r2=683801&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/VectorInterface.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/VectorInterface.java Thu Aug  7 19:26:23
2008
@@ -1,30 +1,79 @@
 package org.apache.hama;
 
-import org.apache.hama.io.VectorDatum;
-
 /**
- * A vector. Features are dimension-value pairs. This class implements a
- * simple dictionary data structure to map dimensions onto their values. Note
- * that for convenience, features do not have be sorted according to their
- * dimensions at this point. The SVMLightTrainer class has an option for sorting
- * input vectors prior to training.
+ * Basic vector interface.
  */
 public interface VectorInterface {
   
+  /**
+   * @return size of the vector
+   */
+  public int size();
+
+  /**
+   * @param index
+   * @return v(index)
+   */
+  public double get(int index); 
+  
+  /**
+   * v(index) = value
+   *  
+   * @param index
+   * @param value
+   */
+  public void set(int index, double value);
+  
+  /**
+   * @param v
+   * @return x = v 
+   */
+  public Vector set(Vector v);
+
+  /**
+   * v(index) += value
+   *  
+   * @param index
+   * @param value
+   */
+  public void add(int index, double value);
+  
+  /**
+   * @param alpha
+   * @param v
+   * @return  x = alpha*v + x
+   */
+  public boolean add(double alpha, Vector v);
+
+  /**
+   * @param v
+   * @return x = v + x
+   */
+  public Vector add(Vector v);
+  
+  /**
+   * @param v
+   * @return x dot v
+   */
+  public double dot(Vector v);
+
+  /**
+   * Computes the given norm of the vector
+   * 
+   * @param type
+   * @return norm of the vector
+   */
+  public double norm(Vector.Norm type);
+
+  @Deprecated
   public double getValueAt(int index);
   
+  @Deprecated
   public int getDimAt(int index);
   
-  public int size();
-  
+  @Deprecated
   public double getL1Norm();
   
+  @Deprecated
   public double getL2Norm();
-  
-  public double getCosine(Vector v);
-  
-  public VectorDatum addition(byte[] bs, Vector v2);
-  
-  // TODO: save, copy,...,etc
-  
 }

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=683801&r1=683800&r2=683801&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 Thu Aug  7 19:26:23
2008
@@ -6,17 +6,16 @@
 import org.apache.hadoop.mapred.OutputCollector;
 import org.apache.hadoop.mapred.Reporter;
 import org.apache.hama.Vector;
-import org.apache.hama.io.VectorDatum;
 import org.apache.hama.mapred.MatrixMap;
 
-public class AdditionMap extends MatrixMap<ImmutableBytesWritable, VectorDatum> {
+public class AdditionMap extends MatrixMap<ImmutableBytesWritable, Vector> {
 
-  public void map(ImmutableBytesWritable key, VectorDatum value,
-      OutputCollector<ImmutableBytesWritable, VectorDatum> output,
+  public void map(ImmutableBytesWritable key, Vector value,
+      OutputCollector<ImmutableBytesWritable, Vector> output,
       Reporter reporter) throws IOException {
 
-    Vector v1 = new Vector(B.getRowResult(key.get()));
-    output.collect(key, v1.addition(key.get(), value.getVector()));
+    Vector v1 = new Vector(key.get(), B);
+    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=683801&r1=683800&r2=683801&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 Thu Aug  7 19:26:23
2008
@@ -9,19 +9,19 @@
 import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
 import org.apache.hadoop.mapred.OutputCollector;
 import org.apache.hadoop.mapred.Reporter;
-import org.apache.hama.io.VectorDatum;
+import org.apache.hama.Vector;
 import org.apache.hama.mapred.MatrixReduce;
 
 public class AdditionReduce extends
-    MatrixReduce<ImmutableBytesWritable, VectorDatum> {
+    MatrixReduce<ImmutableBytesWritable, Vector> {
 
   @Override
-  public void reduce(ImmutableBytesWritable key, Iterator<VectorDatum> values,
+  public void reduce(ImmutableBytesWritable key, Iterator<Vector> values,
       OutputCollector<ImmutableBytesWritable, BatchUpdate> output,
       Reporter reporter) throws IOException {
 
     BatchUpdate b = new BatchUpdate(key.get());
-    VectorDatum vector = values.next();
+    Vector vector = values.next();
     for (Map.Entry<byte[], Cell> f : vector.entrySet()) {
       b.put(f.getKey(), f.getValue().getValue());
     }

Added: 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=683801&view=auto
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/io/VectorWritable.java (added)
+++ incubator/hama/trunk/src/java/org/apache/hama/io/VectorWritable.java Thu Aug  7 19:26:23
2008
@@ -0,0 +1,200 @@
+package org.apache.hama.io;
+
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Map;
+import java.util.Set;
+import java.util.SortedMap;
+import java.util.TreeMap;
+import java.util.TreeSet;
+
+import org.apache.hadoop.hbase.HConstants;
+import org.apache.hadoop.hbase.io.Cell;
+import org.apache.hadoop.hbase.io.HbaseMapWritable;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.hbase.util.Writables;
+import org.apache.hadoop.io.Writable;
+import org.apache.hama.AbstractBase;
+import org.apache.hama.Vector;
+
+public class VectorWritable extends AbstractBase implements Writable,
+    Map<byte[], Cell> {
+  public byte[] row;
+  public HbaseMapWritable<byte[], Cell> cells;
+  public int[] m_dims;
+  public double[] m_vals;
+
+  public void parse(Set<Entry<byte[], Cell>> entrySet) {
+    SortedMap<Integer, Double> m = new TreeMap<Integer, Double>();
+    for (Map.Entry<byte[], Cell> f : entrySet) {
+      m.put(getColumnIndex(f.getKey()), Double.parseDouble(Bytes.toString(f
+          .getValue().getValue())));
+    }
+
+    this.m_dims = new int[m.keySet().size()];
+    this.m_vals = new double[m.keySet().size()];
+
+    int i = 0;
+    for (Map.Entry<Integer, Double> f : m.entrySet()) {
+      this.m_dims[i] = f.getKey();
+      this.m_vals[i] = f.getValue();
+      i++;
+    }
+  }
+
+  public Cell put(@SuppressWarnings("unused")
+  byte[] key, @SuppressWarnings("unused")
+  Cell value) {
+    throw new UnsupportedOperationException("VectorDatum is read-only!");
+  }
+
+  public Cell get(Object key) {
+    return (Cell) this.cells.get(key);
+  }
+
+  public Cell remove(@SuppressWarnings("unused")
+  Object key) {
+    throw new UnsupportedOperationException("VectorDatum is read-only!");
+  }
+
+  public boolean containsKey(Object key) {
+    return cells.containsKey(key);
+  }
+
+  public boolean containsValue(@SuppressWarnings("unused")
+  Object value) {
+    throw new UnsupportedOperationException("Don't support containsValue!");
+  }
+
+  public boolean isEmpty() {
+    return cells.isEmpty();
+  }
+
+  public void clear() {
+    throw new UnsupportedOperationException("VectorDatum is read-only!");
+  }
+
+  public Set<byte[]> keySet() {
+    Set<byte[]> result = new TreeSet<byte[]>(Bytes.BYTES_COMPARATOR);
+    for (byte[] w : cells.keySet()) {
+      result.add(w);
+    }
+    return result;
+  }
+
+  public Set<Map.Entry<byte[], Cell>> entrySet() {
+    return Collections.unmodifiableSet(this.cells.entrySet());
+  }
+
+  public Collection<Cell> values() {
+    ArrayList<Cell> result = new ArrayList<Cell>();
+    for (Writable w : cells.values()) {
+      result.add((Cell) w);
+    }
+    return result;
+  }
+
+  public void readFields(final DataInput in) throws IOException {
+    this.row = Bytes.readByteArray(in);
+    this.cells.readFields(in);
+    parse(this.cells.entrySet());
+  }
+
+  public void write(final DataOutput out) throws IOException {
+    Bytes.writeByteArray(out, this.row);
+    this.cells.write(out);
+  }
+
+  public VectorWritable addition(byte[] bs, Vector v2) {
+    // TODO Auto-generated method stub
+    return null;
+  }
+
+  public void putAll(Map<? extends byte[], ? extends Cell> m) {
+    // TODO Auto-generated method stub
+
+  }
+
+  /**
+   * Get the Cell that corresponds to column
+   */
+  public Cell get(byte[] column) {
+    return this.cells.get(column);
+  }
+
+  /**
+   * Get the Cell that corresponds to column, using a String key
+   */
+  public Cell get(String key) {
+    return get(Bytes.toBytes(key));
+  }
+
+  public int size() {
+    //return this.cells.size();
+    return m_dims.length;
+  }
+
+  @Override
+  public String toString() {
+    StringBuilder sb = new StringBuilder();
+    sb.append("row=");
+    sb.append(Bytes.toString(this.row));
+    sb.append(", cells={");
+    boolean moreThanOne = false;
+    for (Map.Entry<byte[], Cell> e : this.cells.entrySet()) {
+      if (moreThanOne) {
+        sb.append(", ");
+      } else {
+        moreThanOne = true;
+      }
+      sb.append("(column=");
+      sb.append(Bytes.toString(e.getKey()));
+      sb.append(", timestamp=");
+      sb.append(Long.toString(e.getValue().getTimestamp()));
+      sb.append(", value=");
+      byte[] v = e.getValue().getValue();
+      if (Bytes.equals(e.getKey(), HConstants.COL_REGIONINFO)) {
+        try {
+          sb.append(Writables.getHRegionInfo(v).toString());
+        } catch (IOException ioe) {
+          sb.append(ioe.toString());
+        }
+      } else {
+        sb.append(v);
+      }
+      sb.append(")");
+    }
+    sb.append("}");
+    return sb.toString();
+  }
+
+  /**
+   * Row entry.
+   */
+  public class Entries implements Map.Entry<byte[], Cell> {
+    private final byte[] column;
+    private final Cell cell;
+
+    Entries(byte[] row, Cell cell) {
+      this.column = row;
+      this.cell = cell;
+    }
+
+    public Cell setValue(@SuppressWarnings("unused")
+    Cell c) {
+      throw new UnsupportedOperationException("VectorDatum is read-only!");
+    }
+
+    public byte[] getKey() {
+      return column;
+    }
+
+    public Cell getValue() {
+      return cell;
+    }
+  }
+}

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=683801&r1=683800&r2=683801&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 Thu Aug
 7 19:26:23 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.io.VectorDatum;
+import org.apache.hama.Vector;
+import org.apache.hama.io.VectorWritable;
 
 public abstract class MatrixInputFormatBase
-implements InputFormat<ImmutableBytesWritable, VectorDatum> {
+implements InputFormat<ImmutableBytesWritable, Vector> {
   private final Log LOG = LogFactory.getLog(MatrixInputFormatBase.class);
   private byte [][] inputColumns;
   private HTable table;
@@ -36,7 +37,7 @@
    * Iterate over an HBase table data, return (Text, VectorResult) pairs
    */
   protected class TableRecordReader
-  implements RecordReader<ImmutableBytesWritable, VectorDatum> {
+  implements RecordReader<ImmutableBytesWritable, Vector> {
     private byte [] startRow;
     private byte [] endRow;
     private RowFilterInterface trrRowFilter;
@@ -77,7 +78,7 @@
     }
 
     /**
-     * @param inputColumns the columns to be placed in {@link VectorDatum}.
+     * @param inputColumns the columns to be placed in {@link VectorWritable}.
      */
     public void setInputColumns(final byte [][] inputColumns) {
       this.trrInputColumns = inputColumns;
@@ -124,8 +125,8 @@
      *
      * @see org.apache.hadoop.mapred.RecordReader#createValue()
      */
-    public VectorDatum createValue() {
-      return new VectorDatum();
+    public Vector createValue() {
+      return new Vector();
     }
 
     /** {@inheritDoc} */
@@ -151,7 +152,7 @@
      * @throws IOException
      */
     @SuppressWarnings("unchecked")
-    public boolean next(ImmutableBytesWritable key, VectorDatum value)
+    public boolean next(ImmutableBytesWritable key, Vector value)
     throws IOException {
       RowResult result = this.scanner.next();
       boolean hasMore = result != null && result.size() > 0;
@@ -170,7 +171,7 @@
    * @see org.apache.hadoop.mapred.InputFormat#getRecordReader(InputSplit,
    *      JobConf, Reporter)
    */
-  public RecordReader<ImmutableBytesWritable, VectorDatum> getRecordReader(InputSplit
split,
+  public RecordReader<ImmutableBytesWritable, Vector> getRecordReader(InputSplit split,
       @SuppressWarnings("unused")
       JobConf job, @SuppressWarnings("unused")
       Reporter reporter)
@@ -239,7 +240,7 @@
   }
 
   /**
-   * @param inputColumns to be passed in {@link VectorDatum} to the map task.
+   * @param inputColumns to be passed in {@link 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=683801&r1=683800&r2=683801&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 Thu Aug  7 19:26:23
2008
@@ -15,12 +15,12 @@
 import org.apache.hadoop.mapred.Reporter;
 import org.apache.hama.Constants;
 import org.apache.hama.Matrix;
-import org.apache.hama.io.VectorDatum;
+import org.apache.hama.Vector;
 
 @SuppressWarnings("unchecked")
 public abstract class MatrixMap<K extends WritableComparable, V extends Writable>
     extends MapReduceBase implements
-    Mapper<ImmutableBytesWritable, VectorDatum, K, V> {
+    Mapper<ImmutableBytesWritable, Vector, K, V> {
   protected static Matrix B;
 
   public static void initJob(String matrixA, String matrixB,
@@ -38,6 +38,6 @@
     job.set(MatrixInputFormat.COLUMN_LIST, Constants.COLUMN);
   }
 
-  public abstract void map(ImmutableBytesWritable key, VectorDatum value,
+  public abstract void map(ImmutableBytesWritable key, Vector value,
       OutputCollector<K, V> output, Reporter reporter) throws IOException;
 }

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=683801&r1=683800&r2=683801&view=diff
==============================================================================
--- incubator/hama/trunk/src/test/org/apache/hama/TestMatrix.java (original)
+++ incubator/hama/trunk/src/test/org/apache/hama/TestMatrix.java Thu Aug  7 19:26:23 2008
@@ -27,7 +27,7 @@
 import org.apache.hadoop.mapred.JobConf;
 import org.apache.hama.algebra.AdditionMap;
 import org.apache.hama.algebra.AdditionReduce;
-import org.apache.hama.io.VectorDatum;
+import org.apache.hama.io.VectorWritable;
 import org.apache.hama.mapred.MatrixMap;
 import org.apache.hama.mapred.MatrixReduce;
 import org.apache.hama.mapred.TestMatrixMapReduce;

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=683801&r1=683800&r2=683801&view=diff
==============================================================================
--- incubator/hama/trunk/src/test/org/apache/hama/TestVector.java (original)
+++ incubator/hama/trunk/src/test/org/apache/hama/TestVector.java Thu Aug  7 19:26:23 2008
@@ -50,7 +50,7 @@
     Vector v1 = new Vector(m1.getRowResult(0));
     Vector v2 = new Vector(m1.getRowResult(1));
 
-    double cos = v1.getCosine(v2);
+    double cos = v1.dot(v2);
     assertEquals(cos, result);
     m1.close();
   }

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=683801&r1=683800&r2=683801&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 Thu Aug
 7 19:26:23 2008
@@ -27,9 +27,9 @@
 import org.apache.hadoop.mapred.JobConf;
 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.hama.io.VectorDatum;
 import org.apache.log4j.Logger;
 
 /**
@@ -64,7 +64,7 @@
     jobConf.setJobName("test MR job");
 
     MatrixMap.initJob("MatrixA", "MatrixB", AdditionMap.class,
-        ImmutableBytesWritable.class, VectorDatum.class, jobConf);
+        ImmutableBytesWritable.class, Vector.class, jobConf);
     MatrixReduce.initJob("xanadu", AdditionReduce.class, jobConf);
 
     jobConf.setNumMapTasks(1);



Mime
View raw message