-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-6429] Implement hashCode and equals together #12157
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,4 +22,8 @@ package org.apache.spark.util.collection | |
| */ | ||
| case class FixedHashObject(v: Int, h: Int) extends Serializable { | ||
| override def hashCode(): Int = h | ||
| override def equals(other: Any): Boolean = other match { | ||
|
||
| case that: FixedHashObject => v == that.v && h == that.h | ||
| case _ => false | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,8 @@ | |
|
|
||
| package org.apache.spark.sql.types | ||
|
|
||
| import java.util.Objects | ||
|
|
||
| import org.json4s.JsonAST.JValue | ||
| import org.json4s.JsonDSL._ | ||
|
|
||
|
|
@@ -83,6 +85,8 @@ abstract class UserDefinedType[UserType >: Null] extends DataType with Serializa | |
|
|
||
| override def sql: String = sqlType.sql | ||
|
|
||
| override def hashCode(): Int = getClass.hashCode() | ||
|
|
||
| override def equals(other: Any): Boolean = other match { | ||
| case that: UserDefinedType[_] => this.acceptsType(that) | ||
| case _ => false | ||
|
|
@@ -115,7 +119,9 @@ private[sql] class PythonUserDefinedType( | |
| } | ||
|
|
||
| override def equals(other: Any): Boolean = other match { | ||
| case that: PythonUserDefinedType => this.pyUDT.equals(that.pyUDT) | ||
| case that: PythonUserDefinedType => pyUDT == that.pyUDT | ||
|
||
| case _ => false | ||
| } | ||
|
|
||
| override def hashCode(): Int = Objects.hashCode(pyUDT) | ||
| } | ||
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.
This may upset MiMa since you effectively remove an 'idx' property but it can be ignored for our purposes as it's a private class.
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.
Make sense