如何在MapReduce作业中以拼花文件格式编写输出?

问题描述 投票:0回答:1

我希望使用parquet-mr库在镶木地板文件格式中编写MapReduce输出,如下所示:

        job.setInputFormatClass(TextInputFormat.class); 
        job.setOutputFormatClass(ParquetOutputFormat.class);

        FileInputFormat.addInputPath(job, new Path(args[1]));
        ParquetOutputFormat.setOutputPath(job, new Path(args[2]));
        ParquetOutputFormat.setCompression(job, CompressionCodecName.GZIP);


        SkipBadRecords.setMapperMaxSkipRecords(conf, Long.MAX_VALUE);
        SkipBadRecords.setAttemptsToStartSkipping(conf, 0);

        job.submit();

但是,我不断收到这样的错误:

2018-02-23 09:32:58,325 WARN [main] org.apache.hadoop.mapred.YarnChild: Exception running child : java.lang.NullPointerException: writeSupportClass should not be null
    at org.apache.parquet.Preconditions.checkNotNull(Preconditions.java:38)
    at org.apache.parquet.hadoop.ParquetOutputFormat.getWriteSupport(ParquetOutputFormat.java:350)
    at org.apache.parquet.hadoop.ParquetOutputFormat.getRecordWriter(ParquetOutputFormat.java:293)
    at org.apache.parquet.hadoop.ParquetOutputFormat.getRecordWriter(ParquetOutputFormat.java:283)
    at org.apache.hadoop.mapred.ReduceTask$NewTrackingRecordWriter.<init>(ReduceTask.java:548)
    at org.apache.hadoop.mapred.ReduceTask.runNewReducer(ReduceTask.java:622)
    at org.apache.hadoop.mapred.ReduceTask.run(ReduceTask.java:390)
    at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:164)

我知道writeSupportClass需要传递/设置为类似的东西

ParquetOutputFormat.setWriteSupportClass(job, ProtoWriteSupport.class);

但我可以问如何指定架构,实现ProtoWriteSupport或任何其他WriteSupport类吗?我需要实现哪些方法,是否有任何以正确方式执行此操作的示例?

如果有帮助,我的MR工作的输出应该看起来像是以镶木地板的形式存储:

Text      INTWRITABLE
 a            100 
hadoop mapreduce parquet file-format
1个回答
0
投票

试试ParquetOutputFormat.setWriteSupportClass(job, ProtoWriteSupport.class);

ProtoWriteSupport<T extends MessageOrBuilder>

用于编写协议缓冲区的WriteSupport的实现。

检查Javadoc以获取可用的嵌套默认类列表。

CDH Tutorial使用镶木地板文件格式与MapReduce,Hive,HBase和Pig。

© www.soinside.com 2019 - 2024. All rights reserved.