Github user cloud-fan commented on the pull request: https://github.com/apache/spark/pull/736#issuecomment-42955215 @rxin I'm sorry I didn't got a link for that, but I didn't find any discussion about performance issue of Iterator#size, either. I just checked the source code of Iterator and desugar scala for loop to see what happened. `scala -Xprint:parser -e "var count = 0;for (i <- List(1,2,3).iterator) count += 1"` You can try it yourself, it will be translated into `var count = 0;List(1, 2, 3).iterator.foreach( i => count += 1)` And the Iterator#foreach implementation is `{ while (hasNext) f(next()) }`, it's same with what spark do to calculate the size of iterator. Anyway, get size of an iterator is a basic function, it is logical to let the language lib do it.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---