db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r595178 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/oe: client/Display.java direct/Standard.java model/Customer.java model/District.java model/Order.java model/Warehouse.java
Date Thu, 15 Nov 2007 01:37:22 GMT
Author: djd
Date: Wed Nov 14 17:37:21 2007
New Revision: 595178

URL: http://svn.apache.org/viewvc?rev=595178&view=rev
Log:
Re-use data model objects in the order entry standard transaction implementations to reduce
garbage collection effects introduced by the application (since this framework is intended
to test Derby's performance)

Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/oe/client/Display.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/oe/direct/Standard.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/oe/model/Customer.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/oe/model/District.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/oe/model/Order.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/oe/model/Warehouse.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/oe/client/Display.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/oe/client/Display.java?rev=595178&r1=595177&r2=595178&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/oe/client/Display.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/oe/client/Display.java
Wed Nov 14 17:37:21 2007
@@ -36,6 +36,9 @@
  * Objects passed in from the data model (Customer etc.) may not
  * be fully populated, but they will contain all the information
  * required for that specific operation.
+ * <BR>
+ * Any display method must not retain references to any objects
+ * it is passed, the caller may be re-using the objects across transactions.
  * <P>
  * DECIMAL values are represented as String objects to allow
  * Order Entry to be run on J2ME/CDC/Foundation which does

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/oe/direct/Standard.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/oe/direct/Standard.java?rev=595178&r1=595177&r2=595178&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/oe/direct/Standard.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/oe/direct/Standard.java
Wed Nov 14 17:37:21 2007
@@ -52,10 +52,31 @@
  * <P>
  * More specific direct (client side) implementations
  * could extend this class overriding methods as needed.
+ * <P>
+ * Object is single threaded so it re-uses objects
+ * where possible to avoid the garbage collection
+ * due to the application affecting the results
+ * too much since the purpose of the framework
+ * is to test Derby's performance.
  */
 public class Standard implements Operations {
     
     private final Connection conn;
+    
+    /*
+     * Objects for re-use within the transactions
+     */
+    
+    private final Customer customer = new Customer();
+    
+    private final Warehouse warehouse = new Warehouse();
+    
+    private final District district = new District();
+    
+    private final Order order = new Order();
+    
+    private final List nameList = new ArrayList();
+
 
     /**
      * Create an instance of this implementation.
@@ -207,7 +228,7 @@
             osCustomerByName.setString(3, customerLast);
             ResultSet rs = osCustomerByName.executeQuery();
 
-            List list = new ArrayList();
+            nameList.clear();
             while (rs.next())
             {
                 Customer customer = new Customer();
@@ -220,23 +241,23 @@
                 customer.setFirst(rs.getString("C_FIRST"));
                 customer.setMiddle(rs.getString("C_MIDDLE"));
                 
-                list.add(customer);
+                nameList.add(customer);
             }
             reset(osCustomerByName);
-            if (list.isEmpty())
+            if (nameList.isEmpty())
                 throw new SQLException("Order Status by name - no matching customer "
                         + customerLast);
             
             // Customer to use is midpoint (with round up) (see 2.6.2.2)
-            int mid = list.size()/2;
+            int mid = nameList.size()/2;
             if (mid != 0) {
-                if (list.size()%2 == 1)
+                if (nameList.size()%2 == 1)
                     mid++;
             }
 
 
-            Customer customer = (Customer) list.get(mid);
-            list = null;
+            Customer customer = (Customer) nameList.get(mid);
+            nameList.clear();
             
             getOrderStatusForCustomer(display, displayData, true, customer);
         } catch (SQLException e) {
@@ -256,7 +277,7 @@
                 "SELECT C_BALANCE, C_FIRST, C_MIDDLE, C_LAST " +
                 "FROM CUSTOMER WHERE C_W_ID = ? AND C_D_ID = ? AND C_ID = ?");
         
-        Customer customer = new Customer();
+        customer.clear();
         customer.setWarehouse(w);
         customer.setDistrict(d);
         customer.setId(c);
@@ -299,7 +320,7 @@
                 "OL_DELIVERY_D FROM ORDERLINE " +
                 "WHERE OL_W_ID = ? AND OL_D_ID = ? AND OL_O_ID = ?");
         
-        Order order = new Order();
+        order.clear();
         order.setWarehouse(customer.getWarehouse());
         order.setDistrict(customer.getDistrict());
         
@@ -376,24 +397,24 @@
             pyCustomerByName.setString(3, customerLast);
             ResultSet rs = pyCustomerByName.executeQuery();
 
-            List list = new ArrayList();
+            nameList.clear();
             while (rs.next())
             {           
-                list.add(rs.getObject("C_ID"));            
+                nameList.add(rs.getObject("C_ID"));            
             }
             reset(pyCustomerByName);
-            if (list.isEmpty())
+            if (nameList.isEmpty())
                 throw new SQLException("Payment by name - no matching customer "
                         + customerLast);
             
             // Customer to use is midpoint (with round up) (see 2.5.2.2)
-            int mid = list.size()/2;
+            int mid = nameList.size()/2;
             if (mid != 0) {
-                if (list.size()%2 == 1)
+                if (nameList.size()%2 == 1)
                     mid++;
             }
             
-            int c = ((Integer) list.get(mid)).intValue();
+            int c = ((Integer) nameList.get(mid)).intValue();
 
             paymentById(display, displayData, w, d, cw, cd, c, amount);
         } catch (SQLException e) {
@@ -521,7 +542,7 @@
             reset(pyCustomerGetData);
         }
 
-        District district = new District();
+        district.clear();
         district.setWarehouse(w);
         district.setId(d);
 
@@ -541,7 +562,7 @@
         district.setAddress(getAddress(rs, "D_STREET_1"));
         reset(pyDistrictInfo);        
         
-        Warehouse warehouse = new Warehouse();
+        warehouse.clear();
         warehouse.setId(w);
         
         // Update WAREHOUSE

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/oe/model/Customer.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/oe/model/Customer.java?rev=595178&r1=595177&r2=595178&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/oe/model/Customer.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/oe/model/Customer.java
Wed Nov 14 17:37:21 2007
@@ -69,6 +69,24 @@
     private int payment_cnt;
     private int delivery_cnt;
     private String data;
+    
+    /**
+     * Clear all information to allow object re-use.
+     */
+    public void clear()
+    {
+        warehouse = district = 0;
+        id = 0;     
+        first = middle = last = null;
+        address = null;     
+        phone = null;       
+        since = null;       
+        credit = credit_lim = discount = null;      
+        ytd_payment = null;     
+        payment_cnt = delivery_cnt = 0; 
+        data = null;
+    }
+    
     public Address getAddress() {
         return address;
     }

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/oe/model/District.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/oe/model/District.java?rev=595178&r1=595177&r2=595178&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/oe/model/District.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/oe/model/District.java
Wed Nov 14 17:37:21 2007
@@ -49,6 +49,16 @@
  */
 public class District extends Warehouse {
     private short warehouse;
+    
+    /**
+     * Clear all information to allow object re-use.
+     */
+    public void clear()
+    {
+        super.clear();
+        warehouse = 0;
+    }
+
 
     public short getWarehouse() {
         return warehouse;

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/oe/model/Order.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/oe/model/Order.java?rev=595178&r1=595177&r2=595178&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/oe/model/Order.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/oe/model/Order.java Wed
Nov 14 17:37:21 2007
@@ -54,6 +54,20 @@
     private Integer carrier_id; // JDBC maps SMALLINT to java.lang.Integer
     private int ol_cnt;
     private boolean all_local;
+    
+    /**
+     * Clear all information to allow object re-use.
+     */
+    public void clear()
+    {
+        id = 0;
+        district = warehouse = 0;
+        customer = 0;
+        entry_d = null;
+        carrier_id = null;
+        ol_cnt = 0;
+        all_local = false;
+    }
 
     public boolean isAll_local() {
         return all_local;

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/oe/model/Warehouse.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/oe/model/Warehouse.java?rev=595178&r1=595177&r2=595178&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/oe/model/Warehouse.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/oe/model/Warehouse.java
Wed Nov 14 17:37:21 2007
@@ -47,6 +47,18 @@
     private Address address;
     private String tax;
     private String ytd;
+    
+    /**
+     * Clear all information to allow object re-use.
+     */
+    public void clear()
+    {
+        id = 0;
+        name = null;
+        address = null;
+        tax = null;
+        ytd = null;
+    }
 
     public Address getAddress() {
         return address;



Mime
View raw message