[ https://issues.apache.org/jira/browse/SPARK-15764?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Reynold Xin updated SPARK-15764: -------------------------------- Description: BindReferences contains a n^2 loop which causes performance issues when operating over large schemas: to determine the ordinal of an input, 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. was: BindReferences contains a n^2 loop which causes performance issues when operating over large schemas: to determine the ordinal of an input, 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. > Replace n^2 loop in BindReferences > ---------------------------------- > > Key: SPARK-15764 > URL: https://issues.apache.org/jira/browse/SPARK-15764 > Project: Spark > Issue Type: Sub-task > Components: SQL > Reporter: Josh Rosen > Assignee: Josh Rosen > Fix For: 2.0.0 > > > BindReferences contains a n^2 loop which causes performance issues when > operating over large schemas: to determine the ordinal of an input, 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. -- This message was sent by Atlassian JIRA (v6.3.4#6332) --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@spark.apache.org For additional commands, e-mail: issues-h...@spark.apache.org