本文介绍了avro php-从缓冲区读取的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用avro编写反序列化数据的php脚本.我收到的数据作为avro二进制流的缓冲区.在avro php示例中,我仅看到一个从文件读取数据的示例.不是二进制缓冲区.
I am writing a php script using avro to deserialize data.I receive the data as a buffer of avro binary stream.In the avro php example, I see only an example of reading the data from a file. not a binary buffer.
如何反序列化数据?我正在寻找的是avro的二进制解码器
How can I deserialize the data?What I am looking for is a binary decoder for avro
推荐答案
$binaryBuffer = <get_avro_serialized_record>
$writersSchema = '{
"type" : "record",
"name" : "Example",
"namespace" : "com.example.record",
"fields" : [ {
"name" : "userId",
"type" : "int"
.............
}'
$reader = new AvroIODatumReader($writersSchema);
$io = new AvroStringIO($binaryBuffer)
$deserializedRecord = $reader->read(new AvroIOBinaryDecoder($io))
假设您要对每个记录分别反序列化,并具有writers模式.
assuming you want to deserialize each record separately, and have the writers schema.
这篇关于avro php-从缓冲区读取的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!