Github user mgaido91 commented on the issue:

    https://github.com/apache/spark/pull/19860
  
    @viirya sorry, I don't understand your question.
    In Coalesce, we need to find the first non-null element. As soon as we find 
one, we don't need to evaluate anything else. Previously, the code generated by 
coalesce would have been:
    ```
    methodName_1();
    methodName_2();
    ...
    methodName_X();
    ```
    and in each method we were using `${ev.isNull}` to avoid the computation of 
the unnecessary expressions, after the first non-null condition was met.
    In this case, even though we are doing nothing inside these function we are 
still calling all them and this is not cheap, as pointed out by @gatorsmile 
here: https://github.com/apache/spark/pull/19752#discussion_r153081547.
    Thus, in the new generated code, we avoid calling the methods when it is 
not necessary, since the generated code is:
    ```
    do {
      methodName_1();
      if (!isNull_1234) {
        continue;
      }
      ...
    } while (false);
    ```



---

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

Reply via email to