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 praveenesh kumar <pr...@gmail.com> on 2011/04/25 10:38:55 UTC
Error while compiling the program
Hi,
I am running the following code (Gender.java) on my hadoop .
import java.io.IOException;
import java.util.*;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.conf.*;
import org.apache.hadoop.io.*;
import org.apache.hadoop.mapred.*;
import org.apache.hadoop.util.*;
public class Gender {
private static String genderCheck = "female";
public static class Map extends MapReduceBase implements Mapper {
private final static IntWritable one = new IntWritable(1);
private Text locText = new Text();
public void map(LongWritable key, Text value, OutputCollector
output, Reporter reporter) throws IOException {
String line = value.toString();
String location = line.split(",")[14] + "," +
line.split(",")[15];
long male = 0L;
long female = 0L;
if (line.split(",")[17].matches("\d+") &&
line.split(",")[18].matches("\d+")) {
male = Long.parseLong(line.split(",")[17]);
female = Long.parseLong(line.split(",")[18]);
}
long diff = male - female;
locText.set(location);
if (Gender.genderCheck.toLowerCase().equals("female") && diff <
0) {
output.collect(locText, new LongWritable(diff * -1L));
}
else if (Gender.genderCheck.toLowerCase().equals("male") && diff
> 0) {
output.collect(locText, new
LongWritable(diff));
}
}
}
public static void main(String[] args) throws Exception {
JobConf conf = new JobConf(Gender.class);
conf.setJobName("gender");
conf.setOutputKeyClass(Text.class);
conf.setOutputValueClass(LongWritable.class);
conf.setMapperClass(Map.class);
if (args.length != 3) {
System.out.println("Usage:");
System.out.println("[male/female] /path/to/2kh/files
/path/to/output");
System.exit(1);
}
if (!args[0].equalsIgnoreCase("male") &&
!args[0].equalsIgnoreCase("female")) {
System.out.println("first argument must be male or female");
System.exit(1);
}
Gender.genderCheck = args[0];
conf.setInputFormat(TextInputFormat.class);
conf.setOutputFormat(TextOutputFormat.class);
FileInputFormat.setInputPaths(conf, new Path(args[1]));
FileOutputFormat.setOutputPath(conf, new Path(args[2]));
JobClient.runJob(conf);
}
}
I am getting the following exception while compiling this :
*Gender.java:14: Gender.Map is not abstract and does not override abstract
method
map(java.lang.Object,java.lang.Object,org.apache.hadoop.mapred.OutputCollector,org.apache.hadoop.mapred.Reporter)
in org.apache.hadoop.mapred.Mapper
public static class Map extends MapReduceBase implements Mapper {
^
Note: Gender.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Gender.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
*
Anyone suggest me how to debug this error ??
Re: Error while compiling the program
Posted by praveenesh kumar <pr...@gmail.com>.
Thanks Joey..!!
It compiled..
Regards,
Praveenesh
On Mon, Apr 25, 2011 at 3:47 PM, Joey Echeverria <jo...@cloudera.com> wrote:
> Your delcaration of the Map class needs to include the input and
> output types, e.g.:
>
> public static class Map extends MapReduceBase implements
> Mapper<LongWritable, Text, Text, LongWritable> {
> ...
> }
>
> -Joey
>
> On Mon, Apr 25, 2011 at 4:38 AM, praveenesh kumar <pr...@gmail.com>
> wrote:
> > Hi,
> >
> > I am running the following code (Gender.java) on my hadoop .
> >
> >
> > import java.io.IOException;
> > import java.util.*;
> >
> > import org.apache.hadoop.fs.Path;
> > import org.apache.hadoop.conf.*;
> > import org.apache.hadoop.io.*;
> > import org.apache.hadoop.mapred.*;
> > import org.apache.hadoop.util.*;
> >
> > public class Gender {
> >
> > private static String genderCheck = "female";
> >
> > public static class Map extends MapReduceBase implements Mapper {
> > private final static IntWritable one = new IntWritable(1);
> > private Text locText = new Text();
> >
> > public void map(LongWritable key, Text value, OutputCollector
> > output, Reporter reporter) throws IOException {
> > String line = value.toString();
> > String location = line.split(",")[14] + "," +
> > line.split(",")[15];
> > long male = 0L;
> > long female = 0L;
> > if (line.split(",")[17].matches("\d+") &&
> > line.split(",")[18].matches("\d+")) {
> > male = Long.parseLong(line.split(",")[17]);
> > female = Long.parseLong(line.split(",")[18]);
> > }
> > long diff = male - female;
> > locText.set(location);
> > if (Gender.genderCheck.toLowerCase().equals("female") && diff
> <
> > 0) {
> > output.collect(locText, new LongWritable(diff * -1L));
> > }
> > else if (Gender.genderCheck.toLowerCase().equals("male") &&
> diff
> >> 0) {
> > output.collect(locText, new
> > LongWritable(diff));
> > }
> > }
> > }
> >
> > public static void main(String[] args) throws Exception {
> > JobConf conf = new JobConf(Gender.class);
> > conf.setJobName("gender");
> > conf.setOutputKeyClass(Text.class);
> > conf.setOutputValueClass(LongWritable.class);
> > conf.setMapperClass(Map.class);
> >
> > if (args.length != 3) {
> > System.out.println("Usage:");
> > System.out.println("[male/female] /path/to/2kh/files
> > /path/to/output");
> > System.exit(1);
> > }
> >
> > if (!args[0].equalsIgnoreCase("male") &&
> > !args[0].equalsIgnoreCase("female")) {
> > System.out.println("first argument must be male or female");
> > System.exit(1);
> > }
> > Gender.genderCheck = args[0];
> >
> > conf.setInputFormat(TextInputFormat.class);
> > conf.setOutputFormat(TextOutputFormat.class);
> > FileInputFormat.setInputPaths(conf, new Path(args[1]));
> > FileOutputFormat.setOutputPath(conf, new Path(args[2]));
> > JobClient.runJob(conf);
> > }
> >
> > }
> >
> > I am getting the following exception while compiling this :
> >
> > *Gender.java:14: Gender.Map is not abstract and does not override
> abstract
> > method
> >
> map(java.lang.Object,java.lang.Object,org.apache.hadoop.mapred.OutputCollector,org.apache.hadoop.mapred.Reporter)
> > in org.apache.hadoop.mapred.Mapper
> > public static class Map extends MapReduceBase implements Mapper {
> > ^
> > Note: Gender.java uses or overrides a deprecated API.
> > Note: Recompile with -Xlint:deprecation for details.
> > Note: Gender.java uses unchecked or unsafe operations.
> > Note: Recompile with -Xlint:unchecked for details.
> > *
> > Anyone suggest me how to debug this error ??
> >
>
>
>
> --
> Joseph Echeverria
> Cloudera, Inc.
> 443.305.9434
>
Re: Error while compiling the program
Posted by Joey Echeverria <jo...@cloudera.com>.
Your delcaration of the Map class needs to include the input and
output types, e.g.:
public static class Map extends MapReduceBase implements
Mapper<LongWritable, Text, Text, LongWritable> {
...
}
-Joey
On Mon, Apr 25, 2011 at 4:38 AM, praveenesh kumar <pr...@gmail.com> wrote:
> Hi,
>
> I am running the following code (Gender.java) on my hadoop .
>
>
> import java.io.IOException;
> import java.util.*;
>
> import org.apache.hadoop.fs.Path;
> import org.apache.hadoop.conf.*;
> import org.apache.hadoop.io.*;
> import org.apache.hadoop.mapred.*;
> import org.apache.hadoop.util.*;
>
> public class Gender {
>
> private static String genderCheck = "female";
>
> public static class Map extends MapReduceBase implements Mapper {
> private final static IntWritable one = new IntWritable(1);
> private Text locText = new Text();
>
> public void map(LongWritable key, Text value, OutputCollector
> output, Reporter reporter) throws IOException {
> String line = value.toString();
> String location = line.split(",")[14] + "," +
> line.split(",")[15];
> long male = 0L;
> long female = 0L;
> if (line.split(",")[17].matches("\d+") &&
> line.split(",")[18].matches("\d+")) {
> male = Long.parseLong(line.split(",")[17]);
> female = Long.parseLong(line.split(",")[18]);
> }
> long diff = male - female;
> locText.set(location);
> if (Gender.genderCheck.toLowerCase().equals("female") && diff <
> 0) {
> output.collect(locText, new LongWritable(diff * -1L));
> }
> else if (Gender.genderCheck.toLowerCase().equals("male") && diff
>> 0) {
> output.collect(locText, new
> LongWritable(diff));
> }
> }
> }
>
> public static void main(String[] args) throws Exception {
> JobConf conf = new JobConf(Gender.class);
> conf.setJobName("gender");
> conf.setOutputKeyClass(Text.class);
> conf.setOutputValueClass(LongWritable.class);
> conf.setMapperClass(Map.class);
>
> if (args.length != 3) {
> System.out.println("Usage:");
> System.out.println("[male/female] /path/to/2kh/files
> /path/to/output");
> System.exit(1);
> }
>
> if (!args[0].equalsIgnoreCase("male") &&
> !args[0].equalsIgnoreCase("female")) {
> System.out.println("first argument must be male or female");
> System.exit(1);
> }
> Gender.genderCheck = args[0];
>
> conf.setInputFormat(TextInputFormat.class);
> conf.setOutputFormat(TextOutputFormat.class);
> FileInputFormat.setInputPaths(conf, new Path(args[1]));
> FileOutputFormat.setOutputPath(conf, new Path(args[2]));
> JobClient.runJob(conf);
> }
>
> }
>
> I am getting the following exception while compiling this :
>
> *Gender.java:14: Gender.Map is not abstract and does not override abstract
> method
> map(java.lang.Object,java.lang.Object,org.apache.hadoop.mapred.OutputCollector,org.apache.hadoop.mapred.Reporter)
> in org.apache.hadoop.mapred.Mapper
> public static class Map extends MapReduceBase implements Mapper {
> ^
> Note: Gender.java uses or overrides a deprecated API.
> Note: Recompile with -Xlint:deprecation for details.
> Note: Gender.java uses unchecked or unsafe operations.
> Note: Recompile with -Xlint:unchecked for details.
> *
> Anyone suggest me how to debug this error ??
>
--
Joseph Echeverria
Cloudera, Inc.
443.305.9434