diff options
author | Marcelo Vanzin <vanzin@cloudera.com> | 2016-07-20 10:38:44 -0700 |
---|---|---|
committer | Marcelo Vanzin <vanzin@cloudera.com> | 2016-07-20 10:38:44 -0700 |
commit | e3cd5b3050711af69fc1dfc518b11bf1a86b6a4c (patch) | |
tree | 962153906aa7420f6aefda2e6bf878ee41dea8c8 /sql/catalyst/src | |
parent | b9bab4dcf6cec5ec9e9860871f9dd1ec633a1d22 (diff) | |
download | spark-e3cd5b3050711af69fc1dfc518b11bf1a86b6a4c.tar.gz spark-e3cd5b3050711af69fc1dfc518b11bf1a86b6a4c.tar.bz2 spark-e3cd5b3050711af69fc1dfc518b11bf1a86b6a4c.zip |
[SPARK-16634][SQL] Workaround JVM bug by moving some code out of ctor.
Some 1.7 JVMs have a bug that is triggered by certain Scala-generated
bytecode. GenericArrayData suffers from that and fails to load in certain
JVMs.
Moving the offending code out of the constructor and into a helper method
avoids the issue.
Author: Marcelo Vanzin <vanzin@cloudera.com>
Closes #14271 from vanzin/SPARK-16634.
Diffstat (limited to 'sql/catalyst/src')
-rw-r--r-- | sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/GenericArrayData.scala | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/GenericArrayData.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/GenericArrayData.scala index 3a665d3708..7ee9581b63 100644 --- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/GenericArrayData.scala +++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/GenericArrayData.scala @@ -23,6 +23,16 @@ import org.apache.spark.sql.catalyst.InternalRow import org.apache.spark.sql.types.{DataType, Decimal} import org.apache.spark.unsafe.types.{CalendarInterval, UTF8String} +private object GenericArrayData { + + // SPARK-16634: Workaround for JVM bug present in some 1.7 versions. + def anyToSeq(seqOrArray: Any): Seq[Any] = seqOrArray match { + case seq: Seq[Any] => seq + case array: Array[_] => array.toSeq + } + +} + class GenericArrayData(val array: Array[Any]) extends ArrayData { def this(seq: Seq[Any]) = this(seq.toArray) @@ -37,10 +47,7 @@ class GenericArrayData(val array: Array[Any]) extends ArrayData { def this(primitiveArray: Array[Byte]) = this(primitiveArray.toSeq) def this(primitiveArray: Array[Boolean]) = this(primitiveArray.toSeq) - def this(seqOrArray: Any) = this(seqOrArray match { - case seq: Seq[Any] => seq - case array: Array[_] => array.toSeq - }) + def this(seqOrArray: Any) = this(GenericArrayData.anyToSeq(seqOrArray)) override def copy(): ArrayData = new GenericArrayData(array.clone()) |