我有以下代码将rdd保存到cassandra:
JavaRDD<UserByID> mapped = ......
CassandraJavaUtil.javaFunctions(mapped)
.writerBuilder("mykeyspace", "user_by_id", mapToRow(UserByID.class)).saveToCassandra();
以及 UserByID
是一个普通的可序列化pojo,包含以下带有getter和setter的变量
private UUID userid;
cassandra表有完全相同的类userbyid变量的名称,并且userid是cassandra表中的uuid类型,我正在使用相同的类Map从表中成功加载数据。
CassandraJavaRDD<UserByID> UserByIDRDD = javaFunctions(spark)
.cassandraTable("mykeyspace", "user_by_id", mapRowTo(UserByID.class));
但是,当我打电话的时候 saveToCassandra
在上面的函数中,我得到以下异常:
org.apache.spark.SparkException: Job aborted due to stage failure: Task
0 in stage 227.0 failed 1 times, most recent failure: Lost task 0.0
in stage 227.0 (TID 12721, localhost, executor driver):
java.lang.IllegalArgumentException:
The value (4e22e71a-a387-4de8-baf1-0ef6e65fe33e) of the type
(java.util.UUID) cannot be converted to
struct<leastSignificantBits:bigint,mostSignificantBits:bigint>
为了解决这个问题,我注册了uuid编解码器,但是没有帮助,我使用 spark-cassandra-connector_2.11
版本2.4.0和 spark-core_2.11
有什么建议吗?
我的参考是在这里,但它没有java uuid的例子,你的帮助是感激的。
1条答案
按热度按时间r3i60tvu1#
这是一个非常奇怪的错误-对于connector 2.4.0和spark 2.2.1,这一错误可以正常工作,示例如下:
表定义:
pojo类:
Spark作业:
我注意到在你的代码中你使用了函数
mapRowTo
以及mapToRow
不打电话给.class
在pojo上-您确定您的代码已经编译并且没有运行任何旧版本的代码吗?