GitHub user JoshRosen opened a pull request:

    https://github.com/apache/spark/pull/13505

    [SPARK-15764][SQL] Replace N^2 loop in BindReferences

    BindReferences contains a n^2 loop which causes performance issues when 
operating over large schemas: to determine the ordinal of an attribute 
reference, we perform a linear scan over the `input` array. Because input can 
sometimes be a `List`, the call to `input(ordinal).nullable` can also be O(n).
    
    Instead of performing a linear scan, we can convert the input into an array 
and build a hash map to map from expression ids to ordinals. The greater 
up-front cost of the map construction is offset by the fact that an expression 
can contain multiple attribute references, so the cost of the map construction 
is amortized across a number of lookups.
    
    Perf. benchmarks to follow. /cc @ericl

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/JoshRosen/spark bind-references-improvement

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/spark/pull/13505.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #13505
    
----
commit 6216e944a1aef8dc67a446654c0799c8e9920b4f
Author: Josh Rosen <[email protected]>
Date:   2016-06-04T00:12:16Z

    Replace N^2 loop in BindReferences.

----


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

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

Reply via email to