找不到请求操作的编解码器:[list <watson.destination_intent>&lt; - &gt; scala.collection.immutable $结肠结肠$]

时间:2017-04-29 00:02:27

标签: cassandra user-defined-types

尝试使用UserDefinedType列表时,我收到CodecNotFoundException 我已经注册了UDT的编解码器,当我尝试使用UDT列表时会发生这种情况

com.datastax.driver.core.exceptions.CodecNotFoundException: Codec not found for requested operation: [list<watson.destination_intent> <-> scala.collection.immutable.$colon$colon]
at com.datastax.driver.core.CodecRegistry.notFound(CodecRegistry.java:741)
at com.datastax.driver.core.CodecRegistry.createCodec(CodecRegistry.java:602)
at com.datastax.driver.core.CodecRegistry.findCodec(CodecRegistry.java:582)
at com.datastax.driver.core.CodecRegistry.codecFor(CodecRegistry.java:507)
at com.datastax.driver.core.AbstractGettableByIndexData.codecFor(AbstractGettableByIndexData.java:77)
at com.datastax.driver.core.BoundStatement.bind(BoundStatement.java:201)
at com.datastax.driver.core.DefaultPreparedStatement.bind(DefaultPreparedStatement.java:126)
at com.expedia.www.watson.flink.jobs.CassandraListOutputFormat.writeRecord(TravelerProfileLoadJob.scala:218)
at com.expedia.www.watson.flink.jobs.CassandraListOutputFormat.writeRecord(TravelerProfileLoadJob.scala:173)
at com.expedia.www.watson.sdk.flink.outputs.RateLimitingOutputFormat.writeRecord(RateLimitingOutputFormat.scala:36)
at org.apache.flink.runtime.operators.DataSinkTask.invoke(DataSinkTask.java:192)
at org.apache.flink.runtime.taskmanager.Task.run(Task.java:642)
at java.lang.Thread.run(Thread.java:745)

2 个答案:

答案 0 :(得分:0)

原来问题在于scala和java转换。 由于驱动程序是用java编写的,而我使用scala传递列表,因此在尝试动态创建编解码器时失败了。 一旦我将列表更改为java.util.list,它就开始工作了。

答案 1 :(得分:0)

以下内容对我有用

import scala.collection.JavaConverters._
import scala.collection.JavaConversions._

val list: List[String] = InputString.split(",").toList

val javaList = list.asJava

Ex: connector.withSessionDo { session => session.execute(session.prepare(selectQuery).setConsistencyLevel(ConsistencyLevel.LOCAL_ONE).bind(javaList, field)) }