[ 
https://issues.apache.org/jira/browse/HIVE-21195?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

BELUGA BEHR updated HIVE-21195:
-------------------------------
    Status: Patch Available  (was: Open)

> Review of DefaultGraphWalker Class
> ----------------------------------
>
>                 Key: HIVE-21195
>                 URL: https://issues.apache.org/jira/browse/HIVE-21195
>             Project: Hive
>          Issue Type: Improvement
>    Affects Versions: 4.0.0, 3.2.0
>            Reporter: BELUGA BEHR
>            Assignee: BELUGA BEHR
>            Priority: Minor
>         Attachments: HIVE-21195.1.patch
>
>
> {code:java}
>     protected final List<Node> toWalk = new ArrayList<Node>();
> ...
>     while (toWalk.size() > 0) {
>       Node nd = toWalk.remove(0);
> {code}
> Every time this loop runs, the first item of a list is removed.  For an 
> {{ArrayList}}, this means that every time the first item is removed, all of 
> the remaining items in the list are copied down one position so that the 
> first item is always at array index 0.  This is expensive in a tight loop.  
> Use a {{Queue}} implementation that does not have this behavior. 
> {{ArrayDeque}}
> {quote}
> This class is likely to be faster than Stack when used as a stack, and faster 
> than LinkedList when used as a queue.
> {quote}
> https://docs.oracle.com/javase/7/docs/api/java/util/ArrayDeque.html
> Add a little bit extra cleanup since it's being looked at.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to