<p>package selfname;</p>
import java.io.IOException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.Text;
//import org.apache.hadoop.mapreduce.lib.input.CombineFileInputFormat;
//import org.apache.hadoop.mapreduce.lib.input.MultipleTextOutputFormat;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.Mapper;
import org.apache.hadoop.mapreduce.Reducer;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import org.apache.hadoop.mapreduce.lib.output.MultipleOutputs;
public class Selfname {
public static class FileMap extends Mapper<Object,Text,Text,Text>{
public void map(Object key,Text value,Context context) throws IOException, InterruptedException{
String line = value.toString();
if(line.length()>=93){
String keys = line.substring(15, 19);
String values = line.substring(87,93);
context.write(new Text(keys), new Text(values));
}
}
}
public static class FileReduce extends Reducer<Text,Text,Text,Text>{
<strong>private MultipleOutputs<Text, Text> multipleOutputs;
protected void setup(Context context)throws IOException, InterruptedException {
multipleOutputs = new MultipleOutputs<Text, Text>(context);
}</strong>
public void reduce(Text key,Iterable<Text>values,Context context) throws IOException, InterruptedException{
String value = new String();
for(Text val:values){
value+=val.toString()+",";
}
<strong>multipleOutputs.write(key, new Text(value), key.toString());</strong>
}
<strong>protected void cleanup(Context context)throws IOException, InterruptedException {
multipleOutputs.close();
}</strong>
}
public static void main(String[] args) throws IOException, ClassNotFoundException, InterruptedException{
Configuration conf = new Configuration();
Job job = new Job(conf,"myfile");
job.setJarByClass(Selfname.class);
job.setMapperClass(FileMap.class);
job.setReducerClass(FileReduce.class);
job.setOutputKeyClass(Text.class);
job.setOutputValueClass(Text.class);
job.setNumReduceTasks(1);
FileInputFormat.addInputPath(job, new Path(args[0]));
FileOutputFormat.setOutputPath(job, new Path(args[1]));
System.exit(job.waitForCompletion(true)?0:1);
}
}
<p>package selfname;</p>
import java.io.IOExcepti