Github user liancheng commented on a diff in the pull request:
https://github.com/apache/spark/pull/4115#discussion_r23209879
--- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/Row.scala ---
@@ -291,12 +309,61 @@ trait Row extends Seq[Any] with Serializable {
/** Returns true if there are any NULL values in this row. */
def anyNull: Boolean = {
- val l = length
+ val len = length
var i = 0
- while (i < l) {
+ while (i < len) {
if (isNullAt(i)) { return true }
i += 1
}
false
}
+
+ override def equals(that: Any): Boolean = that match {
+ case null => false
+ case that: Row =>
+ if (this.length != that.length) {
+ return false
+ }
+ var i = 0
+ val len = this.length
+ while (i < len) {
+ if (apply(i) != that.apply(i)) {
+ return false
+ }
+ i += 1
+ }
+ true
+ case _ => false
+ }
+
+ override def hashCode: Int = {
+ // Using Scala's Seq hash code implementation.
+ var n = 0
+ var h = MurmurHash3.seqSeed
+ val len = length
+ while (n < len) {
+ h = MurmurHash3.mix(h, apply(n).##)
+ n += 1
+ }
+ MurmurHash3.finalizeHash(h, n)
+ }
+
+ /* ---------------------- utility methods for Scala
---------------------- */
+
+ /**
+ * Return a Scala Seq representing the row. ELements are placed in the
same order in the Seq.
+ */
+ def toSeq: Seq[Any]
--- End diff --
Would like to have a `toArray` here, since most `Row` subclasses are backed
by array, which already has plenty rich operations.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]