[ 
https://issues.apache.org/jira/browse/SPARK-58680?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18103189#comment-18103189
 ] 

Uroš Bojanić commented on SPARK-58680:
--------------------------------------

In progress: https://github.com/apache/spark/pull/57883.

> Use isEmpty/nonEmpty for emptiness checks in ExternalAppendOnlyMap
> ------------------------------------------------------------------
>
>                 Key: SPARK-58680
>                 URL: https://issues.apache.org/jira/browse/SPARK-58680
>             Project: Spark
>          Issue Type: Improvement
>          Components: Spark Core
>    Affects Versions: 4.3.0
>            Reporter: Uroš Bojanić
>            Priority: Major
>              Labels: pull-request-available
>
> Three emptiness checks on ArrayBuffer in ExternalAppendOnlyMap are written as 
> length comparisons: kcPairs.length > 0, pairs.length == 0, and 
> assert(pairs.length > 0). The same file already uses the idiomatic form 
> elsewhere (spilledMaps.isEmpty, mergeHeap.nonEmpty, mergeHeap.isEmpty), as 
> does the sibling ExternalSorter.
> This switches the three sites to isEmpty/nonEmpty for consistency. For 
> ArrayBuffer both forms are O(1) and exactly equivalent, so this is a 
> readability change with no behavior or performance difference.
> The currentMap.size > 0 check in forceSpill is deliberately left alone: 
> AppendOnlyMap is an Iterable rather than a Seq and does not override 
> knownSize, so isEmpty there would fall back to iterator(), which asserts that 
> the map has not been destructively sorted. That check must stay a size 
> comparison.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to