[ 
https://issues.apache.org/jira/browse/LUCENE-5864?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14080928#comment-14080928
 ] 

Adrien Grand commented on LUCENE-5864:
--------------------------------------

Good points about some confusing parts, I will try to fix them.

I agree get vs. build can be confusing but getting rid of get could be a 
controversial change, I'd rather discuss it as a follow-up.

bq. Why are equals() and hashcode() throwing UOE?

This has been helpful while I was creating this patch to find places where I 
had forgotten to add a call to .get() (otherwise the comparison between a 
BytesRefBuilder and a BytesRef would always return false). I agree that 
consistency with StringBuilder would be nice, although I find it quite 
error-prone as well to have things like a hashcode method on a buffer (they 
shouldn't be used in hash tables). I can implement proper equals/hashCode impls 
instead if you want, but I was thinking that having these methods throwing 
exceptions could be helpful to users upgrading their applications in the same 
way that it has been helpful to me to catch errors while building this patch.

> Split BytesRef into BytesRef and BytesRefBuilder
> ------------------------------------------------
>
>                 Key: LUCENE-5864
>                 URL: https://issues.apache.org/jira/browse/LUCENE-5864
>             Project: Lucene - Core
>          Issue Type: Bug
>            Reporter: Adrien Grand
>            Assignee: Adrien Grand
>             Fix For: 4.10
>
>         Attachments: LUCENE-5864.patch
>
>
> Follow-up of LUCENE-5836.
> The fact that BytesRef (and CharsRef, IntsRef, LongsRef) can be used as 
> either pointers to a section of a byte[] or as buffers raises issues. The 
> idea would be to keep BytesRef but remove all the buffer methods like 
> copyBytes, grow, etc. and add a new class BytesRefBuilder that wraps a byte[] 
> and a length (but no offset), has grow/copyBytes/copyChars methods and the 
> ability to build BytesRef instances.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to