大数据

标题: Spark MultipleOutputs解决方案 [打印本页]

作者: Zeng    时间: 2016-2-19 11:21
标题: Spark MultipleOutputs解决方案
    在目前Spark版本中,对MultipleOutputs的支持不够到位,不方便将数据集保存到不同路径下。估计大家已经翻阅下面Stackoverflow链接n遍:
    Write to multiple outputs by key Spark - one Spark job
    根据这个链接文档,可以解决好Text File的多路保存,但如果你的需求是生成Sequence File或者Parquet File,这里提供的方法就难以解决,其主要问题在于value数据集难以按记录分开保存为<null   value>格式。
    下面链接对MultipleOutputs问题做了更多的探讨:
    Writing to multiple outputs in Spark

    其实,传统hadoop是可以正常处理文件的多路输出,但要在Spark中使用,需要进行包装。下面链接提供了一个非常好的参考实现,但要根据自己的业务需求进行调整和改进(如果你有疑问,可以回复本帖):
    Wrapping OutputFormat to produce multiple outputs with hadoop MultipleOutputs





欢迎光临 大数据 (http://www.bigbase.cn/) Powered by Discuz! X3.2