hama-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Hama Wiki] Trivial Update of "InterfaceConsiderations" by udanax
Date Thu, 07 Aug 2008 06:56:00 GMT
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 ==

Mime
View raw message