Skip to content

Commit

Permalink
MapR [SPARK-170] StackOverflowException in equals method in DBMapValue (
Browse files Browse the repository at this point in the history
  • Loading branch information
ekrivokonmapr authored and mgorbov committed Mar 7, 2018
1 parent 77ed36f commit 5a390c1
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 9 deletions.
7 changes: 7 additions & 0 deletions external/maprdb/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_${scala.binary.version}</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-streaming_${scala.binary.version}</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,12 @@ private[spark] final class DBMapValue(
override def hashCode(): Int = this.keySet.size

override def equals(other: Any): Boolean = {
if (other.isInstanceOf[DBMapValue]) {
val that: DBMapValue = other.asInstanceOf[DBMapValue]
this == that
} else if (other.isInstanceOf[Map[_, _]]) {
val that: DBMapValue = new DBMapValue(
other.asInstanceOf[Map[String, AnyRef]])
this.getMap == that
} else false

other match {
case _: Map[_, _] =>
val that: DBMapValue = new DBMapValue(
other.asInstanceOf[Map[String, AnyRef]])
this.getMap == that
case _ => false
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/* Copyright (c) 2015 & onwards. MapR Tech, Inc., All rights reserved */
package com.mapr.db.spark.types

import org.apache.spark.SparkFunSuite

class DBMapValueTest extends SparkFunSuite {
test("Check DBMapValue equals method") {
val map = Map("1" -> "2", "a" -> "b")
val dbMapValue = new DBMapValue(map)
val dbMapValueOther = new DBMapValue(map)

assert(!dbMapValue.equals("StringType"))
assert(dbMapValue.equals(map))
assert(dbMapValue.equals(dbMapValueOther))
}
}

0 comments on commit 5a390c1

Please sign in to comment.