2017-09-07 42 views
1

我刚开始学习Hadoop,并且有各种格式的输入类型。我有几个程序要研究,我的主要问题是如何确定输入格式是TextInputFormat还是KeyValueTextInputFormat或其他。 你的帮助是非常赞赏如何识别MapReduce程序中的输入格式

回答

1

您不必识别InputFormat正在使用MapReduce的程序

InputFormat是你可以明确地在程序中指定的东西,MapReduce作业将使用它。

如果您不指定任何内容,它将使用默认值,它将扩展FileInputFormat<LongWritable, Key>。这就是为什么在一个简单的单词计数程序,你会经常看到Mapper类定义为:

public class MyMapper extends Mapper<LongWritable, Key, Text, IntWritable> { 
    //... 
} 

您可以指定InputFormat在JobConf对象使用:

JobConf job = new JobConf(new Configuration(), MyJob.class); 

job.setInputFormat(SequenceFileInputFormat.class); 
job.setOutputFormat(SequenceFileOutputFormat.class); 

链接:InputFormat.class进一步读。