如果要在Scalding中创建一个包含超过22个字段的管道,则受Scala元组的限制,Scala元组的数量不能超过22个.
有没有办法使用集合而不是元组?我想象下面的例子,遗憾的是它不起作用:
input.read.mapTo('line -> aLotOfFields) { line: String =>
(1 to 24).map(_.toString)
}.write(output)
Run Code Online (Sandbox Code Playgroud)
其实你可以。它在常见问题解答中 - https://github.com/twitter/scalding/wiki/Frequently-asked-questions#what-if-i-have-more-than-22-fields-in-my-data-set
val toFields = (1 to 24).map(f => Symbol("field_" + f)).toList
input
.read
.mapTo('line -> toFields) { line: String =>
new Tuple((1 to 24).map(_.toString).map(_.asInstanceOf[AnyRef]): _*)
}
Run Code Online (Sandbox Code Playgroud)
最后一张地图(_.asInstanceOf[AnyRef])看起来很难看,所以如果您找到更好的解决方案,请告诉我。
| 归档时间: |
|
| 查看次数: |
1758 次 |
| 最近记录: |