Return-Path: Delivered-To: apmail-db-derby-dev-archive@www.apache.org Received: (qmail 40610 invoked from network); 28 Nov 2006 01:32:39 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 28 Nov 2006 01:32:39 -0000 Received: (qmail 27784 invoked by uid 500); 28 Nov 2006 01:32:48 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 27567 invoked by uid 500); 28 Nov 2006 01:32:47 -0000 Mailing-List: contact derby-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: Delivered-To: mailing list derby-dev@db.apache.org Received: (qmail 27558 invoked by uid 99); 28 Nov 2006 01:32:47 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 27 Nov 2006 17:32:47 -0800 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: neutral (herse.apache.org: local policy) Received: from [32.97.110.151] (HELO e33.co.us.ibm.com) (32.97.110.151) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 27 Nov 2006 17:32:33 -0800 Received: from d03relay04.boulder.ibm.com (d03relay04.boulder.ibm.com [9.17.195.106]) by e33.co.us.ibm.com (8.13.8/8.12.11) with ESMTP id kAS1WCmR026590 for ; Mon, 27 Nov 2006 20:32:12 -0500 Received: from d03av03.boulder.ibm.com (d03av03.boulder.ibm.com [9.17.195.169]) by d03relay04.boulder.ibm.com (8.13.6/8.13.6/NCO v8.1.1) with ESMTP id kAS1WCxs519162 for ; Mon, 27 Nov 2006 18:32:12 -0700 Received: from d03av03.boulder.ibm.com (loopback [127.0.0.1]) by d03av03.boulder.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id kAS1WCfQ023333 for ; Mon, 27 Nov 2006 18:32:12 -0700 Received: from [127.0.0.1] (sig-9-76-203-175.mts.ibm.com [9.76.203.175]) by d03av03.boulder.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id kAS1VpCO022708 for ; Mon, 27 Nov 2006 18:32:11 -0700 Message-ID: <456B917F.4090706@apache.org> Date: Mon, 27 Nov 2006 17:31:43 -0800 From: Daniel John Debrunner User-Agent: Thunderbird 1.5.0.8 (Windows/20061025) MIME-Version: 1.0 To: derby-dev@db.apache.org Subject: Re: ArrayInputStream and performance References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Knut Anders Hatlen wrote: > I can't answer your question, but I will add that I find much of the > code that uses ArrayInputStream very confusing. ArrayInputStream is > supposed to wrap a byte array to provide encapsulation and easy access > to the data through the InputStream interface. However, many (most?) > of the callers inline the accesses to the data (presumably for > performance reasons), so we end up with lots of methods looking like > this: > > public X readSomething(ArrayInputStream ais, byte[] data, int offset...) { > // lots of direct manipulation of the byte array > // ... > // ... > // ... > // finally, make sure that the state of the stream is brought to a > // consistent state: > ais.setPosition(offset + numberOfManipulatedBytes); > } I could only find one method that looked something like the above: StoredFieldHeader.readFieldLengthAndSetStreamPosition Could you provide a list of the others so I can see what the issue is? Thanks, Dan. > > Both the byte array and the offset are part of the ArrayInputStream > class, so having all three of them in the parameter list feels a bit > ugly. And if we need to manipulate the internal state directly that > often, perhaps an InputStream is not the best data structure in the > first place? >