You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2019/03/29 02:06:13 UTC

[GitHub] [spark] eatoncys commented on issue #24238: [SPARK-27320][SQL]Converting seq to array in AggregationIterator to improve its access performance

eatoncys commented on issue #24238: [SPARK-27320][SQL]Converting seq to array in AggregationIterator to improve its access performance
URL: https://github.com/apache/spark/pull/24238#issuecomment-477837590
 
 
   @HyukjinKwon, I constructed a test case that used `for` and `index` to access a list which hive 1000 elements, the result is like below, `calculateWithFor` is 6x faster than `calculateWithIndex`
   
   calculateWithIndex cost: 6813710 ns
   calculateWithFor    cost: 1257866 ns
   
   
   `def calculateWithFor(in: Seq[Int]): Array[Int] = {
       val result = new Array[Int](in.length)
       var i: Int = 0
       for (x <- in) {
         result(i) = x
         i = i + 1
       }
       result
     }
   
     def calculateWithIndex(in: Seq[Int]): Array[Int] = {
       val result = new Array[Int](in.length)
       val length = in.length
       var i: Int = 0
       while(i < length) {
         result(i) = in(i)
         i = i + 1
       }
       result
     }`

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org