【问题标题】:Error while using gzip codec to compress output from reducer in Hadoop Mapreduce在 Hadoop Mapreduce 中使用 gzip 编解码器压缩来自 reducer 的输出时出错
【发布时间】:2013-10-05 22:35:25
【问题描述】:

我没有在下面粘贴输入、输出、映射器和减速器类。以下是我的主要功能。我正在使用 Hadoop 1.0.4 运行以下代码。在我尝试压缩减速器的输出之前,它工作正常。我将编译错误与代码一起粘贴:

public static void main(String[] args) throws Exception
{
    Configuration conf = new Configuration();

    conf.set("xmlinput.start", "<page>");
    conf.set("xmlinput.end", "</page>");
    Job job = new Job(conf);  //configure the job, submit it, control its execution, and query the state
    job.setJarByClass(XmlParser11.class); //set jar by finding where the class came from
    job.setOutputKeyClass(Text.class); //Set the key class for the job output data
    job.setOutputValueClass(Text.class);

    //job.setCompressMapOutput(true);
    //job.setMapOutputCompressorClass(GzipCodec.class);

    //job.setCompressOutput(job, true);
    //job.setClass("mapred.output.compression.codec", GzipCodec.class,CompressionCodec.class);
    job.setMapperClass(XmlParser11.Map.class);
    job.setReducerClass(XmlParser11.Reduce.class);

    job.setInputFormatClass(XmlInputFormat1.class);  //Set the InputFormat for the job                job.setOutputFormatClass(TextOutputFormat.class); //Set the OutputFormat for the job
    FileOutputFormat.setCompressOutput(job,true);
    FileOutputFormat.setOutputCompressorClass(job,GzipCodec.class);
    FileInputFormat.addInputPath(job, new Path(args[0])); //the job for which the input path should be modified                FileOutputFormat.setOutputPath(job, new Path(args[1]));
    job.waitForCompletion(true);       
}

[ravisg@topsail-sn ~]$ javac -classpath /var/hadoop/hadoop-core-1.0.4.jar -d stopWords/ XmlParser11.java
 XmlParser11.java:306: error: cannot find symbol
        FileOutputFormat.setOutputCompressorClass(job,GzipCodec.class);
                                                      ^
 symbol:   class GzipCodec
 location: class XmlParser11

你能告诉我如何压缩我的减速器的输出,或者你能指出我做错了什么吗?我尝试使用 Stackoverflow 上建议的不同压缩风格,但总是遇到类似的错误。

【问题讨论】:

  • 你可以尝试使用 Hadoop jar 命令运行 jar,即 hadoop jar .
  • @Binary01 - 没有。我收到错误错误:找不到符号 FileOutputFormat.setOutputCompressorClass(job,GzipCodec.class);

标签: java hadoop mapreduce compression gzip


【解决方案1】:

对不起,我只好用了

FileOutputFormat.setOutputCompressorClass(job, org.apache.hadoop.io.compress.GzipCodec.class

而不是

FileOutputFormat.setOutputCompressorClass(job, GzipCodec.class);

【讨论】:

    【解决方案2】:

    编译代码时,您需要将 Hadoop 发行版中的 hadoop-common*jar 添加到类路径中。有问题的 jar 包含 GZipCodec 类

    【讨论】:

    • 我已经将 hadoop-core-1.0.4.jar 添加到 classpath 。我可以在编译代码时向 hadoop-common*jar 添加第二个类路径吗?
    • 您需要将 jars 添加到类路径中,在 Linux 中使用 : 或 s by ;如果你在 Windows 上编译它。这是关于stackoverflow.com/questions/219585/…的问答
    猜你喜欢
    • 2018-08-02
    • 2016-09-10
    • 2021-11-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多