You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Uwe Schindler (JIRA)" <ji...@apache.org> on 2017/05/08 19:16:04 UTC

[jira] [Commented] (LUCENE-7723) LongValuesSource/DoubleValuesSource impls should implement equals/hashCode

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

Uwe Schindler commented on LUCENE-7723:
---------------------------------------

The problem is that you have 2 different lambdas, so they are by default "different". If you compare instances of functional interfaces, thy are only identical if they are the same instance... The test would work, if you would declare the lambda once and pass it on both sides of the equals.

To make the whole thing more complicated: Lambdas without captures should compare to each other if declared once. So that means if you have a method that returns a functional interface instance and this functional instance does not depend on anything from the outside (like function parameters, local variables), it would be a singleton and the method would return the same each time. But as soon as the lambda refers to variables outside the lambda, it gets a caturing one (capturing the external variables). Then every instance is different, because it creates an object instance (it cannot reuse as the captured variables are final fields inside the lambda implementation class). So you should never rely on equalness or sameness for lambdas.

> LongValuesSource/DoubleValuesSource impls should implement equals/hashCode
> --------------------------------------------------------------------------
>
>                 Key: LUCENE-7723
>                 URL: https://issues.apache.org/jira/browse/LUCENE-7723
>             Project: Lucene - Core
>          Issue Type: Task
>            Reporter: Adrien Grand
>         Attachments: LUCENE-7723.patch
>
>
> Given that we embed values sources in queries and sorts, from which we expect that they have working equals/hashCode, we should also implement equals/hashCode on LongValuesSource/DoubleValuesSource impls.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org