public static class MapClass extends Mapper<LongWritable,Text,IntPair,IntWritable>{ private final IntPair inkey=new IntPair(); private final IntWritable invalue=new IntWritable(); @Override protected void map(LongWritable Key, Text Value, Context context) throws IOException, InterruptedException { StringTokenizer itr=new StringTokenizer(invalue.toString()); int left=0; int right=0; if(itr.hasMoreTokens()){ left=Integer.parseInt(itr.nextToken()); if(itr.hasMoreTokens()){ right=Integer.parseInt(itr.nextToken()); } inkey.set(left, right); invalue.set(right); context.write(inkey, invalue); } } public static class ReduceClass extends Reducer<IntPair,IntWritable,Text,IntWritable>{ private final Text SEPARATOR=new Text("--------------------------------------"); private final Text first=new Text(); @Override protected void reduce(IntPair key, Iterable<IntWritable> values, Context context) throws IOException, InterruptedException { context.write(SEPARATOR, null); first.set(Integer.toString(key.getFirst())); for(IntWritable value:values){ context.write(first, value); } } } 楼主上面放到函数的含义是什么? 能否放到里面 |