为什么Map方法会引发错误?但是它用println显示值

时间:2019-06-03 02:19:18

标签: scala-collections

1,2013-07-25 00:00:00.0,11599,CLOSED
2,2013-07-25 00:00:00.0,256,PENDING_PAYMENT
3,2013-07-25 00:00:00.0,12111,COMPLETE
4,2013-07-25 00:00:00.0,8827,CLOSED
5,2013-07-25 00:00:00.0,11318,COMPLETE
6,2013-07-25 00:00:00.0,7130,COMPLETE
7,2013-07-25 00:00:00.0,4530,COMPLETE
8,2013-07-25 00:00:00.0,2911,PROCESSING
9,2013-07-25 00:00:00.0,5657,PENDING_PAYMENT
10,2013-07-25 00:00:00.0,5648,PENDING_PAYMENT
11,2013-07-25 00:00:00.0,918,PAYMENT_REVIEW
12,2013-07-25 00:00:00.0,1837,CLOSED
13,2013-07-25 00:00:00.0,9149,PENDING_PAYMENT
14,2013-07-25 00:00:00.0,9842,PROCESSING

Data file

val order = sc.textFile(“ / home / project / sf_data-master / retail_db / orders / part-00000”)

val order1 = order.map(x =>(x.split(“,”)(3).toString,x.split(“,”)(2).toInt))

val order1 = order.map(x =>(x.split(“,”)(3).toString,x.split(“,”)(2).toInt))。foreach(println)

val Totord = order1.reduceByKey((tot,value)=> tot + value) println(Totord)

//我想按COMPLETE,PROCESSING ...........

来计算所有订单(最后第二列)的总和。

//第二条语句(val order1)显示了一些错误/信息,例如[Ljava.lang.String; @ c3177d5

//但是当包含println时,order1给出了result.3rd语句。

0 个答案:

没有答案