incubator-hama-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Edward J. Yoon (JIRA)" <j...@apache.org>
Subject [jira] Updated: (HAMA-151) Add multiplication example of file matrices
Date Thu, 12 Feb 2009 03:09:59 GMT

     [ https://issues.apache.org/jira/browse/HAMA-151?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Edward J. Yoon updated HAMA-151:
--------------------------------

    Status: Patch Available  (was: Open)

Submit patch to hudson.

> Add multiplication example of file matrices
> -------------------------------------------
>
>                 Key: HAMA-151
>                 URL: https://issues.apache.org/jira/browse/HAMA-151
>             Project: Hama
>          Issue Type: New Feature
>          Components: documentation , examples
>    Affects Versions: 0.1.0
>            Reporter: Edward J. Yoon
>            Assignee: Edward J. Yoon
>             Fix For: 0.1.0
>
>         Attachments: HAMA-151.patch
>
>
> Using CollectBlocksMap (See also HAMA-150), We can collect the blocks to 'collectionTable'
from HDFS files as describe below.
> It would be nice if it added up the examples.
> -----
>   public static class MyMapper extends CollectBlocksBase implements
>       CollectBlocksMap<IntWritable, MapWritable> {
>     private MapWritable value;
>     @Override
>     public void map(IntWritable key, MapWritable value,
>         OutputCollector<BlockID, VectorWritable> output, Reporter reporter)
>         throws IOException {
>       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(),
>             subVector(startColumn, endColumn)));
>         i++;
>       } while (endColumn < (mColumns - 1));
>     }
>     private DenseVector subVector(int i0, int i1) {
>       DenseVector res = new DenseVector();
>       for (int i = i0; i <= i1; i++) {
>         res.set(i, ((DoubleWritable) this.value.get(new IntWritable(i))).get());
>       }
>       return res;
>     }
>   }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message