Collecting text in output

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Collecting text in output

Anurup Pavuluri


In my Map function I am collecting Text as the output. When I run the
job the job gives a The following code is exactly
what I am doing. Did someone else have a similar problem with Text? It
works for IntWritable instead of Text.

    private Text word = new Text();

    public void map(WritableComparable key, Writable value,
        OutputCollector output,
        Reporter reporter) throws IOException {
        String line = ((Text)value).toString();
        StringTokenizer itr = new StringTokenizer(line);
        for(int i=0; i<3; i++)
        String ipAddress = itr.nextToken();
        ipAddress = ipAddress.trim();
        output.collect(word, word);

  public static class Reduce extends MapReduceBase implements Reducer {

    public void reduce(WritableComparable key, Iterator values,
        OutputCollector output,
        Reporter reporter) throws IOException {
        int sum = 0;
        Text word = new Text();
      while (values.hasNext()) {
        sum += ((IntWritable);
        output.collect(key, word);

-- Anurup Pavuluri Graduate Student Information Networking Institute,
Carnegie Mellon University. E-Mail: [hidden email] Phone: 412
726 7193(M)