hadoop-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alessandro Binhara <binh...@gmail.com>
Subject simple map reduce
Date Thu, 17 Feb 2011 18:47:56 GMT
Helo all..

i create a simple map reduce .. to sum a valeu from a input file like :

key, value
993, 3
993, 2
333, 2

etc .. like this..

public void map(LongWritable key, Text value,
    OutputCollector<Text, IntWritable> output, Reporter reporter)
    throws IOException
    {
 String line = value.toString();
String fields[] = line.split(",");
output.collect(new Text(fields[0]), new
IntWritable(Integer.parseInt(fields[1])));
 }

 public void reduce(Text key, Iterator<IntWritable> values,
OutputCollector<Text, IntWritable> output, Reporter reporter)
      throws IOException
      {
   int maxValue = 0;
   while (values.hasNext()) {
   maxValue +=  values.next().get();
   }
   output.collect(key, new IntWritable(maxValue));
      }


Well.. my question is..

I had a another structure .. of input file
key, value1, value2, value3
993, 3,2,3
993, 2,1,1
333, 2,2,1

How i can sendo to reduce a list of values, ? To process a list numers and
not only one number?
values must be added separately..

thanks for all ..

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message