You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hive.apache.org by "BELUGA BEHR (JIRA)" <ji...@apache.org> on 2019/01/31 22:58:00 UTC

[jira] [Assigned] (HIVE-21195) Review of DefaultGraphWalker Class

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

BELUGA BEHR reassigned HIVE-21195:
----------------------------------

    Assignee: BELUGA BEHR

> 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
>
> {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)