You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by "Denis (JIRA)" <ji...@apache.org> on 2007/07/13 10:35:04 UTC

[jira] Created: (AXIS2-2957) ADB. Time of addition of elements into array proportionally to a factorial!

ADB. Time of addition of elements into array proportionally to a factorial!
---------------------------------------------------------------------------

                 Key: AXIS2-2957
                 URL: https://issues.apache.org/jira/browse/AXIS2-2957
             Project: Axis 2.0 (Axis2)
          Issue Type: Bug
          Components: adb, codegen
    Affects Versions: 1.2
         Environment: Win XP Pro, Tomcat 5.5.20, Eclipse 3.2, Sun JDK 1.5
            Reporter: Denis
            Priority: Critical


The code, generated by ADB for addition of an element to an array, is carried out in time proportional to a factorial from number of added elements.
Also the ADB generates a dirty (bad formatted and without using import statements) code.
The code was generated from Eclipse by wizard "Axis2 code generator".

Small part of WSDL:

            <xs:complexType name="Advertisement">
                <xs:sequence>
                    <xs:element name="id" type="xs:long"/>
                    <xs:element name="placeId" type="xs:int"/>
                    <xs:element name="header" type="xs:string"/>
                    <xs:element name="file" type="xs:string"/>
                    <xs:element minOccurs="0" name="url" type="xs:string"/>
                </xs:sequence>
            </xs:complexType>
            <xs:complexType name="AdvertisementArray">
                <xs:sequence>
                    <xs:element maxOccurs="unbounded" minOccurs="0" name="advertisement"
                        type="data:Advertisement"/>
                </xs:sequence>
            </xs:complexType>
            <xs:complexType name="Packet">
                <xs:sequence>
                    <xs:element name="id" type="xs:string"/>
                    <xs:element minOccurs="0" name="sessionId" type="xs:string"/>
                    <xs:element minOccurs="0" name="advertisements" type="data:AdvertisementArray"/>
                    <xs:element minOccurs="0" name="info" type="xs:string"/>
                </xs:sequence>
            </xs:complexType>
            <xs:element name="packet" type="data:Packet"/>


See an example of a code:

The auto generated by ADB AdvertisementArray.java contains following code:

	 public void addAdvertisement (
			 ru.scanrealty.supplier.deo. SRDAdvertisement param) {
		 if (localAdvertisement == null) {
			 localAdvertisement = new ru.scanrealty.supplier.deo. SRDAdvertisement [] {};
		}

		 // update the setting tracker
		 localAdvertisementTracker = true;

		 java.util. List list = org.apache.axis2.databinding.utils.ConverterUtil
				 .toList (localAdvertisement);
		 list.add (param);
		 this.localAdvertisement = (ru.scanrealty.supplier.deo. SRDAdvertisement []) list
				 .toArray (new ru.scanrealty.supplier.deo. SRDAdvertisement [list
						 .size ()]);

	}

Also org.apache.axis2.databinding.utils.ConverterUtil.java contains following code:

    public static List toList (Object [] array) {
        if (array == null) {
            return new ArrayList ();
       } else {
            ArrayList list = new ArrayList ();
            for (int i = 0; i < array.length; i ++) {
                list.add (array [i]);
           }
            return list;
       }
   }

It's very bad code!

The following code will be carried out in time proportional to a factorial from amount of added elements:

ResultSet rs = < gets result set from DB >
AdvertisementArray advertisements = new AdvertisementArray ();
while (rs.next ()) {
    advertisements.addAdvertisement (createAdvertisement (rs));
}

It occurs because of transformation of an array to the list and copying of elements of an array in a loop in a code ConverterUtil.toList().

In Java the given code should be as:

public class AdvertisementArray
    implements org.apache.axis2.databinding. ADBBean {

          ......
    protected ArrayList <Advertisement> localAdvertisement; // Sequence and repeated elements.

    public Advertisement [] getAdvertisement () {
        ... some checks (also up on null) ...
        return (Advertisement []) localAdvertisement.toArray (new Advertisement [0]);
   }

    public void addAdvertisement (Advertisement el) {
        ... some checks ...
        localAdvertisement.add (el);
   }
    ......
}


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org


[jira] Commented: (AXIS2-2957) ADB. Time of addition of elements into array proportionally to a Sum!

Posted by "Denis (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/AXIS2-2957?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12512606 ] 

Denis commented on AXIS2-2957:
------------------------------

You can do change:
protected ArrayList <Advertisement> localAdvertisement; // Sequence and repeated elements.

on

protected ArrayList  localAdvertisement; // Sequence and repeated elements.

It will be compatibly with Java 1.4
Only remove (change) auto generated code, which copies elements in loop.

> ADB. Time of addition of elements into array proportionally to a Sum!
> ---------------------------------------------------------------------
>
>                 Key: AXIS2-2957
>                 URL: https://issues.apache.org/jira/browse/AXIS2-2957
>             Project: Axis 2.0 (Axis2)
>          Issue Type: Bug
>          Components: adb, codegen
>    Affects Versions: 1.2
>         Environment: Win XP Pro, Tomcat 5.5.20, Eclipse 3.2, Sun JDK 1.5
>            Reporter: Denis
>            Assignee: Amila Chinthaka Suriarachchi
>            Priority: Critical
>         Attachments: adb-codegen-sample-bug-factorial.zip
>
>
> The code, generated by ADB for addition of an element to an array, is carried out in time proportional to a sum from number of added elements.
> Also the ADB generates a dirty (bad formatted and without using import statements) code.
> The code was generated from Eclipse by wizard "Axis2 code generator".
> Small part of WSDL:
>             <xs:complexType name="Advertisement">
>                 <xs:sequence>
>                     <xs:element name="id" type="xs:long"/>
>                     <xs:element name="placeId" type="xs:int"/>
>                     <xs:element name="header" type="xs:string"/>
>                     <xs:element name="file" type="xs:string"/>
>                     <xs:element minOccurs="0" name="url" type="xs:string"/>
>                 </xs:sequence>
>             </xs:complexType>
>             <xs:complexType name="AdvertisementArray">
>                 <xs:sequence>
>                     <xs:element maxOccurs="unbounded" minOccurs="0" name="advertisement"
>                         type="data:Advertisement"/>
>                 </xs:sequence>
>             </xs:complexType>
>             <xs:complexType name="Packet">
>                 <xs:sequence>
>                     <xs:element name="id" type="xs:string"/>
>                     <xs:element minOccurs="0" name="sessionId" type="xs:string"/>
>                     <xs:element minOccurs="0" name="advertisements" type="data:AdvertisementArray"/>
>                     <xs:element minOccurs="0" name="info" type="xs:string"/>
>                 </xs:sequence>
>             </xs:complexType>
>             <xs:element name="packet" type="data:Packet"/>
> See an example of a code:
> The auto generated by ADB AdvertisementArray.java contains following code:
> 	 public void addAdvertisement (
> 			 ru.scanrealty.supplier.deo. SRDAdvertisement param) {
> 		 if (localAdvertisement == null) {
> 			 localAdvertisement = new ru.scanrealty.supplier.deo. SRDAdvertisement [] {};
> 		}
> 		 // update the setting tracker
> 		 localAdvertisementTracker = true;
> 		 java.util. List list = org.apache.axis2.databinding.utils.ConverterUtil
> 				 .toList (localAdvertisement);
> 		 list.add (param);
> 		 this.localAdvertisement = (ru.scanrealty.supplier.deo. SRDAdvertisement []) list
> 				 .toArray (new ru.scanrealty.supplier.deo. SRDAdvertisement [list
> 						 .size ()]);
> 	}
> Also org.apache.axis2.databinding.utils.ConverterUtil.java contains following code:
>     public static List toList (Object [] array) {
>         if (array == null) {
>             return new ArrayList ();
>        } else {
>             ArrayList list = new ArrayList ();
>             for (int i = 0; i < array.length; i ++) {
>                 list.add (array [i]);
>            }
>             return list;
>        }
>    }
> It's very bad code!
> The following code will be carried out in time proportional to a sum from amount of added elements:
> ResultSet rs = < gets result set from DB >
> AdvertisementArray advertisements = new AdvertisementArray ();
> while (rs.next ()) {
>     advertisements.addAdvertisement (createAdvertisement (rs));
> }
> It occurs because of transformation of an array to the list and copying of elements of an array in a loop in a code ConverterUtil.toList().
> In Java the given code should be as:
> public class AdvertisementArray
>     implements org.apache.axis2.databinding. ADBBean {
>           ......
>     protected ArrayList <Advertisement> localAdvertisement; // Sequence and repeated elements.
>     public Advertisement [] getAdvertisement () {
>         ... some checks (also up on null) ...
>         return (Advertisement []) localAdvertisement.toArray (new Advertisement [0]);
>    }
>     public void addAdvertisement (Advertisement el) {
>         ... some checks ...
>         localAdvertisement.add (el);
>    }
>     ......
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org


[jira] Updated: (AXIS2-2957) ADB. Time of addition of elements into array proportionally to a Sum!

Posted by "Davanum Srinivas (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/AXIS2-2957?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Davanum Srinivas updated AXIS2-2957:
------------------------------------

    Assignee: Amila Chinthaka Suriarachchi

> ADB. Time of addition of elements into array proportionally to a Sum!
> ---------------------------------------------------------------------
>
>                 Key: AXIS2-2957
>                 URL: https://issues.apache.org/jira/browse/AXIS2-2957
>             Project: Axis 2.0 (Axis2)
>          Issue Type: Bug
>          Components: adb, codegen
>    Affects Versions: 1.2
>         Environment: Win XP Pro, Tomcat 5.5.20, Eclipse 3.2, Sun JDK 1.5
>            Reporter: Denis
>            Assignee: Amila Chinthaka Suriarachchi
>            Priority: Critical
>         Attachments: adb-codegen-sample-bug-factorial.zip
>
>
> The code, generated by ADB for addition of an element to an array, is carried out in time proportional to a sum from number of added elements.
> Also the ADB generates a dirty (bad formatted and without using import statements) code.
> The code was generated from Eclipse by wizard "Axis2 code generator".
> Small part of WSDL:
>             <xs:complexType name="Advertisement">
>                 <xs:sequence>
>                     <xs:element name="id" type="xs:long"/>
>                     <xs:element name="placeId" type="xs:int"/>
>                     <xs:element name="header" type="xs:string"/>
>                     <xs:element name="file" type="xs:string"/>
>                     <xs:element minOccurs="0" name="url" type="xs:string"/>
>                 </xs:sequence>
>             </xs:complexType>
>             <xs:complexType name="AdvertisementArray">
>                 <xs:sequence>
>                     <xs:element maxOccurs="unbounded" minOccurs="0" name="advertisement"
>                         type="data:Advertisement"/>
>                 </xs:sequence>
>             </xs:complexType>
>             <xs:complexType name="Packet">
>                 <xs:sequence>
>                     <xs:element name="id" type="xs:string"/>
>                     <xs:element minOccurs="0" name="sessionId" type="xs:string"/>
>                     <xs:element minOccurs="0" name="advertisements" type="data:AdvertisementArray"/>
>                     <xs:element minOccurs="0" name="info" type="xs:string"/>
>                 </xs:sequence>
>             </xs:complexType>
>             <xs:element name="packet" type="data:Packet"/>
> See an example of a code:
> The auto generated by ADB AdvertisementArray.java contains following code:
> 	 public void addAdvertisement (
> 			 ru.scanrealty.supplier.deo. SRDAdvertisement param) {
> 		 if (localAdvertisement == null) {
> 			 localAdvertisement = new ru.scanrealty.supplier.deo. SRDAdvertisement [] {};
> 		}
> 		 // update the setting tracker
> 		 localAdvertisementTracker = true;
> 		 java.util. List list = org.apache.axis2.databinding.utils.ConverterUtil
> 				 .toList (localAdvertisement);
> 		 list.add (param);
> 		 this.localAdvertisement = (ru.scanrealty.supplier.deo. SRDAdvertisement []) list
> 				 .toArray (new ru.scanrealty.supplier.deo. SRDAdvertisement [list
> 						 .size ()]);
> 	}
> Also org.apache.axis2.databinding.utils.ConverterUtil.java contains following code:
>     public static List toList (Object [] array) {
>         if (array == null) {
>             return new ArrayList ();
>        } else {
>             ArrayList list = new ArrayList ();
>             for (int i = 0; i < array.length; i ++) {
>                 list.add (array [i]);
>            }
>             return list;
>        }
>    }
> It's very bad code!
> The following code will be carried out in time proportional to a sum from amount of added elements:
> ResultSet rs = < gets result set from DB >
> AdvertisementArray advertisements = new AdvertisementArray ();
> while (rs.next ()) {
>     advertisements.addAdvertisement (createAdvertisement (rs));
> }
> It occurs because of transformation of an array to the list and copying of elements of an array in a loop in a code ConverterUtil.toList().
> In Java the given code should be as:
> public class AdvertisementArray
>     implements org.apache.axis2.databinding. ADBBean {
>           ......
>     protected ArrayList <Advertisement> localAdvertisement; // Sequence and repeated elements.
>     public Advertisement [] getAdvertisement () {
>         ... some checks (also up on null) ...
>         return (Advertisement []) localAdvertisement.toArray (new Advertisement [0]);
>    }
>     public void addAdvertisement (Advertisement el) {
>         ... some checks ...
>         localAdvertisement.add (el);
>    }
>     ......
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org


[jira] Updated: (AXIS2-2957) ADB. Time of addition of elements into array proportionally to a factorial!

Posted by "Denis (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/AXIS2-2957?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Denis updated AXIS2-2957:
-------------------------

    Attachment: adb-codegen-sample-bug-factorial.zip

Sample of code generated from Eclipse 3.2 by wizard "Axis2 Code Generator".

> ADB. Time of addition of elements into array proportionally to a factorial!
> ---------------------------------------------------------------------------
>
>                 Key: AXIS2-2957
>                 URL: https://issues.apache.org/jira/browse/AXIS2-2957
>             Project: Axis 2.0 (Axis2)
>          Issue Type: Bug
>          Components: adb, codegen
>    Affects Versions: 1.2
>         Environment: Win XP Pro, Tomcat 5.5.20, Eclipse 3.2, Sun JDK 1.5
>            Reporter: Denis
>            Priority: Critical
>         Attachments: adb-codegen-sample-bug-factorial.zip
>
>
> The code, generated by ADB for addition of an element to an array, is carried out in time proportional to a factorial from number of added elements.
> Also the ADB generates a dirty (bad formatted and without using import statements) code.
> The code was generated from Eclipse by wizard "Axis2 code generator".
> Small part of WSDL:
>             <xs:complexType name="Advertisement">
>                 <xs:sequence>
>                     <xs:element name="id" type="xs:long"/>
>                     <xs:element name="placeId" type="xs:int"/>
>                     <xs:element name="header" type="xs:string"/>
>                     <xs:element name="file" type="xs:string"/>
>                     <xs:element minOccurs="0" name="url" type="xs:string"/>
>                 </xs:sequence>
>             </xs:complexType>
>             <xs:complexType name="AdvertisementArray">
>                 <xs:sequence>
>                     <xs:element maxOccurs="unbounded" minOccurs="0" name="advertisement"
>                         type="data:Advertisement"/>
>                 </xs:sequence>
>             </xs:complexType>
>             <xs:complexType name="Packet">
>                 <xs:sequence>
>                     <xs:element name="id" type="xs:string"/>
>                     <xs:element minOccurs="0" name="sessionId" type="xs:string"/>
>                     <xs:element minOccurs="0" name="advertisements" type="data:AdvertisementArray"/>
>                     <xs:element minOccurs="0" name="info" type="xs:string"/>
>                 </xs:sequence>
>             </xs:complexType>
>             <xs:element name="packet" type="data:Packet"/>
> See an example of a code:
> The auto generated by ADB AdvertisementArray.java contains following code:
> 	 public void addAdvertisement (
> 			 ru.scanrealty.supplier.deo. SRDAdvertisement param) {
> 		 if (localAdvertisement == null) {
> 			 localAdvertisement = new ru.scanrealty.supplier.deo. SRDAdvertisement [] {};
> 		}
> 		 // update the setting tracker
> 		 localAdvertisementTracker = true;
> 		 java.util. List list = org.apache.axis2.databinding.utils.ConverterUtil
> 				 .toList (localAdvertisement);
> 		 list.add (param);
> 		 this.localAdvertisement = (ru.scanrealty.supplier.deo. SRDAdvertisement []) list
> 				 .toArray (new ru.scanrealty.supplier.deo. SRDAdvertisement [list
> 						 .size ()]);
> 	}
> Also org.apache.axis2.databinding.utils.ConverterUtil.java contains following code:
>     public static List toList (Object [] array) {
>         if (array == null) {
>             return new ArrayList ();
>        } else {
>             ArrayList list = new ArrayList ();
>             for (int i = 0; i < array.length; i ++) {
>                 list.add (array [i]);
>            }
>             return list;
>        }
>    }
> It's very bad code!
> The following code will be carried out in time proportional to a factorial from amount of added elements:
> ResultSet rs = < gets result set from DB >
> AdvertisementArray advertisements = new AdvertisementArray ();
> while (rs.next ()) {
>     advertisements.addAdvertisement (createAdvertisement (rs));
> }
> It occurs because of transformation of an array to the list and copying of elements of an array in a loop in a code ConverterUtil.toList().
> In Java the given code should be as:
> public class AdvertisementArray
>     implements org.apache.axis2.databinding. ADBBean {
>           ......
>     protected ArrayList <Advertisement> localAdvertisement; // Sequence and repeated elements.
>     public Advertisement [] getAdvertisement () {
>         ... some checks (also up on null) ...
>         return (Advertisement []) localAdvertisement.toArray (new Advertisement [0]);
>    }
>     public void addAdvertisement (Advertisement el) {
>         ... some checks ...
>         localAdvertisement.add (el);
>    }
>     ......
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org


[jira] Commented: (AXIS2-2957) ADB. Time of addition of elements into array proportionally to a Sum!

Posted by "Amila Chinthaka Suriarachchi (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/AXIS2-2957?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12512522 ] 

Amila Chinthaka Suriarachchi commented on AXIS2-2957:
-----------------------------------------------------

we have to improve the add element method so that it should avoid list to array conversion. But the way you have suggested use java anotations which is 1.5 specific. but we have to keep this code 1.4 compatible.

> ADB. Time of addition of elements into array proportionally to a Sum!
> ---------------------------------------------------------------------
>
>                 Key: AXIS2-2957
>                 URL: https://issues.apache.org/jira/browse/AXIS2-2957
>             Project: Axis 2.0 (Axis2)
>          Issue Type: Bug
>          Components: adb, codegen
>    Affects Versions: 1.2
>         Environment: Win XP Pro, Tomcat 5.5.20, Eclipse 3.2, Sun JDK 1.5
>            Reporter: Denis
>            Assignee: Amila Chinthaka Suriarachchi
>            Priority: Critical
>         Attachments: adb-codegen-sample-bug-factorial.zip
>
>
> The code, generated by ADB for addition of an element to an array, is carried out in time proportional to a sum from number of added elements.
> Also the ADB generates a dirty (bad formatted and without using import statements) code.
> The code was generated from Eclipse by wizard "Axis2 code generator".
> Small part of WSDL:
>             <xs:complexType name="Advertisement">
>                 <xs:sequence>
>                     <xs:element name="id" type="xs:long"/>
>                     <xs:element name="placeId" type="xs:int"/>
>                     <xs:element name="header" type="xs:string"/>
>                     <xs:element name="file" type="xs:string"/>
>                     <xs:element minOccurs="0" name="url" type="xs:string"/>
>                 </xs:sequence>
>             </xs:complexType>
>             <xs:complexType name="AdvertisementArray">
>                 <xs:sequence>
>                     <xs:element maxOccurs="unbounded" minOccurs="0" name="advertisement"
>                         type="data:Advertisement"/>
>                 </xs:sequence>
>             </xs:complexType>
>             <xs:complexType name="Packet">
>                 <xs:sequence>
>                     <xs:element name="id" type="xs:string"/>
>                     <xs:element minOccurs="0" name="sessionId" type="xs:string"/>
>                     <xs:element minOccurs="0" name="advertisements" type="data:AdvertisementArray"/>
>                     <xs:element minOccurs="0" name="info" type="xs:string"/>
>                 </xs:sequence>
>             </xs:complexType>
>             <xs:element name="packet" type="data:Packet"/>
> See an example of a code:
> The auto generated by ADB AdvertisementArray.java contains following code:
> 	 public void addAdvertisement (
> 			 ru.scanrealty.supplier.deo. SRDAdvertisement param) {
> 		 if (localAdvertisement == null) {
> 			 localAdvertisement = new ru.scanrealty.supplier.deo. SRDAdvertisement [] {};
> 		}
> 		 // update the setting tracker
> 		 localAdvertisementTracker = true;
> 		 java.util. List list = org.apache.axis2.databinding.utils.ConverterUtil
> 				 .toList (localAdvertisement);
> 		 list.add (param);
> 		 this.localAdvertisement = (ru.scanrealty.supplier.deo. SRDAdvertisement []) list
> 				 .toArray (new ru.scanrealty.supplier.deo. SRDAdvertisement [list
> 						 .size ()]);
> 	}
> Also org.apache.axis2.databinding.utils.ConverterUtil.java contains following code:
>     public static List toList (Object [] array) {
>         if (array == null) {
>             return new ArrayList ();
>        } else {
>             ArrayList list = new ArrayList ();
>             for (int i = 0; i < array.length; i ++) {
>                 list.add (array [i]);
>            }
>             return list;
>        }
>    }
> It's very bad code!
> The following code will be carried out in time proportional to a sum from amount of added elements:
> ResultSet rs = < gets result set from DB >
> AdvertisementArray advertisements = new AdvertisementArray ();
> while (rs.next ()) {
>     advertisements.addAdvertisement (createAdvertisement (rs));
> }
> It occurs because of transformation of an array to the list and copying of elements of an array in a loop in a code ConverterUtil.toList().
> In Java the given code should be as:
> public class AdvertisementArray
>     implements org.apache.axis2.databinding. ADBBean {
>           ......
>     protected ArrayList <Advertisement> localAdvertisement; // Sequence and repeated elements.
>     public Advertisement [] getAdvertisement () {
>         ... some checks (also up on null) ...
>         return (Advertisement []) localAdvertisement.toArray (new Advertisement [0]);
>    }
>     public void addAdvertisement (Advertisement el) {
>         ... some checks ...
>         localAdvertisement.add (el);
>    }
>     ......
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org


[jira] Updated: (AXIS2-2957) ADB. Time of addition of elements into array proportionally to a Sum!

Posted by "Denis (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/AXIS2-2957?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Denis updated AXIS2-2957:
-------------------------

    Description: 
The code, generated by ADB for addition of an element to an array, is carried out in time proportional to a sum from number of added elements.
Also the ADB generates a dirty (bad formatted and without using import statements) code.
The code was generated from Eclipse by wizard "Axis2 code generator".

Small part of WSDL:

            <xs:complexType name="Advertisement">
                <xs:sequence>
                    <xs:element name="id" type="xs:long"/>
                    <xs:element name="placeId" type="xs:int"/>
                    <xs:element name="header" type="xs:string"/>
                    <xs:element name="file" type="xs:string"/>
                    <xs:element minOccurs="0" name="url" type="xs:string"/>
                </xs:sequence>
            </xs:complexType>
            <xs:complexType name="AdvertisementArray">
                <xs:sequence>
                    <xs:element maxOccurs="unbounded" minOccurs="0" name="advertisement"
                        type="data:Advertisement"/>
                </xs:sequence>
            </xs:complexType>
            <xs:complexType name="Packet">
                <xs:sequence>
                    <xs:element name="id" type="xs:string"/>
                    <xs:element minOccurs="0" name="sessionId" type="xs:string"/>
                    <xs:element minOccurs="0" name="advertisements" type="data:AdvertisementArray"/>
                    <xs:element minOccurs="0" name="info" type="xs:string"/>
                </xs:sequence>
            </xs:complexType>
            <xs:element name="packet" type="data:Packet"/>


See an example of a code:

The auto generated by ADB AdvertisementArray.java contains following code:

	 public void addAdvertisement (
			 ru.scanrealty.supplier.deo. SRDAdvertisement param) {
		 if (localAdvertisement == null) {
			 localAdvertisement = new ru.scanrealty.supplier.deo. SRDAdvertisement [] {};
		}

		 // update the setting tracker
		 localAdvertisementTracker = true;

		 java.util. List list = org.apache.axis2.databinding.utils.ConverterUtil
				 .toList (localAdvertisement);
		 list.add (param);
		 this.localAdvertisement = (ru.scanrealty.supplier.deo. SRDAdvertisement []) list
				 .toArray (new ru.scanrealty.supplier.deo. SRDAdvertisement [list
						 .size ()]);

	}

Also org.apache.axis2.databinding.utils.ConverterUtil.java contains following code:

    public static List toList (Object [] array) {
        if (array == null) {
            return new ArrayList ();
       } else {
            ArrayList list = new ArrayList ();
            for (int i = 0; i < array.length; i ++) {
                list.add (array [i]);
           }
            return list;
       }
   }

It's very bad code!

The following code will be carried out in time proportional to a sum from amount of added elements:

ResultSet rs = < gets result set from DB >
AdvertisementArray advertisements = new AdvertisementArray ();
while (rs.next ()) {
    advertisements.addAdvertisement (createAdvertisement (rs));
}

It occurs because of transformation of an array to the list and copying of elements of an array in a loop in a code ConverterUtil.toList().

In Java the given code should be as:

public class AdvertisementArray
    implements org.apache.axis2.databinding. ADBBean {

          ......
    protected ArrayList <Advertisement> localAdvertisement; // Sequence and repeated elements.

    public Advertisement [] getAdvertisement () {
        ... some checks (also up on null) ...
        return (Advertisement []) localAdvertisement.toArray (new Advertisement [0]);
   }

    public void addAdvertisement (Advertisement el) {
        ... some checks ...
        localAdvertisement.add (el);
   }
    ......
}


  was:
The code, generated by ADB for addition of an element to an array, is carried out in time proportional to a factorial from number of added elements.
Also the ADB generates a dirty (bad formatted and without using import statements) code.
The code was generated from Eclipse by wizard "Axis2 code generator".

Small part of WSDL:

            <xs:complexType name="Advertisement">
                <xs:sequence>
                    <xs:element name="id" type="xs:long"/>
                    <xs:element name="placeId" type="xs:int"/>
                    <xs:element name="header" type="xs:string"/>
                    <xs:element name="file" type="xs:string"/>
                    <xs:element minOccurs="0" name="url" type="xs:string"/>
                </xs:sequence>
            </xs:complexType>
            <xs:complexType name="AdvertisementArray">
                <xs:sequence>
                    <xs:element maxOccurs="unbounded" minOccurs="0" name="advertisement"
                        type="data:Advertisement"/>
                </xs:sequence>
            </xs:complexType>
            <xs:complexType name="Packet">
                <xs:sequence>
                    <xs:element name="id" type="xs:string"/>
                    <xs:element minOccurs="0" name="sessionId" type="xs:string"/>
                    <xs:element minOccurs="0" name="advertisements" type="data:AdvertisementArray"/>
                    <xs:element minOccurs="0" name="info" type="xs:string"/>
                </xs:sequence>
            </xs:complexType>
            <xs:element name="packet" type="data:Packet"/>


See an example of a code:

The auto generated by ADB AdvertisementArray.java contains following code:

	 public void addAdvertisement (
			 ru.scanrealty.supplier.deo. SRDAdvertisement param) {
		 if (localAdvertisement == null) {
			 localAdvertisement = new ru.scanrealty.supplier.deo. SRDAdvertisement [] {};
		}

		 // update the setting tracker
		 localAdvertisementTracker = true;

		 java.util. List list = org.apache.axis2.databinding.utils.ConverterUtil
				 .toList (localAdvertisement);
		 list.add (param);
		 this.localAdvertisement = (ru.scanrealty.supplier.deo. SRDAdvertisement []) list
				 .toArray (new ru.scanrealty.supplier.deo. SRDAdvertisement [list
						 .size ()]);

	}

Also org.apache.axis2.databinding.utils.ConverterUtil.java contains following code:

    public static List toList (Object [] array) {
        if (array == null) {
            return new ArrayList ();
       } else {
            ArrayList list = new ArrayList ();
            for (int i = 0; i < array.length; i ++) {
                list.add (array [i]);
           }
            return list;
       }
   }

It's very bad code!

The following code will be carried out in time proportional to a factorial from amount of added elements:

ResultSet rs = < gets result set from DB >
AdvertisementArray advertisements = new AdvertisementArray ();
while (rs.next ()) {
    advertisements.addAdvertisement (createAdvertisement (rs));
}

It occurs because of transformation of an array to the list and copying of elements of an array in a loop in a code ConverterUtil.toList().

In Java the given code should be as:

public class AdvertisementArray
    implements org.apache.axis2.databinding. ADBBean {

          ......
    protected ArrayList <Advertisement> localAdvertisement; // Sequence and repeated elements.

    public Advertisement [] getAdvertisement () {
        ... some checks (also up on null) ...
        return (Advertisement []) localAdvertisement.toArray (new Advertisement [0]);
   }

    public void addAdvertisement (Advertisement el) {
        ... some checks ...
        localAdvertisement.add (el);
   }
    ......
}


        Summary: ADB. Time of addition of elements into array proportionally to a Sum!  (was: ADB. Time of addition of elements into array proportionally to a factorial!)

> ADB. Time of addition of elements into array proportionally to a Sum!
> ---------------------------------------------------------------------
>
>                 Key: AXIS2-2957
>                 URL: https://issues.apache.org/jira/browse/AXIS2-2957
>             Project: Axis 2.0 (Axis2)
>          Issue Type: Bug
>          Components: adb, codegen
>    Affects Versions: 1.2
>         Environment: Win XP Pro, Tomcat 5.5.20, Eclipse 3.2, Sun JDK 1.5
>            Reporter: Denis
>            Priority: Critical
>         Attachments: adb-codegen-sample-bug-factorial.zip
>
>
> The code, generated by ADB for addition of an element to an array, is carried out in time proportional to a sum from number of added elements.
> Also the ADB generates a dirty (bad formatted and without using import statements) code.
> The code was generated from Eclipse by wizard "Axis2 code generator".
> Small part of WSDL:
>             <xs:complexType name="Advertisement">
>                 <xs:sequence>
>                     <xs:element name="id" type="xs:long"/>
>                     <xs:element name="placeId" type="xs:int"/>
>                     <xs:element name="header" type="xs:string"/>
>                     <xs:element name="file" type="xs:string"/>
>                     <xs:element minOccurs="0" name="url" type="xs:string"/>
>                 </xs:sequence>
>             </xs:complexType>
>             <xs:complexType name="AdvertisementArray">
>                 <xs:sequence>
>                     <xs:element maxOccurs="unbounded" minOccurs="0" name="advertisement"
>                         type="data:Advertisement"/>
>                 </xs:sequence>
>             </xs:complexType>
>             <xs:complexType name="Packet">
>                 <xs:sequence>
>                     <xs:element name="id" type="xs:string"/>
>                     <xs:element minOccurs="0" name="sessionId" type="xs:string"/>
>                     <xs:element minOccurs="0" name="advertisements" type="data:AdvertisementArray"/>
>                     <xs:element minOccurs="0" name="info" type="xs:string"/>
>                 </xs:sequence>
>             </xs:complexType>
>             <xs:element name="packet" type="data:Packet"/>
> See an example of a code:
> The auto generated by ADB AdvertisementArray.java contains following code:
> 	 public void addAdvertisement (
> 			 ru.scanrealty.supplier.deo. SRDAdvertisement param) {
> 		 if (localAdvertisement == null) {
> 			 localAdvertisement = new ru.scanrealty.supplier.deo. SRDAdvertisement [] {};
> 		}
> 		 // update the setting tracker
> 		 localAdvertisementTracker = true;
> 		 java.util. List list = org.apache.axis2.databinding.utils.ConverterUtil
> 				 .toList (localAdvertisement);
> 		 list.add (param);
> 		 this.localAdvertisement = (ru.scanrealty.supplier.deo. SRDAdvertisement []) list
> 				 .toArray (new ru.scanrealty.supplier.deo. SRDAdvertisement [list
> 						 .size ()]);
> 	}
> Also org.apache.axis2.databinding.utils.ConverterUtil.java contains following code:
>     public static List toList (Object [] array) {
>         if (array == null) {
>             return new ArrayList ();
>        } else {
>             ArrayList list = new ArrayList ();
>             for (int i = 0; i < array.length; i ++) {
>                 list.add (array [i]);
>            }
>             return list;
>        }
>    }
> It's very bad code!
> The following code will be carried out in time proportional to a sum from amount of added elements:
> ResultSet rs = < gets result set from DB >
> AdvertisementArray advertisements = new AdvertisementArray ();
> while (rs.next ()) {
>     advertisements.addAdvertisement (createAdvertisement (rs));
> }
> It occurs because of transformation of an array to the list and copying of elements of an array in a loop in a code ConverterUtil.toList().
> In Java the given code should be as:
> public class AdvertisementArray
>     implements org.apache.axis2.databinding. ADBBean {
>           ......
>     protected ArrayList <Advertisement> localAdvertisement; // Sequence and repeated elements.
>     public Advertisement [] getAdvertisement () {
>         ... some checks (also up on null) ...
>         return (Advertisement []) localAdvertisement.toArray (new Advertisement [0]);
>    }
>     public void addAdvertisement (Advertisement el) {
>         ... some checks ...
>         localAdvertisement.add (el);
>    }
>     ......
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org