Return-Path: X-Original-To: apmail-hadoop-common-user-archive@www.apache.org Delivered-To: apmail-hadoop-common-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 761EB71D2 for ; Wed, 3 Aug 2011 12:00:18 +0000 (UTC) Received: (qmail 22462 invoked by uid 500); 3 Aug 2011 12:00:14 -0000 Delivered-To: apmail-hadoop-common-user-archive@hadoop.apache.org Received: (qmail 22147 invoked by uid 500); 3 Aug 2011 12:00:09 -0000 Mailing-List: contact common-user-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: common-user@hadoop.apache.org Delivered-To: mailing list common-user@hadoop.apache.org Received: (qmail 22127 invoked by uid 99); 3 Aug 2011 12:00:08 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Aug 2011 12:00:08 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of phatak.dev@gmail.com designates 209.85.161.48 as permitted sender) Received: from [209.85.161.48] (HELO mail-fx0-f48.google.com) (209.85.161.48) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Aug 2011 12:00:03 +0000 Received: by fxg7 with SMTP id 7so1342489fxg.35 for ; Wed, 03 Aug 2011 04:59:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=RDXoCuS1gMRBKqWdDj5d4H7Cix+ObIZWQ5n+KzOCTco=; b=o0Uo/5+Pk5ajIwVdWPatf4TKnqbJNuLK6firkpLXjtWBFYH56sE8WIwv8lZEmnF7fx hC86vtlx9izmJRgaGn0fW1rX1KcL+DMZOzPTPP85O7HqOWL1I9DZCSH2HrXRaCu26oLl 2SEQQq7TUi2rrP4DQPp8SGw/8EYHERgCoj9aM= MIME-Version: 1.0 Received: by 10.223.72.80 with SMTP id l16mr1122408faj.33.1312372781332; Wed, 03 Aug 2011 04:59:41 -0700 (PDT) Received: by 10.223.149.145 with HTTP; Wed, 3 Aug 2011 04:59:41 -0700 (PDT) In-Reply-To: References: <13a48a3f.ccf0.1317656b924.Coremail.hadoop_wu@163.com> <7dfb7ce4.d830.1317806f35c.Coremail.hadoop_wu@163.com> Date: Wed, 3 Aug 2011 17:29:41 +0530 Message-ID: Subject: Re: Re: error:Type mismatch in value from map From: madhu phatak To: common-user@hadoop.apache.org Content-Type: multipart/alternative; boundary=0015174a0b3871bb5f04a998992b --0015174a0b3871bb5f04a998992b Content-Type: text/plain; charset=ISO-8859-1 Sorry for earlier reply . Is your combiner outputting the Text,Text key/value pairs? On Wed, Aug 3, 2011 at 5:26 PM, madhu phatak wrote: > It should. Whats the input value class for reducer you are setting in Job? > > 2011/7/30 Daniel,Wu > > Thanks Joey, >> >> It works, but one place I don't understand: >> >> 1: in the map >> >> extends Mapper >> so the output value is of type IntWritable >> 2: in the reduce >> extends Reducer >> So input value is of type Text. >> >> type of map output should be the same as input type of reduce, correct? >> but here >> IntWritable<>Text >> >> And the code can run without any error, shouldn't it complain type >> mismatch? >> >> At 2011-07-29 22:49:31,"Joey Echeverria" wrote: >> >If you want to use a combiner, your map has to output the same types >> >as your combiner outputs. In your case, modify your map to look like >> >this: >> > >> > public static class TokenizerMapper >> > extends Mapper{ >> > public void map(Text key, Text value, Context context >> > ) throws IOException, InterruptedException { >> > context.write(key, new IntWritable(1)); >> > } >> > } >> > >> >> 11/07/29 22:22:22 INFO mapred.JobClient: Task Id : >> attempt_201107292131_0011_m_000000_2, Status : FAILED >> >> java.io.IOException: Type mismatch in value from map: expected >> org.apache.hadoop.io.IntWritable, recieved org.apache.hadoop.io.Text >> >> >> >> But I already set IntWritable in 2 places, >> >> 1: Reducer >> >> 2:job.setOutputValueClass(IntWritable.class); >> >> >> >> So where am I wrong? >> >> >> >> public class MyTest { >> >> >> >> public static class TokenizerMapper >> >> extends Mapper{ >> >> public void map(Text key, Text value, Context context >> >> ) throws IOException, InterruptedException { >> >> context.write(key, value); >> >> } >> >> } >> >> >> >> public static class IntSumReducer >> >> extends Reducer { >> >> >> >> public void reduce(Text key, Iterable values, >> >> Context context >> >> ) throws IOException, InterruptedException { >> >> int count = 0; >> >> for (Text iw:values) { >> >> count++; >> >> } >> >> context.write(key, new IntWritable(count)); >> >> } >> >> } >> >> >> >> public static void main(String[] args) throws Exception { >> >> Configuration conf = new Configuration(); >> >> // the configure of seprator should be done in conf >> >> conf.set("key.value.separator.in.input.line", ","); >> >> String[] otherArgs = new GenericOptionsParser(conf, >> args).getRemainingArgs(); >> >> if (otherArgs.length != 2) { >> >> System.err.println("Usage: wordcount "); >> >> System.exit(2); >> >> } >> >> Job job = new Job(conf, "word count"); >> >> job.setJarByClass(WordCount.class); >> >> job.setMapperClass(TokenizerMapper.class); >> >> job.setCombinerClass(IntSumReducer.class); >> >> // job.setReducerClass(IntSumReducer.class); >> >> job.setInputFormatClass(KeyValueTextInputFormat.class); >> >> // job.set("key.value.separator.in.input.line", ","); >> >> job.setOutputKeyClass(Text.class); >> >> job.setOutputValueClass(IntWritable.class); >> >> FileInputFormat.addInputPath(job, new Path(otherArgs[0])); >> >> FileOutputFormat.setOutputPath(job, new Path(otherArgs[1])); >> >> System.exit(job.waitForCompletion(true) ? 0 : 1); >> >> } >> >> } >> >> >> > >> > >> > >> >-- >> >Joseph Echeverria >> >Cloudera, Inc. >> >443.305.9434 >> > > > > -- > Join me at http://hadoopworkshop.eventbrite.com/ > -- Join me at http://hadoopworkshop.eventbrite.com/ --0015174a0b3871bb5f04a998992b--