【问题标题】:How can I identify the Input Formats in MapReduce Program如何识别 MapReduce 程序中的输入格式
【发布时间】:2017-09-07 22:47:09
【问题描述】:

我刚开始学习 Hadoop,输入类型有多种格式。我几乎没有要学习的程序,我的主要问题是如何确定输入格式是 TextInputFormat 还是 KeyValueTextInputFormat 或任何其他格式。 非常感谢您的帮助

【问题讨论】:

    标签: hadoop mapreduce hadoop2 mapr


    【解决方案1】:

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

    InputFormat 是您可以在程序中明确指定的内容,MapReduce 作业将使用它。

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

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

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

    JobConf job = new JobConf(new Configuration(), MyJob.class);
    
    job.setInputFormat(SequenceFileInputFormat.class);
    job.setOutputFormat(SequenceFileOutputFormat.class);
    

    链接至:InputFormat.class 以供进一步阅读。

    【讨论】:

      猜你喜欢
      • 2014-05-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-10-05
      • 1970-01-01
      • 1970-01-01
      • 2015-08-31
      • 2014-12-06
      相关资源
      最近更新 更多