Return-Path: Mailing-List: contact derby-commits-help@db.apache.org; run by ezmlm Delivered-To: mailing list derby-commits@db.apache.org Received: (qmail 94978 invoked by uid 500); 4 Jan 2005 22:36:33 -0000 Delivered-To: apmail-incubator-derby-cvs@incubator.apache.org Received: (qmail 94960 invoked by uid 99); 4 Jan 2005 22:36:33 -0000 X-ASF-Spam-Status: No, hits=-9.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from minotaur.apache.org (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.28) with SMTP; Tue, 04 Jan 2005 14:36:32 -0800 Received: (qmail 45940 invoked by uid 65534); 4 Jan 2005 22:36:30 -0000 Date: 4 Jan 2005 22:36:30 -0000 Message-ID: <20050104223630.45938.qmail@minotaur.apache.org> From: djd@apache.org To: derby-cvs@incubator.apache.org Subject: svn commit: r124165 - /incubator/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet.java MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Virus-Checked: Checked Author: djd Date: Tue Jan 4 14:36:29 2005 New Revision: 124165 URL: http://svn.apache.org/viewcvs?view=rev&rev=124165 Log: Remove creation of integer array representing all the columns' JDBC data types. Array object was created for every ResultSet creation and used infrequently. Creation thus impacted performance and garbage collection. Modified: incubator/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet.java Modified: incubator/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet.java Url: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet.java?view=diff&rev=124165&p1=incubator/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet.java&r1=124164&p2=incubator/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet.java&r2=124165 ============================================================================== --- incubator/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet.java (original) +++ incubator/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet.java Tue Jan 4 14:36:29 2005 @@ -108,18 +108,11 @@ private final ResultDescription resultDescription; - /** - An array of the JDBC column types for this - result set, indexed by column identifier - with the first column at index 1. Position 0 - in the array is not used. - */ - private final int[] jdbcColumnTypes; // max rows limit for this result set private int maxRows; // The Maximum field size limt set for this result set - private int maxFieldSize; + private final int maxFieldSize; /* * Incase of forward only cursors we limit the number of rows @@ -156,14 +149,7 @@ this.stmt = owningStmt = stmt; this.isAtomic = isAtomic; - // Fill in the column types - ResultDescription rd = resultDescription = theResults.getResultDescription(); - jdbcColumnTypes = new int[rd.getColumnCount() + 1]; - - for (int column = 1; column < jdbcColumnTypes.length; column++) { - jdbcColumnTypes[column] = - rd.getColumnDescriptor(column).getType().getTypeId().getJDBCTypeId(); - } + resultDescription = theResults.getResultDescription(); // assign the max rows and maxfiled size limit for this result set if (stmt != null) @@ -174,11 +160,10 @@ maxFieldSize = stmt.MaxFieldSize; } + else + maxFieldSize = 0; order = conn.getResultSetOrderId(); - - // System.out.println(conn.getClass() + " create RS " + this); - // new Throwable("CRS").printStackTrace(System.out); } /** @@ -214,15 +199,15 @@ @exception SQLException ResultSet is not on a row or columnIndex is out of range. */ - protected int getColumnType(int columnIndex) throws SQLException { + final int getColumnType(int columnIndex) throws SQLException { checkOnRow(); // first make sure there's a row if (columnIndex < 1 || - columnIndex >= jdbcColumnTypes.length) + columnIndex > resultDescription.getColumnCount()) throw newSQLException(SQLState.COLUMN_NOT_FOUND, new Integer(columnIndex)); - return jdbcColumnTypes[columnIndex]; + return resultDescription.getColumnDescriptor(columnIndex).getType().getJDBCTypeId(); } /* @@ -528,13 +513,6 @@ */ public final String getString(int columnIndex) throws SQLException { - - // never need to push a context stack because everything can be converted - // into an String without a conversion error. With one exception! If - // the type is OTHER (ie an object) then while Object.toString() cannot - // throw an exception a user implementation of it could require the - // current connection. In order to get the current connection the - // context stack must be set up. try { DataValueDescriptor dvd = getColumn(columnIndex); @@ -542,26 +520,10 @@ if (wasNull = dvd.isNull()) return null; - int colType = jdbcColumnTypes[columnIndex]; - - String value; - - if (colType == Types.OTHER || colType == org.apache.derby.iapi.reference.JDBC20Translation.SQL_TYPES_JAVA_OBJECT) { - synchronized (getConnectionSynchronization()) { - setupContextStack(); - try { - value = dvd.getString(); - } finally { - restoreContextStack(); - } - } - - } else { - value = dvd.getString(); - } + String value = dvd.getString(); // check for the max field size limit - if (maxFieldSize > 0 && isMaxFieldSizeType(colType)) + if (maxFieldSize > 0 && isMaxFieldSizeType(getColumnType(columnIndex))) { if (value.length() > maxFieldSize ) { @@ -759,7 +721,7 @@ byte[] value = dvd.getBytes(); // check for the max field size limit - if (maxFieldSize > 0 && isMaxFieldSizeType(jdbcColumnTypes[columnIndex])) + if (maxFieldSize > 0 && isMaxFieldSizeType(getColumnType(columnIndex))) { if (value.length > maxFieldSize) { @@ -1008,7 +970,7 @@ Object syncLock = getConnectionSynchronization(); - synchronized (getConnectionSynchronization()) { + synchronized (syncLock) { boolean pushStack = false; try { @@ -1116,7 +1078,7 @@ Object syncLock = getConnectionSynchronization(); - synchronized (getConnectionSynchronization()) { + synchronized (syncLock) { boolean pushStack = false; try { @@ -1714,10 +1676,6 @@ DataValueDescriptor[] theCurrentRow = checkOnRow(); // first make sure there's a row - //if (columnIndex < 1 || - // columnIndex >= jdbcColumnTypes.length) - // - try { return theCurrentRow[columnIndex - 1]; } catch (ArrayIndexOutOfBoundsException aoobe) {