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/InterfaceConsiderations

New page:
Let's make Hama interfaces with BDD(Behavior Driven Development) style.

== Flat file to Matrix Conversion ==

We need Input/Output Formatters which convert Text File/Sequence File to Matrix.

For example, 

{{{ 
  public void map(LongWritable key, Text value,
    OutputCollector<ImmutableBytesWritable, VectorWritable> output, Reporter 
reporter)
    throws IOException {
      
    String line = value.toString();

    /* Do something  */

    output.collect(rowKey, vector);
  }

  public void reduce(ImmutableBytesWritable key, Iterator<VectorWritable> 
values,
      OutputCollector<ImmutableBytesWritable, BatchUpdate> output,
      Reporter reporter) throws IOException {

    BatchUpdate batchObj = new BatchUpdate(key.get());
    VectorDatum vector = values.next();
    for (Map.Entry<byte[], Cell> f : vector.entrySet()) {
      batchObj.put(f.getKey(), f.getValue().getValue());
    }

    output.collect(key, batchObj);
  }
}}}

== Matrix Input/Outpu Formatters ==

Reply via email to