Skip to content

Commit 3858e94

Browse files
sarutakHyukjinKwon
authored andcommitted
[SPARK-30566][BUILD] Iterator doesn't refer outer identifier named "iterator" properly in Scala 2.13
### What changes were proposed in this pull request? Renamed an identifier `iterator` to `iter` to avoid compile error with Scala 2.13. ### Why are the changes needed? As of Scala 2.13, scala.collection.Iterator has "iterator" method so if an inner class of Iterator means to refer an outer identifier named "iterator", it does not work as we think. I listed source files that can be affected by that change by `find . -name "*.scala" -exec grep -El "new .*Iterator\[.* +{" {} \;` As far as I confirmed util.Utils` is affected. ### Does this PR introduce any user-facing change? No. ### How was this patch tested? Existing tests. Closes #27275 from sarutak/fix-iterator-for-2.13. Authored-by: Kousuke Saruta <[email protected]> Signed-off-by: HyukjinKwon <[email protected]>
1 parent 19a1059 commit 3858e94

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

core/src/main/scala/org/apache/spark/util/Utils.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1812,14 +1812,14 @@ private[spark] object Utils extends Logging {
18121812
* Generate a zipWithIndex iterator, avoid index value overflowing problem
18131813
* in scala's zipWithIndex
18141814
*/
1815-
def getIteratorZipWithIndex[T](iterator: Iterator[T], startIndex: Long): Iterator[(T, Long)] = {
1815+
def getIteratorZipWithIndex[T](iter: Iterator[T], startIndex: Long): Iterator[(T, Long)] = {
18161816
new Iterator[(T, Long)] {
18171817
require(startIndex >= 0, "startIndex should be >= 0.")
18181818
var index: Long = startIndex - 1L
1819-
def hasNext: Boolean = iterator.hasNext
1819+
def hasNext: Boolean = iter.hasNext
18201820
def next(): (T, Long) = {
18211821
index += 1L
1822-
(iterator.next(), index)
1822+
(iter.next(), index)
18231823
}
18241824
}
18251825
}

0 commit comments

Comments
 (0)