我的烫伤工作看起来像这样:
import com.twitter.scalding。{Args,Csv,Job,TextLine}
class DataJob(args: Args) extends Job(args) {
val input = args("input")
val output = Csv(args("output"), separator = ",")
def parseLine(x: String):Seq[(String, String, String, String)] = {
List(("a", "b", "c", "d")) //Returns a list, not a tuple
}
TextLine(input).mapTo('line -> ('v1, 'v2, 'v3, 'v4)) {
x:String => {
parseLine(x) // this code fails with arity error
}
}.write(Csv(args("output")))
}
运行时,我收到以下错误:
Caused by: java.lang.AssertionError: assertion failed: Arity of (class com.twitter.scalding.LowPriorityTupleSetters$$anon$2) is 1, which doesn't match: + ('v1', 'v2', 'v3', 'v4')
这是因为我的parseLine
函数返回一个元组列表,但代码需要发出一个元组。如何才能使此代码生效?
答案 0 :(得分:0)
好的,看起来我只需要改变:
TextLine(input).mapTo('line -> ('v1, 'v2, 'v3, 'v4))
为:
TextLine(input).flatMap('line -> ('v1, 'v2, 'v3, 'v4))
仍然不清楚为什么,所以任何回复都会受到赞赏!