wangyum commented on a change in pull request #23788: [SPARK-27176][SQL]
Upgrade hadoop-3's built-in Hive maven dependencies to 2.3.4
URL: https://github.com/apache/spark/pull/23788#discussion_r269521648
##########
File path: sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveShim.scala
##########
@@ -146,34 +145,60 @@ private[hive] object HiveShim {
case _ => false
}
- @transient
- def deserializeObjectByKryo[T: ClassTag](
- kryo: Kryo,
- in: InputStream,
- clazz: Class[_]): T = {
- val inp = new Input(in)
- val t: T = kryo.readObject(inp, clazz).asInstanceOf[T]
- inp.close()
- t
- }
+ private lazy val serUtilClass =
+
Utils.classForName("org.apache.hadoop.hive.ql.exec.SerializationUtilities")
+ private lazy val utilClass =
Utils.classForName("org.apache.hadoop.hive.ql.exec.Utilities")
+ private val deserializeMethodName = "deserializeObjectByKryo"
+ private val serializeMethodName = "serializeObjectByKryo"
- @transient
- def serializeObjectByKryo(
- kryo: Kryo,
- plan: Object,
- out: OutputStream) {
- val output: Output = new Output(out)
- kryo.writeObject(output, plan)
- output.close()
+ private def findMethod(klass: Class[_], name: String, args: Class[_]*):
Method = {
+ val method = klass.getDeclaredMethod(name, args: _*)
+ method.setAccessible(true)
+ method
}
def deserializePlan[UDFType](is: java.io.InputStream, clazz: Class[_]):
UDFType = {
- deserializeObjectByKryo(Utilities.runtimeSerializationKryo.get(), is,
clazz)
- .asInstanceOf[UDFType]
+ if (HiveUtils.isHive2) {
Review comment:
Hive 2.x([HIVE-12302](https://issues.apache.org/jira/browse/HIVE-12302)):
```scala
import org.apache.hadoop.hive.ql.exec.SerializationUtilities
val kryo = SerializationUtilities.borrowKryo()
try {
SerializationUtilities.deserializeObjectByKryo(kryo, is,
clazz).asInstanceOf[UDFType]
} finally {
SerializationUtilities.releaseKryo(kryo)
}
```
Hive 1.x:
```scala
import org.apache.hadoop.hive.ql.exec.Utilities
Utilities.deserializeObjectByKryo(Utilities.runtimeSerializationKryo.get(),
is, clazz)
.asInstanceOf[UDFType]
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]