spark-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chen yong <cy...@hotmail.com>
Subject execution sequence puzzle
Date Sat, 01 Oct 2016 13:35:08 GMT
Hello everybody,

I am puzzled by the execution sequence of the following scala program. Please tell me if 
it  run in the same sequence on your computer,.and it is normal.

Thanks

execution sequence according to line number: 26-7-20-27-9-10-12-13-15-7-20-17-18-9-10-12-13-15-7-20-17-18


1.

import scala.collection.mutable.ArrayBuffer


2.




3.

object TestCase1{


4.




5.

def func(testtttt:Iterator[(Int,Long)]): Iterator[(Int,Long)]={


6.




7.

println("in")


8.

val testtttt1=testtttt.flatmap{


9.

case(item,count)=>


10.

val newPrefix=item


11.




12.

println(count)


13.

val a=Iterator.single((newPrefix,count))


14.




15.

func(a)


16.




17.

val c = a


18.

c


19.

}


20.

testtttt1


21.

}


22.




23.

def main(args: Array[String]){


24.

val freqItems = ArrayBuffer((2,3L),(3,2L),(4,1L))


25.

val testtttt = freqItems.toIterator


26.

val result = func(testtttt)


27.

val reer = result.toArray


28.




29.

}


30.

}


Mime
View raw message