You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by "Knut Anders Hatlen (JIRA)" <ji...@apache.org> on 2013/02/18 13:35:12 UTC

[jira] [Updated] (DERBY-6075) Use modern collections in impl/sql/compile

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

Knut Anders Hatlen updated DERBY-6075:
--------------------------------------

    Attachment: d6075-1a-CollectNodesVisitor.diff

Here's a first patch (1a) that updates the signature of CollectNodesVisitor.getList() to return List instead of Vector. It also changes the visitor to use an ArrayList instead of a Vector, and reorganizes CNV's constructors so that all the fields can be declared final.

Because of the signature change, many callers had to switch from using Enumerator to Iterator, or from elementAt() to get(). Many callers already used the List interface methods of the Vector class and didn't need any change.

The patch also clarifies the javadoc of the getList() method by stating that it never returns null. This allows us to remove a redundant null check in GenerationClauseNode.findReferencedColumns().

All the regression tests ran cleanly with the patch.
                
> Use modern collections in impl/sql/compile
> ------------------------------------------
>
>                 Key: DERBY-6075
>                 URL: https://issues.apache.org/jira/browse/DERBY-6075
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 10.10.0.0
>            Reporter: Knut Anders Hatlen
>            Assignee: Knut Anders Hatlen
>            Priority: Minor
>         Attachments: d6075-1a-CollectNodesVisitor.diff
>
>
> The code in the org.apache.derby.impl.sql.compile package predates the Java Collections Framework and uses old-style collections like java.util.Vector and java.util.Hashtable. Since the old-style collection classes are used in many method signatures, it's difficult to use modern collection classes when adding new code.
> I suggest we switch to using interfaces (like java.util.List and java.util.Map) instead of specific classes in the signatures, so that we have more flexibility in choosing the right collection class for the job.
> Only changing the signatures would allow us to continue using Vector and Hashtable, since they implement the interfaces. However, I think it would be good to switch to ArrayList and HashMap in a second step. The instances in impl/sql/compile are not shared between threads, so we don't need the synchronization provided by the old-style classes. Switching to unsynchronized classes may make compilation slightly faster.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira