写Hadoop程序的时候在Mapper里遇到这个需求,上网查了下,做个记录:
public static class MapClass extends MapReduceBase implements Mapper<Object, Text, IntWritable, Text> { @Override public void map(Object k, Text value, OutputCollector<IntWritable, Text> output, Reporter reporter) throws IOException { // TODO Auto-generated method stub FileSplit fileSplit = (FileSplit) reporter.getInputSplit(); String fileName = fileSplit.getPath().getName(); } }
时间: 2024-11-06 13:17:47