-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Define equality between converter wrappers #10425
Conversation
When converter destination collection does not have equality defined, we should override equals/hashcode. 2 wrappers with same underlying collection should be equal.
Thanks! It took me a while to realize this is a PR not a new ticket. I was looking at previous |
9d765e0
to
660deb2
Compare
660deb2
to
941a83f
Compare
I confirmed (if it needed confirming) that the scio test passes with this change. The following is a note to myself, so I don't have to tattoo it on my arm. I'm not persuaded by delegating for the iterator wrappers, but it's also harmless, perhaps. (And it has the air of completeness.) So the material change is for Refreshing my memory, I'm a bit surprised by:
That seems to me unhelpful. However, in the context of this PR, it endorses just delegating, come what may. The wrappers are the thinnest of veneers. (I almost wrote Venners.) My other thought is that arbitrary wrappers with the same (
A hypothetical rogue wrapper, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Straightforward and complete. I had a couple of test tweaks but it can wait for another occasion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So IIUC, the strategy is to override equals
unless the wrapper class already inherits equals
(e.g., SeqWrapper
, JSetWrapper
), right?
If so, should we add equality to DictionaryWrapper
?
scala> val m = collection.mutable.Map(1 -> 1)
val m: scala.collection.mutable.Map[Int,Int] = HashMap(1 -> 1)
scala> m.asJavaDictionary == m.asJavaDictionary
val res18: Boolean = false
When converter destination collection does not have equality defined, we should override equals/hashcode. 2 wrappers with same underlying collection should be equal.
Follow-up for scala/bug#12683