【问题标题】:Write Avro in ruby and read in Python用 ruby​​ 编写 Avro 并用 Python 读取
【发布时间】:2016-07-20 19:22:14
【问题描述】:

我在尝试将用 Ruby 编写的 Avro 字节解码为 Kafka 主题时遇到了问题。在观察 avro 字节字符串时,我可以看到它看起来不错。但是当我尝试解码时,我得到一个 'UnicodeDecodeError: 'utf8' codec can't decode byte 0x98 in position 32: invalid start byte'。

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)

谢谢。

【问题讨论】:

    标签: python ruby avro


    【解决方案1】:

    这样修改代码解决了问题

    bytes_reader = io.BytesIO(msg.value)
    reader = DataFileReader(bytes_reader, DatumReader())
    for r in reader:
        print r
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-06-28
      • 2019-07-08
      • 1970-01-01
      • 1970-01-01
      • 2017-07-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多