Re: BytesRef violates the principle of least astonishment

2015-05-20 Thread Dawid Weiss
> Otherwise, it violates the Liskov substitution principle as well. Sadly it also violates the Heisenberg's principle at the bit state energy levels. We're working on improving that. >From your heated comments I think you should switch the language to something that guarantees immutability of any

Re: BytesRef violates the principle of least astonishment

2015-05-20 Thread Trejkaz
On Thu, May 21, 2015 at 9:44 AM, Chris Hostetter wrote: > If you really feel strongly about this, and want to advocate for more > consistency arround the meaning/implementation of "clone()" in Java APIs, > i suggest you take it up with the Open JDK project, and focus on a more > high visibility, w

Re: BytesRef violates the principle of least astonishment

2015-05-20 Thread Chris Hostetter
: I already know how Object#clone() works: May i humbly suggest that you: a) relax a bit; b) keep reading the rest of the javadocs for that method? : As BytesRef#clone() is overriding Object#clone(), I expect it to : comply with that. BytesRef#clone() functions virtually identical to the way O

Re: BytesRef violates the principle of least astonishment

2015-05-20 Thread Trejkaz
On Wed, May 20, 2015 at 5:12 PM, András Péteri wrote: > As Olivier wrote, multiple BytesRef instances can share the underlying byte > array when representing slices of existing data, for performance reasons. > > BytesRef#clone()'s javadoc comment says that the result will be a shallow > clone, sha

Re: MUST operator across grouped documents

2015-05-20 Thread Eduardo Manrique
I was searching a solution for this cross doc AND and found this: TwoPhaseIterator: Description Currently some scorers have to do a lot of per-document work to determine if a document is a match. The simplest example is a phrase scorer, but there are others (spans, sloppy phrase, geospatial, etc

Re: BytesRef violates the principle of least astonishment

2015-05-20 Thread Dawid Weiss
> BytesRef is not different, because it is just a "reference" to pass around. > And cloning a reference for sure should not clone the target of the > reference. You are "cloning" the reference and only that (as the name of the > class says: Bytes*Ref*)! Exactly. It is a reference and as such, c

RE: BytesRef violates the principle of least astonishment

2015-05-20 Thread Uwe Schindler
Hi, > > BytesRef#clone()'s javadoc comment says that the result will be a > > shallow clone, sharing the backing array with the original instance, > > and points to another utility method for deep cloning: > BytesRef#deepCopyOf(BytesRef). > > There is no hard contract for clone > https://docs.or

Re: BytesRef violates the principle of least astonishment

2015-05-20 Thread Toke Eskildsen
On Wed, 2015-05-20 at 09:12 +0200, András Péteri wrote: > As Olivier wrote, multiple BytesRef instances can share the underlying byte > array when representing slices of existing data, for performance reasons. > > BytesRef#clone()'s javadoc comment says that the result will be a shallow > clone, s

Re: BytesRef violates the principle of least astonishment

2015-05-20 Thread Olivier Binda
On 05/20/2015 08:53 AM, Trejkaz wrote: On Wed, May 20, 2015 at 3:21 PM, Olivier Binda wrote: My take : Indeed BytesRef is mutable This happens for performance reasons, to avoid unnecessary object creations and unecessary copying and Also to workaround the java "issue" that most of the time you

Re: BytesRef violates the principle of least astonishment

2015-05-20 Thread Dawid Weiss
Yes, BytesRef can be surprising. No, it probably won't change in Lucene to comply with superb design principles. Yes, the odd design is there for performance reasons and it does provide noticeable gain. Perhaps you could file a JIRA issue to improve the documentation, this would be helpful. For wh

Re: BytesRef violates the principle of least astonishment

2015-05-20 Thread Trejkaz
On Wed, May 20, 2015 at 3:21 PM, Olivier Binda wrote: > My take : > Indeed BytesRef is mutable > This happens for performance reasons, to avoid unnecessary object > creations and unecessary copying and Also to workaround > the java "issue" that most of the time you need to pass an array with an >

Re: BytesRef violates the principle of least astonishment

2015-05-20 Thread András Péteri
As Olivier wrote, multiple BytesRef instances can share the underlying byte array when representing slices of existing data, for performance reasons. BytesRef#clone()'s javadoc comment says that the result will be a shallow clone, sharing the backing array with the original instance, and points to