Re: BytesRef equals() method

2014-01-22 Thread Yann-Erwan Perio
On Wed, Jan 22, 2014 at 12:09 PM, Michael McCandless wrote: Hi, > DocsAndPositionsEnum.getPayload() is allowed to re-use the returned > BytesRef under the hood. Ah, I am starting to get it. The BytesRef would be directly stored in the key set of the map, but since its properties can change, the

Re: BytesRef equals() method

2014-01-22 Thread Michael McCandless
DocsAndPositionsEnum.getPayload() is allowed to re-use the returned BytesRef under the hood. So, if you want to hold a copy of the payload across two or more calls to .getPayload you'll have to make a deep copy of (BytesRef.deepCopyOf) the returned BytesRef yourself. Mike McCandless http://blog.

Re: BytesRef equals() method

2014-01-22 Thread Steven Schlansker
On Wed, 22 Jan 2014 07:14:59 +0100 Yann-Erwan Perio wrote: > On Tue, Jan 21, 2014 at 7:54 PM, Steven Schlansker > wrote: > > Certainly, but my problem still persists if I do not do it. I spent > the whole night debugging the code, to no avail. As a matter of fact, > when I run a series of tests

Re: BytesRef equals() method

2014-01-21 Thread Yann-Erwan Perio
On Tue, Jan 21, 2014 at 7:54 PM, Steven Schlansker wrote: Hi, Firstly, thanks to all of you for your insights. > How can two byte arrays be equal if they have different lengths? > Same way as two Strings with differing lengths can never be equal, two > byte arrays with different lengths will ne

Re: BytesRef equals() method

2014-01-21 Thread Michael Sokolov
Note the comments in the source: /** Length of used bytes. */ public int length; length is not the same as the size of the internal buffer. It is the number of used bytes, so the length of the "logical" value as you call it. -Mike On 1/21/2014 10:32 AM, Yann-Erwan Perio wrote: Hello,

RE: BytesRef equals() method

2014-01-21 Thread Rose, Stuart J
rings. Stuart -Original Message- From: Yann-Erwan Perio [mailto:ye.pe...@gmail.com] Sent: Tuesday, January 21, 2014 7:33 AM To: java-user@lucene.apache.org Subject: BytesRef equals() method Hello, I have been working a bit with BytesRef recently, and I wonder whether the content of the equals() m

Re: BytesRef equals() method

2014-01-21 Thread Steven Schlansker
On Jan 21, 2014, at 7:32 AM, Yann-Erwan Perio wrote: > Hello, > > I have been working a bit with BytesRef recently, and I wonder whether > the content of the equals() method, and more specifically the content > of the bytesEquals(BytesRef other) method, is the intended one. > > I was made awar

BytesRef equals() method

2014-01-21 Thread Yann-Erwan Perio
Hello, I have been working a bit with BytesRef recently, and I wonder whether the content of the equals() method, and more specifically the content of the bytesEquals(BytesRef other) method, is the intended one. Here is my use case. I work with Lucene 4.6.0. During indexing, using a custom tokeni