Return-Path: Delivered-To: apmail-lucene-java-user-archive@www.apache.org Received: (qmail 87764 invoked from network); 7 Oct 2007 11:48:29 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 7 Oct 2007 11:48:29 -0000 Received: (qmail 39967 invoked by uid 500); 7 Oct 2007 11:48:11 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 39946 invoked by uid 500); 7 Oct 2007 11:48:11 -0000 Mailing-List: contact java-user-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: java-user@lucene.apache.org Delivered-To: mailing list java-user@lucene.apache.org Received: (qmail 39935 invoked by uid 99); 7 Oct 2007 11:48:10 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 07 Oct 2007 04:48:10 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [66.111.4.25] (HELO out1.smtp.messagingengine.com) (66.111.4.25) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 07 Oct 2007 11:48:14 +0000 Received: from compute1.internal (compute1.internal [10.202.2.41]) by out1.messagingengine.com (Postfix) with ESMTP id 2EDE62F563 for ; Sun, 7 Oct 2007 07:47:54 -0400 (EDT) Received: from web8.messagingengine.com ([10.202.2.217]) by compute1.internal (MEProxy); Sun, 07 Oct 2007 07:47:54 -0400 Received: by web8.messagingengine.com (Postfix, from userid 99) id 0760B12B15; Sun, 7 Oct 2007 07:47:54 -0400 (EDT) Message-Id: <1191757673.30911.1214561755@webmail.messagingengine.com> X-Sasl-Enc: s+jczo+0ZlSVG7piGGVKiADGkNlADrLZc3qWgUpK9+xx 1191757673 From: "Michael McCandless" To: java-user@lucene.apache.org Content-Disposition: inline Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="ISO-8859-1" MIME-Version: 1.0 X-Mailer: MessagingEngine.com Webmail Interface References: <9DDFDD4D-EF67-4C77-AE6E-FAC1105882DB@gmail.com> Subject: Re: norms(String field, byte[] bytes, int offset) In-Reply-To: <9DDFDD4D-EF67-4C77-AE6E-FAC1105882DB@gmail.com> Date: Sun, 07 Oct 2007 07:47:53 -0400 X-Virus-Checked: Checked by ClamAV on apache.org I think the intention of that method is to load all norms for that reader into the byte array, so I think it's reasonable that an exception is thrown if you provide a byte array that's too small. Though maybe it would be friendlier to throw an IllegalArgumentException that says "the byte array is not long enough"? Mike "Karl Wettin" wrote: > I'm confused by this method. Why is the length set to maxDoc() and > not bytes.length? This means that the following snippet will throw an > ArrayIndexOutOfBoundsException in most cases: > > byte[] b = new byte[1]; > ir.norms(field, b, doc); > > > > /** Read norms into a pre-allocated array. */ > > public synchronized void norms(String field, byte[] bytes, int > > offset) > > throws IOException { > > > > ensureOpen(); > > Norm norm = (Norm) norms.get(field); > > if (norm == null) { > > System.arraycopy(fakeNorms(), 0, bytes, offset, maxDoc()); > > return; > > } > > > > if (norm.bytes != null) { // can copy from > > cache > > System.arraycopy(norm.bytes, 0, bytes, offset, maxDoc()); > > return; > > } > > > > // Read from disk. norm.in may be shared across multiple > > norms and > > // should only be used in a synchronized context. > > norm.in.seek(norm.normSeek); > > norm.in.readBytes(bytes, offset, maxDoc()); > > } > > -- > karl > > --------------------------------------------------------------------- > To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org > For additional commands, e-mail: java-user-help@lucene.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org For additional commands, e-mail: java-user-help@lucene.apache.org