You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-user@hadoop.apache.org by Chang Hu <ch...@cs.umd.edu> on 2008/03/24 21:22:15 UTC
setMapOutputValueClass doesn't work
Hi,
I have been unsuccessfully trying to set the map output value class
different to the one reduce outputs (in 0.16.0). AFAIK the following should
do the trick:
conf.setMapOutputValueClass(FooWritable.class)
conf.setOutputValueClass(BarWritable.class)
However I kept getting exceptions saying BarWritable is not FooWritable.
Both classes implements WritableComparable.
java.io.IOException: wrong value class: test.BarWritable is not class
test.FooWritable
at org.apache.hadoop.io.SequenceFile$Writer.append(SequenceFile.java
:952)
at org.apache.hadoop.mapred.MapTask$MapOutputBuffer$2.collect(
MapTask.java:489)
at edu.umd.cs.hadoopImage.HadoopImg$InpaintReduceClass.reduce(
HadoopImg.java:122)
at edu.umd.cs.hadoopImage.HadoopImg$InpaintReduceClass.reduce(
HadoopImg.java:1)
at org.apache.hadoop.mapred.MapTask$MapOutputBuffer.combineAndSpill(
MapTask.java:522)
at org.apache.hadoop.mapred.MapTask$MapOutputBuffer.sortAndSpillToDisk(
MapTask.java:493)
at org.apache.hadoop.mapred.MapTask$MapOutputBuffer.flush(MapTask.java
:713)
at org.apache.hadoop.mapred.MapTask.run(MapTask.java:209)
at org.apache.hadoop.mapred.TaskTracker$Child.main(TaskTracker.java
:2071)
Suggestions? Thanks.
- Chang
--
---------------
Überstehen ist alles.
Chang Hu
Ph.D. student
Computer Science Department
University of Maryland
Re: setMapOutputValueClass doesn't work
Posted by Chang Hu <ch...@cs.umd.edu>.
Thanks Riccardo, but that's not the case. I checked and made sure it's
collecting FooWritable. In fact, from the following thread:
http://www.nabble.com/Different-output-classes-from-map-and-reducer-td15728122.html
My exception is the same as if map output value class was not set.
- Chang
On Mon, Mar 24, 2008 at 4:52 PM, Riccardo Boscolo <dr...@netseer.com>
wrote:
> From the exception stack it appears that the map output class is correctly
> set to FooWritable.class but you are trying to collect BarWritable(s) in
> your map tasks.
>
> Best,
>
> RB
>
> On Mon, Mar 24, 2008 at 1:22 PM, Chang Hu <ch...@cs.umd.edu> wrote:
>
> > Hi,
> >
> > I have been unsuccessfully trying to set the map output value class
> > different to the one reduce outputs (in 0.16.0). AFAIK the following
> > should
> > do the trick:
> >
> > conf.setMapOutputValueClass(FooWritable.class)
> > conf.setOutputValueClass(BarWritable.class)
> >
> > However I kept getting exceptions saying BarWritable is not FooWritable.
> > Both classes implements WritableComparable.
> >
> > java.io.IOException: wrong value class: test.BarWritable is not class
> > test.FooWritable
> > at org.apache.hadoop.io.SequenceFile$Writer.append(SequenceFile.java
> > :952)
> > at org.apache.hadoop.mapred.MapTask$MapOutputBuffer$2.collect(
> > MapTask.java:489)
> > at edu.umd.cs.hadoopImage.HadoopImg$InpaintReduceClass.reduce(
> > HadoopImg.java:122)
> > at edu.umd.cs.hadoopImage.HadoopImg$InpaintReduceClass.reduce(
> > HadoopImg.java:1)
> > at org.apache.hadoop.mapred.MapTask$MapOutputBuffer.combineAndSpill(
> > MapTask.java:522)
> > at
> org.apache.hadoop.mapred.MapTask$MapOutputBuffer.sortAndSpillToDisk(
> > MapTask.java:493)
> > at org.apache.hadoop.mapred.MapTask$MapOutputBuffer.flush(
> MapTask.java
> > :713)
> > at org.apache.hadoop.mapred.MapTask.run(MapTask.java:209)
> > at org.apache.hadoop.mapred.TaskTracker$Child.main(TaskTracker.java
> > :2071)
> >
> >
> > Suggestions? Thanks.
> >
> >
> > - Chang
> >
> >
> > --
> > ---------------
> > Überstehen ist alles.
> >
> >
> > Chang Hu
> > Ph.D. student
> > Computer Science Department
> > University of Maryland
> >
>
>
>
> --
> -------------------------------
> Riccardo Boscolo, PhD
> V.P. of Core Technology
> Netseer Inc.
> 11943 Montana Ave, Suite 200
> Los Angeles, CA 90049
> T: 310-597-4482
> F: 310-597-4489
> Email: drboscolo@netseer.com
> -------------------------------
>
--
---------------
Überstehen ist alles.
Chang Hu
Ph.D. student
Computer Science Department
University of Maryland
Re: setMapOutputValueClass doesn't work
Posted by Riccardo Boscolo <dr...@netseer.com>.
>From the exception stack it appears that the map output class is correctly
set to FooWritable.class but you are trying to collect BarWritable(s) in
your map tasks.
Best,
RB
On Mon, Mar 24, 2008 at 1:22 PM, Chang Hu <ch...@cs.umd.edu> wrote:
> Hi,
>
> I have been unsuccessfully trying to set the map output value class
> different to the one reduce outputs (in 0.16.0). AFAIK the following
> should
> do the trick:
>
> conf.setMapOutputValueClass(FooWritable.class)
> conf.setOutputValueClass(BarWritable.class)
>
> However I kept getting exceptions saying BarWritable is not FooWritable.
> Both classes implements WritableComparable.
>
> java.io.IOException: wrong value class: test.BarWritable is not class
> test.FooWritable
> at org.apache.hadoop.io.SequenceFile$Writer.append(SequenceFile.java
> :952)
> at org.apache.hadoop.mapred.MapTask$MapOutputBuffer$2.collect(
> MapTask.java:489)
> at edu.umd.cs.hadoopImage.HadoopImg$InpaintReduceClass.reduce(
> HadoopImg.java:122)
> at edu.umd.cs.hadoopImage.HadoopImg$InpaintReduceClass.reduce(
> HadoopImg.java:1)
> at org.apache.hadoop.mapred.MapTask$MapOutputBuffer.combineAndSpill(
> MapTask.java:522)
> at org.apache.hadoop.mapred.MapTask$MapOutputBuffer.sortAndSpillToDisk(
> MapTask.java:493)
> at org.apache.hadoop.mapred.MapTask$MapOutputBuffer.flush(MapTask.java
> :713)
> at org.apache.hadoop.mapred.MapTask.run(MapTask.java:209)
> at org.apache.hadoop.mapred.TaskTracker$Child.main(TaskTracker.java
> :2071)
>
>
> Suggestions? Thanks.
>
>
> - Chang
>
>
> --
> ---------------
> Überstehen ist alles.
>
>
> Chang Hu
> Ph.D. student
> Computer Science Department
> University of Maryland
>
--
-------------------------------
Riccardo Boscolo, PhD
V.P. of Core Technology
Netseer Inc.
11943 Montana Ave, Suite 200
Los Angeles, CA 90049
T: 310-597-4482
F: 310-597-4489
Email: drboscolo@netseer.com
-------------------------------
Re: setMapOutputValueClass doesn't work
Posted by Chang Hu <ch...@cs.umd.edu>.
Good call. Thank you guys for helping me out. I'll do some experiments on
efficiency later and keep you guys updated.
- Chang
On Mon, Mar 24, 2008 at 6:51 PM, Riccardo Boscolo <dr...@netseer.com>
wrote:
> That's simple, add a combiner that looks exactly like your reducer, but
> collects IntWritable(s) as values. Btw, yours is a very good example,
> because it is often forgotten that the (key,value) class types of
> combiners
> should always match those of mappers.
>
> RB
>
> On Mon, Mar 24, 2008 at 3:42 PM, Chang Hu <ch...@cs.umd.edu> wrote:
>
> > Thanks Doug! I am able to run the job after removing the setConbiner()
> > line. Does it hurt efficiency and how do I add a combiner?
> >
> > - Chang
> >
> > On Mon, Mar 24, 2008 at 6:26 PM, Doug Cutting <cu...@apache.org>
> wrote:
> >
> > > Chang Hu wrote:
> > > > Code below, also attached. I put this together from the word count
> > > > example.
> > >
> > > The problem is with your combiner. When a combiner is specified, it
> > > generates the final map output, since combination is a map-side
> > > operation. Your combiner takes <Text,IntWritable> generated by your
> > > mapper and generates <Text,Text> outputs, which would not be
> acceptable
> > > to your reducer, which accepts <Text,IntWritable> inputs. Does that
> > > make sense?
> > >
> > > Doug
> > >
> >
> >
> >
> > --
> > ---------------
> > Überstehen ist alles.
> >
> >
> > Chang Hu
> > Ph.D. student
> > Computer Science Department
> > University of Maryland
> >
>
>
>
> --
> -------------------------------
> Riccardo Boscolo, PhD
> V.P. of Core Technology
> Netseer Inc.
> 11943 Montana Ave, Suite 200
> Los Angeles, CA 90049
> T: 310-597-4482
> F: 310-597-4489
> Email: drboscolo@netseer.com
> -------------------------------
>
--
---------------
Überstehen ist alles.
Chang Hu
Ph.D. student
Computer Science Department
University of Maryland
Re: setMapOutputValueClass doesn't work
Posted by Riccardo Boscolo <dr...@netseer.com>.
That's simple, add a combiner that looks exactly like your reducer, but
collects IntWritable(s) as values. Btw, yours is a very good example,
because it is often forgotten that the (key,value) class types of combiners
should always match those of mappers.
RB
On Mon, Mar 24, 2008 at 3:42 PM, Chang Hu <ch...@cs.umd.edu> wrote:
> Thanks Doug! I am able to run the job after removing the setConbiner()
> line. Does it hurt efficiency and how do I add a combiner?
>
> - Chang
>
> On Mon, Mar 24, 2008 at 6:26 PM, Doug Cutting <cu...@apache.org> wrote:
>
> > Chang Hu wrote:
> > > Code below, also attached. I put this together from the word count
> > > example.
> >
> > The problem is with your combiner. When a combiner is specified, it
> > generates the final map output, since combination is a map-side
> > operation. Your combiner takes <Text,IntWritable> generated by your
> > mapper and generates <Text,Text> outputs, which would not be acceptable
> > to your reducer, which accepts <Text,IntWritable> inputs. Does that
> > make sense?
> >
> > Doug
> >
>
>
>
> --
> ---------------
> Überstehen ist alles.
>
>
> Chang Hu
> Ph.D. student
> Computer Science Department
> University of Maryland
>
--
-------------------------------
Riccardo Boscolo, PhD
V.P. of Core Technology
Netseer Inc.
11943 Montana Ave, Suite 200
Los Angeles, CA 90049
T: 310-597-4482
F: 310-597-4489
Email: drboscolo@netseer.com
-------------------------------
Re: setMapOutputValueClass doesn't work
Posted by Chang Hu <ch...@cs.umd.edu>.
Thanks Doug! I am able to run the job after removing the setConbiner()
line. Does it hurt efficiency and how do I add a combiner?
- Chang
On Mon, Mar 24, 2008 at 6:26 PM, Doug Cutting <cu...@apache.org> wrote:
> Chang Hu wrote:
> > Code below, also attached. I put this together from the word count
> > example.
>
> The problem is with your combiner. When a combiner is specified, it
> generates the final map output, since combination is a map-side
> operation. Your combiner takes <Text,IntWritable> generated by your
> mapper and generates <Text,Text> outputs, which would not be acceptable
> to your reducer, which accepts <Text,IntWritable> inputs. Does that
> make sense?
>
> Doug
>
--
---------------
Überstehen ist alles.
Chang Hu
Ph.D. student
Computer Science Department
University of Maryland
Re: setMapOutputValueClass doesn't work
Posted by Doug Cutting <cu...@apache.org>.
Chang Hu wrote:
> Code below, also attached. I put this together from the word count
> example.
The problem is with your combiner. When a combiner is specified, it
generates the final map output, since combination is a map-side
operation. Your combiner takes <Text,IntWritable> generated by your
mapper and generates <Text,Text> outputs, which would not be acceptable
to your reducer, which accepts <Text,IntWritable> inputs. Does that
make sense?
Doug
Re: setMapOutputValueClass doesn't work
Posted by Chang Hu <ch...@cs.umd.edu>.
Code below, also attached. I put this together from the word count
example.
package edu.umd.cs.mapreduce;
import java.io.IOException;
import java.util.Iterator;
import java.util.StringTokenizer;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapred.JobClient;
import org.apache.hadoop.mapred.JobConf;
import org.apache.hadoop.mapred.MapReduceBase;
import org.apache.hadoop.mapred.Mapper;
import org.apache.hadoop.mapred.OutputCollector;
import org.apache.hadoop.mapred.Reducer;
import org.apache.hadoop.mapred.Reporter;
import org.apache.hadoop.mapred.RunningJob;
public class PageRankHadoop {
public static class MapClass extends MapReduceBase implements
Mapper<LongWritable, Text, Text, IntWritable> {
private final static IntWritable one = new IntWritable(1);
private Text word = new Text();
public void map(LongWritable key, Text value, OutputCollector<Text,
IntWritable> output, Reporter reporter) throws IOException {
String line = value.toString();
StringTokenizer itr = new StringTokenizer(line);
while (itr.hasMoreTokens()) {
word.set(itr.nextToken());
output.collect(word, one);
}
}
}
public static class ReduceClass extends MapReduceBase implements
Reducer<Text, IntWritable, Text, Text> {
public void reduce(Text key, Iterator<IntWritable> values,
OutputCollector<Text, Text> output, Reporter reporter) throws IOException {
int sum = 0;
while (values.hasNext()) {
sum += values.next().get();
}
// copied from the wordcount example, changed IntWritable to
Text
output.collect(key, new Text(Integer.toString(sum)));
}
}
// dummy constructor
private PageRankHadoop() {
}
public static void main(String[] args) throws IOException, Exception {
// paths
String remotePath = "/users/chang/";
String remoteInputPath = remotePath + "data/";
String remoteOutputPath = remotePath + "output/";
// HACK: single mapper and reducer
int numMapTasks = 1;
int numReduceTasks = 1;
JobConf conf = new JobConf(PageRankHadoop.class);
conf.setJobName("PageRankHadoop");
conf.setNumMapTasks(numMapTasks);
conf.setNumReduceTasks(numReduceTasks);
conf.setInputPath(new Path(remoteInputPath));
conf.setOutputPath(new Path(remoteOutputPath));
conf.setMapOutputKeyClass(Text.class);
conf.setMapOutputValueClass(IntWritable.class);
conf.setOutputKeyClass(Text.class);
conf.setOutputValueClass(Text.class);
conf.setMapperClass(MapClass.class);
conf.setCombinerClass(ReduceClass.class);
conf.setReducerClass(ReduceClass.class);
// remove remote files
FileSystem.get(conf).delete(new Path(remoteOutputPath));
RunningJob job = JobClient.runJob(conf);
}
}
The exception I got is:
08/03/24 17:54:43 INFO mapred.JobClient: Task Id :
task_200803241557_0004_m_000000_0, Status : FAILED
java.io.IOException: wrong value class: org.apache.hadoop.io.Text is not
class org.apache.hadoop.io.IntWritable
at org.apache.hadoop.io.SequenceFile$Writer.append(SequenceFile.java
:952)
at org.apache.hadoop.mapred.MapTask$MapOutputBuffer$2.collect(
MapTask.java:489)
at edu.umd.cs.mapreduce.PageRankHadoop$ReduceClass.reduce(
PageRankHadoop.java:60)
at edu.umd.cs.mapreduce.PageRankHadoop$ReduceClass.reduce(
PageRankHadoop.java:1)
at org.apache.hadoop.mapred.MapTask$MapOutputBuffer.combineAndSpill(
MapTask.java:522)
at org.apache.hadoop.mapred.MapTask$MapOutputBuffer.sortAndSpillToDisk(
MapTask.java:493)
at org.apache.hadoop.mapred.MapTask$MapOutputBuffer.flush(MapTask.java
:713)
at org.apache.hadoop.mapred.MapTask.run(MapTask.java:209)
at org.apache.hadoop.mapred.TaskTracker$Child.main(TaskTracker.java
:2071)
Will post my cluster configuration if necessary.
Thanks,
- Chang
On Mon, Mar 24, 2008 at 5:13 PM, Doug Cutting <cu...@apache.org> wrote:
> Can you produce a simple, standalone example program that fails in this
> way, and post it to the list? Thanks!
>
> Doug
>
--
---------------
Überstehen ist alles.
Chang Hu
Ph.D. student
Computer Science Department
University of Maryland
Re: setMapOutputValueClass doesn't work
Posted by Doug Cutting <cu...@apache.org>.
Can you produce a simple, standalone example program that fails in this
way, and post it to the list? Thanks!
Doug