【问题标题】:output apache pig data to file in custom format以自定义格式将 apache pig 数据输出到文件
【发布时间】:2012-07-09 06:22:07
【问题描述】:

我有一个制表符分隔的数据输入,由于数据大小,需要使用 Apache Pig 进行处理。 我已成功加载数据,甚至对其进行了分析,但我想以原始格式将输出存储到文件中,而不是存储元组。

Sample Input
A \t B
A \t B

Sample Output
A \t B
A \t B

而不是(A,B),(A,B)

 Store D into 'output' using PigStorage('\n')

问题出在哪里?

【问题讨论】:

  • 您当前的输出实际上是什么样的?这也应该是 PigStorage 行中的制表符吗?
  • 类似的东西:1,{(A,1),(D,1)} \n 2,{(B,2),(C,2)} 我想得到与输入格式相同。

标签: java hadoop apache-pig


【解决方案1】:

您已加载以制表符分隔的输入,但您正在将其写回 换行 (\n) 分隔。

试试:

Store D into 'output' using PigStorage('\t');

Store D into 'output' using PigStorage(); -- tab is the default delimiter

至于输出的具体格式,我建议你看一下 flatten [1] 操作符。

[1]http://pig.apache.org/docs/r0.7.0/piglatin_ref2.html#Flatten+Operator

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-06-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-05-27
    • 1970-01-01
    相关资源
    最近更新 更多