Return-Path: Delivered-To: apmail-jakarta-lucene-dev-archive@www.apache.org Received: (qmail 91771 invoked from network); 20 May 2004 02:56:21 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 20 May 2004 02:56:21 -0000 Received: (qmail 62346 invoked by uid 500); 20 May 2004 02:57:00 -0000 Delivered-To: apmail-jakarta-lucene-dev-archive@jakarta.apache.org Received: (qmail 62243 invoked by uid 500); 20 May 2004 02:56:59 -0000 Mailing-List: contact lucene-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Lucene Developers List" Reply-To: "Lucene Developers List" Delivered-To: mailing list lucene-dev@jakarta.apache.org Received: (qmail 62228 invoked by uid 98); 20 May 2004 02:56:59 -0000 Received: from ntao@panscient.com by hermes.apache.org by uid 82 with qmail-scanner-1.20 (clamuko: 0.70. Clear:RC:0(203.59.3.45):. Processed in 0.444919 secs); 20 May 2004 02:56:59 -0000 X-Qmail-Scanner-Mail-From: ntao@panscient.com via hermes.apache.org X-Qmail-Scanner: 1.20 (Clear:RC:0(203.59.3.45):. Processed in 0.444919 secs) Received: from unknown (HELO mail.iinet.net.au) (203.59.3.45) by hermes.apache.org with SMTP; 20 May 2004 02:56:58 -0000 Received: (qmail 13675 invoked from network); 20 May 2004 02:56:07 -0000 Received: from unknown (HELO 192.168.0.242) (203.173.1.7) by mail.iinet.net.au with SMTP; 20 May 2004 02:56:06 -0000 Subject: TermInfosReader.getIndexOffset javadoc and code inconsistent? From: Nigel Tao Reply-To: ntao@panscient.com To: Lucene Developers List Content-Type: text/plain Message-Id: <1085019974.4081.12.camel@vitabrits.panscient.com> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.4 Date: Thu, 20 May 2004 12:26:15 +1000 Content-Transfer-Encoding: 7bit X-Spam-Rating: hermes.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N This is a minor quibble, but are the javadocs and the code for TermInfosReader.getIndexOffset(Term) inconsistent? The javadocs say "less than" but the code says "less than or equal to" (if the "return mid" route is taken, which requires that term.compareTo(indexTerms[mid]) == 0). But more importantly - does this impact any consumers of this method - if, for example, they actually presume "less than" rather than "less than or equal to"? Also, this may be a strictly academic point, but should it be documented that this method may return -1 if no index entry is <= term? In practice this is impossible since indexTerms[0] is always the empty Term with "" field and "" text, which is less than (or equal to :-) any other Term. cheers, Nigel. ----------------------------------- /** * Returns the offset of the greatest index entry which is * less than term. */ private final int getIndexOffset(Term term) throws IOException { // binary search indexTerms[] int lo = 0; int hi = indexTerms.length - 1; while (hi >= lo) { int mid = (lo + hi) >> 1; int delta = term.compareTo(indexTerms[mid]); if (delta < 0) hi = mid - 1; else if (delta > 0) lo = mid + 1; else return mid; } return hi; } ----------------------------------- --------------------------------------------------------------------- To unsubscribe, e-mail: lucene-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: lucene-dev-help@jakarta.apache.org