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

Dawid Weiss commented on LUCENE-460:
------------------------------------

There isn't really much to understand, it's pretty simple. 

{code}
h = (h<<1) | (h >>> 31);  // rotate left
{code}

These are rotation bitshifts -- there is no operator for it in Java. There's 
actually an intrinsic for this (Integer.rotateLeft and rotateRight).

Now which sequence of operations -- the one above or IntelliJ generated one -- 
is "better" is a difficult question to answer -- depends how many collisions 
you actually get for real life include/exclude pairs. I doubt there'll be many. 
Multiplications used to be much smaller than bitshifts and logical operations 
so the first version is probably historically motivated (as being faster).

                
> hashCode improvements
> ---------------------
>
>                 Key: LUCENE-460
>                 URL: https://issues.apache.org/jira/browse/LUCENE-460
>             Project: Lucene - Core
>          Issue Type: Improvement
>          Components: core/search
>            Reporter: Yonik Seeley
>            Assignee: Yonik Seeley
>            Priority: Minor
>
> It would be nice for all Query classes to implement hashCode and equals to 
> enable them to be used as keys when caching.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

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

Reply via email to