Return-Path: Delivered-To: apmail-lucene-java-user-archive@www.apache.org Received: (qmail 77460 invoked from network); 10 Dec 2010 18:05:09 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 10 Dec 2010 18:05:09 -0000 Received: (qmail 68412 invoked by uid 500); 10 Dec 2010 18:05:05 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 68337 invoked by uid 500); 10 Dec 2010 18:05:05 -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 68328 invoked by uid 99); 10 Dec 2010 18:05:05 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 10 Dec 2010 18:05:05 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=RCVD_IN_DNSWL_LOW,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [209.85.213.176] (HELO mail-yx0-f176.google.com) (209.85.213.176) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 10 Dec 2010 18:05:00 +0000 Received: by yxm8 with SMTP id 8so2565334yxm.35 for ; Fri, 10 Dec 2010 10:04:39 -0800 (PST) MIME-Version: 1.0 Received: by 10.42.166.73 with SMTP id n9mr791885icy.64.1292004278435; Fri, 10 Dec 2010 10:04:38 -0800 (PST) Received: by 10.42.223.9 with HTTP; Fri, 10 Dec 2010 10:04:38 -0800 (PST) In-Reply-To: <201012110131124712723@gmail.com> References: <201012102233473727284@gmail.com> <201012110131124712723@gmail.com> Date: Fri, 10 Dec 2010 10:04:38 -0800 Message-ID: Subject: Re: RE: maybe I hit a bug of Term ? From: Tom Hill To: java-user@lucene.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hi Sariny, What Uwe was saying is that the definition for hashCode is found in the docs for Object, and it applies to all implementations of hashCode. It says: "It is not required that if two objects are unequal according to the equals(java.lang.Object) method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hashtables." The implementation of Maps, etc., understand this, and use it appropriately. So, if you write your own Map implementation, you may have to care about this, but in the general case, you can just use any Collection and it will work. Tom 2010/12/10 Sariny : > Object.hashCode() is "implemented by converting the internal address of t= he object into an integer", > > Term.hashCode() has override the default implemention,so,this question ha= s nothing todo with Object.hashCode(). > > I think I should try another way to cache filter results... > > > >>Hashcodes are not guaranteed to be different. See Object#hashCode() >>javadocs. >> >>----- >>Uwe Schindler >>H.-H.-Meier-Allee 63, D-28213 Bremen >>http://www.thetaphi.de >>eMail: uwe@thetaphi.de >> >>> -----Original Message----- >>> From: Sariny [mailto:sariny@gmail.com] >>> Sent: Friday, December 10, 2010 3:34 PM >>> To: java-user >>> Subject: maybe I hit a bug of Term ? >>> >>> >>> =A0 =A0 =A0 =A0 =A0 =A0 =A0Hi, two different Term get the same hashCode= , =A0lucene >>> version 3.0.2 >>> >>> =A0 =A0 =A0 =A0 =A0 =A0 =A0System.out.println(new >>> Term("manu_id",NumericUtils.intToPrefixCoded(111)).hashCode()); >>> =A0 =A0 =A0 =A0 System.out.println(new >>> Term("manu_id",NumericUtils.intToPrefixCoded(402)).hashCode()); >>> >>> =A0 =A0 =A0 =A0 a bug? >>> >>> >>> --------------------------------------------------------------------- >>> 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 >> > > =3D =3D =3D =3D =3D =3D =3D =3D =3D =3D =3D =3D =3D =3D =3D =3D =3D =3D = =3D =3D > > > Hashcodes are not guaranteed to be different. See Object#hashCode() > javadocs. > > ----- > Uwe Schindler > H.-H.-Meier-Allee 63, D-28213 Bremen > http://www.thetaphi.de > eMail: uwe@thetaphi.de > >> -----Original Message----- >> From: Sariny [mailto:sariny@gmail.com] >> Sent: Friday, December 10, 2010 3:34 PM >> To: java-user >> Subject: maybe I hit a bug of Term ? >> >> >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 Hi, two different Term get the same hashCode= , =A0lucene >> version 3.0.2 >> >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 System.out.println(new >> Term("manu_id",NumericUtils.intToPrefixCoded(111)).hashCode()); >> =A0 =A0 =A0 =A0 System.out.println(new >> Term("manu_id",NumericUtils.intToPrefixCoded(402)).hashCode()); >> >> =A0 =A0 =A0 =A0 a bug? >> >> >> --------------------------------------------------------------------- >> 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 > > > --------------------------------------------------------------------- > 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