我正面临着尝试将用Ruby编写的Avro字节解码为Kafka主题的问题。在观察avro字节字符串时我可以看到它看起来很好。但是当我尝试解码时,我得到一个'UnicodeDecodeError:'utf8'编解码器无法解码位置32的字节0x98:无效的起始字节'。
import avro.schema
import avro.io
import io
bytes_reader = io.BytesIO(m.value)
decoder = avro.io.BinaryDecoder(bytes_reader)
reader = avro.io.DatumReader(schema)
print reader.read(decoder)
感谢。
答案 0 :(得分:0)
以这种方式修改代码解决了问题
bytes_reader = io.BytesIO(msg.value)
reader = DataFileReader(bytes_reader, DatumReader())
for r in reader:
print r