[jdom-interest] Patch for org.jdom.contrib.ResultSetBuilder

David Bartle dbartle at whn.com
Tue Dec 12 15:49:55 PST 2000


I have increased the speed of the result set builder by a factor of "alot"

The increase in speed comes from moving the column name requests outside of
the nested for loop and creating a list of column names once instead of
"row number" times.

For one of our tables with 1093 rows and 49 columns this new code yielded
times
of approximately 5.227 seconds for Document build (down from 22.652
seconds).

Here is the diff with no whitespace ignored

------ snip -------
106a107
>
107a109
>         int rowCount = 0;
112c114,127
<         int rowCount = 0;
---
>         // get the column labels for this record set
>         String[] columnLabels = new java.lang.String[colCount];
>
>         for (int index = 0; index < colCount; index++) {
>           columnLabels[index] = new String(rsmd.getColumnName(index+1));
>         }
>
>
>         // build the org.jdom.Document out of the result set
>         Element entry;
>         Element child;
>         String name;
>         String value;
>
114c129,131
<           Element entry = new Element(rowName, ns);
---
>
>           entry = new Element(rowName, ns);
>
116,119c133,135
<             String origName = rsmd.getColumnName(col);
<             String name = lookupName(origName);
<             String value = rs.getString(col);
<             if (isAttribute(origName)) {
---
>             name = lookupName( columnLabels[col-1] );
>             value = rs.getString(col);
>             if ( isAttribute(name) ) {
125c141
<               Element child = new Element(name, ns);
---
>               child = new Element(name, ns);
-------- snip ----------

David Bartle
Developer
Whats Hot Now (whn.com)
david.bartle at whn.com
(310) 754-2685




More information about the jdom-interest mailing list