我试图在spark中使用kryo序列化程序。我已设置select
table1.email,
table1.emailID,
min(table2.customerid),
sum(table3.purchases)
from
table1
inner join table2 on table1.email=table2.email
inner join table3 on table2.customerID=table3.customerid
group by
table1.email,
table1.emailID,
table2.email
以确保我注册了所有必要的课程。除了要求我注册我的自定义类之外,还要求我注册spark类,如spark.kryo.registrationRequired=true
。
虽然我已注册了火花StructType
,但现在崩溃说我需要注册StringType
。
StringType$
我正在导入spark implicits以便在json中读取。我不确定这是否会导致问题。
com.esotericsoftware.kryo.KryoException (java.lang.IllegalArgumentException: Class is not registered: org.apache.spark.sql.types.StringType$
Note: To register this class use: kryo.register(org.apache.spark.sql.types.StringType$.class);
Serialization trace:
dataType (org.apache.spark.sql.types.StructField)
fields (org.apache.spark.sql.types.StructType))
我确实认为将注册设置为false会停止此错误,但在这种情况下我没有看到任何性能提升,所以我试图确保我注册了所有必要的类。
答案 0 :(得分:1)
我遇到了同样的问题,经过一些实验,我设法用以下一行来解决它:
Class.forName("org.apache.spark.sql.types.StringType$")
这样你就可以在Kryo中注册这个课程并停止抱怨。
干杯