反序列化方法:
override def deserialize(bytes: ByteBuffer, protocolVersion: ProtocolVersion): UserType = {
Option(bytes) match {
case Some(value) if value.remaining == 0 =>
throw new Exception(s"Cannot Deserialize empty bytes Array!!!! $this.getClass")
case Some(value) =>
val byteArray = new Array[Byte](bytes.remaining)
bytes.duplicate.get(byteArray)
objectMapper.readValue[java.util.List[UserType]] (byteArray, classOf[java.util.List[UserType]] ).get(0)
case _ =>
null
}
}
我可以通过自定义编解码器读取列的字节。但是,它的反序列化失败并出现错误
java.io.charconversionexception:char#3处的utf-32字符0x314c5555(高于0x0010ffff)无效,字节15)位于com.fasterxml.jackson.core.io.utf32reader.reportinvalid(utf32reader)。java:195)在com.fasterxml.jackson.core.io.utf32reader.read(utf32reader。java:158)位于com.fasterxml.jackson.core.json.readerbasedjsonparser.\u loadmore(readerbasedjsonparser)。java:250)在com.fasterxml.jackson.core.json.readerbasedjsonparser.\u skipwsorend(readerbasedjsonparser。java:2354)位于com.fasterxml.jackson.core.json.readerbasedjsonparser.nexttoken(readerbasedjsonparser)。java:672)在com.fasterxml.jackson.databind.objectmapper.\u initforreading(objectmapper。java:4340)在com.fasterxml.jackson.databind.objectmapper.\u readmapandclose(objectmapper。java:4189)在com.fasterxml.jackson.databind.objectmapper.readvalue(objectmapper。java:3266)
如何反序列化接收到的字节?
cassandra中的类型定义是
CREATE TYPE canada_catalog.UserType (id text, flag1 BOOLEAN,flag2 BOOLEAN);
Cassandra柱属于 frozen<list<frozen<usertype>>>
暂无答案!
目前还没有任何答案,快来回答吧!