Return-Path: Delivered-To: apmail-db-derby-commits-archive@www.apache.org Received: (qmail 67692 invoked from network); 15 Nov 2007 01:37:44 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 15 Nov 2007 01:37:44 -0000 Received: (qmail 97472 invoked by uid 500); 15 Nov 2007 01:37:32 -0000 Delivered-To: apmail-db-derby-commits-archive@db.apache.org Received: (qmail 97446 invoked by uid 500); 15 Nov 2007 01:37:32 -0000 Mailing-List: contact derby-commits-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: "Derby Development" List-Id: Delivered-To: mailing list derby-commits@db.apache.org Received: (qmail 97435 invoked by uid 99); 15 Nov 2007 01:37:31 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 14 Nov 2007 17:37:31 -0800 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 15 Nov 2007 01:37:29 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 2F2A61A9832; Wed, 14 Nov 2007 17:37:23 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: derby-commits@db.apache.org From: djd@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20071115013723.2F2A61A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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. + *
+ * Any display method must not retain references to any objects + * it is passed, the caller may be re-using the objects across transactions. *

* 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 @@ *

* More specific direct (client side) implementations * could extend this class overriding methods as needed. + *

+ * 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;