You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hama.apache.org by Apache Wiki <wi...@apache.org> on 2009/02/16 05:36:48 UTC

[Hama Wiki] Trivial Update of "MatMult" by udanax

Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Hama Wiki" for change notification.

The following page has been changed by udanax:
http://wiki.apache.org/hama/MatMult

------------------------------------------------------------------------------
  
      @Override
      public void map(IntWritable key, MapWritable value,
-         OutputCollector<BlockID, VectorWritable> output, Reporter reporter)
+         OutputCollector<BlockID, MapWritable> output, Reporter reporter)
          throws IOException {
+       int startColumn, endColumn, blkRow = key.get() / mBlockRowSize, i = 0;
-       int startColumn;
-       int endColumn;
-       int blkRow = key.get() / mBlockRowSize;
        this.value = value;
+       
- 
-       int i = 0;
        do {
          startColumn = i * mBlockColSize;
          endColumn = startColumn + mBlockColSize - 1;
          if (endColumn >= mColumns) // the last sub vector
            endColumn = mColumns - 1;
-         output.collect(new BlockID(blkRow, i), new VectorWritable(key.get(),
+         output.collect(new BlockID(blkRow, i), subVector(key.get(), startColumn, endColumn));
-             subVector(startColumn, endColumn)));
  
          i++;
        } while (endColumn < (mColumns - 1));
      }
  
-     private DenseVector subVector(int i0, int i1) {
+     private MapWritable subVector(int row, int i0, int i1) {
        DenseVector res = new DenseVector();
+       res.setRow(row);
+       
        for (int i = i0; i <= i1; i++) {
          res.set(i, ((DoubleWritable) this.value.get(new IntWritable(i))).get());
        }
  
-       return res;
+       return res.getEntries();
      }
    }