Return-Path: X-Original-To: apmail-cayenne-commits-archive@www.apache.org Delivered-To: apmail-cayenne-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A485392C2 for ; Tue, 28 Feb 2012 12:10:20 +0000 (UTC) Received: (qmail 35535 invoked by uid 500); 28 Feb 2012 12:10:20 -0000 Delivered-To: apmail-cayenne-commits-archive@cayenne.apache.org Received: (qmail 35515 invoked by uid 500); 28 Feb 2012 12:10:20 -0000 Mailing-List: contact commits-help@cayenne.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cayenne.apache.org Delivered-To: mailing list commits@cayenne.apache.org Received: (qmail 35508 invoked by uid 99); 28 Feb 2012 12:10:20 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 Feb 2012 12:10:20 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 Feb 2012 12:10:19 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 329F223889B8 for ; Tue, 28 Feb 2012 12:09:58 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1294605 - /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/Expression.java Date: Tue, 28 Feb 2012 12:09:58 -0000 To: commits@cayenne.apache.org From: aadamchik@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120228120958.329F223889B8@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: aadamchik Date: Tue Feb 28 12:09:57 2012 New Revision: 1294605 URL: http://svn.apache.org/viewvc?rev=1294605&view=rev Log: CAY-1667 Expression parser performance optimization expanding buffer by 1 char - this is needed to prevent buffer resize Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/Expression.java Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/Expression.java URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/Expression.java?rev=1294605&r1=1294604&r2=1294605&view=diff ============================================================================== --- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/Expression.java (original) +++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/Expression.java Tue Feb 28 12:09:57 2012 @@ -82,9 +82,9 @@ public abstract class Expression impleme *
    *
  • An attribute of root ObjEntity. For entity Gallery OBJ_PATH expression * "galleryName" will point to ObjAttribute "galleryName" - *
  • Another ObjEntity related to root ObjEntity via a chain of relationships. - * For entity Gallery OBJ_PATH expression "paintingArray.toArtist" will point to - * ObjEntity "Artist" + *
  • Another ObjEntity related to root ObjEntity via a chain of + * relationships. For entity Gallery OBJ_PATH expression "paintingArray.toArtist" + * will point to ObjEntity "Artist" *
  • ObjAttribute of another ObjEntity related to root ObjEntity via a chain of * relationships. For entity Gallery OBJ_PATH expression * "paintingArray.toArtist.artistName" will point to ObjAttribute "artistName" @@ -98,13 +98,13 @@ public abstract class Expression impleme * (dot). Path can point to either one of these: *
      *
    • An attribute of root DbEntity. For entity GALLERY, DB_PATH expression - * "GALLERY_NAME" will point to a DbAttribute "GALLERY_NAME".
    • + * "GALLERY_NAME" will point to a DbAttribute "GALLERY_NAME". *
    • Another DbEntity related to root DbEntity via a chain of relationships. * For entity GALLERY DB_PATH expression "paintingArray.toArtist" will point to - * DbEntity "ARTIST".
    • + * DbEntity "ARTIST". *
    • DbAttribute of another ObjEntity related to root DbEntity via a chain of * relationships. For entity GALLERY DB_PATH expression - * "paintingArray.toArtist.ARTIST_NAME" will point to DbAttribute "ARTIST_NAME".
    • + * "paintingArray.toArtist.ARTIST_NAME" will point to DbAttribute "ARTIST_NAME". *
    */ public static final int DB_PATH = 27; @@ -119,9 +119,8 @@ public abstract class Expression impleme public static final int NOT_LIKE = 37; public static final int NOT_LIKE_IGNORE_CASE = 38; - private static final int PARSE_BUFFER_MAX_SIZE = 4096; - + protected int type; /** @@ -137,9 +136,11 @@ public abstract class Expression impleme } // optimizing parser buffers per CAY-1667... + // adding 1 extra char to the buffer size above the String length, as otherwise + // resizing still occurs at the end of the stream int bufferSize = expressionString.length() > PARSE_BUFFER_MAX_SIZE ? PARSE_BUFFER_MAX_SIZE - : expressionString.length(); + : expressionString.length() + 1; Reader reader = new StringReader(expressionString); JavaCharStream stream = new JavaCharStream(reader, 1, 1, bufferSize); ExpressionParserTokenManager tm = new ExpressionParserTokenManager(stream); @@ -271,8 +272,8 @@ public abstract class Expression impleme * expression parameter, and value being the value that should be used in * the final expression. * @param pruneMissing If true, subexpressions that rely on missing - * parameters will be pruned from the resulting tree. If false, - * any missing values will generate an exception. + * parameters will be pruned from the resulting tree. If false + * , any missing values will generate an exception. * @return Expression resulting from the substitution of parameters with real values, * or null if the whole expression was pruned, due to the missing parameters. */ @@ -349,8 +350,8 @@ public abstract class Expression impleme public abstract Expression notExp(); /** - * Returns a count of operands of this expression. In real life there are unary (count == - * 1), binary (count == 2) and ternary (count == 3) expressions. + * Returns a count of operands of this expression. In real life there are unary (count + * == 1), binary (count == 2) and ternary (count == 3) expressions. */ public abstract int getOperandCount();