您可以将数据附加到现有的Avro数据文件中吗? [英] Can you append data to an existing Avro data file?

查看:71
本文介绍了您可以将数据附加到现有的Avro数据文件中吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

似乎没有任何方法可以将数据附加到现有的Avro序列化文件中.我想有多个进程写入单个avro文件,但是每次打开文件时,我似乎都是从头开始.我不想读所有数据,然后再写回去.

It seems like there isn't any way to append data to an existing Avro serialized file. I'd like to have multiple processes writing to a single avro file, but it looks like each time I open it, I start over from scratch. I don't want to read in all the data and then write it back out again.

使用红宝石示例代码,我尝试将"ab"和"ab +"作为各种设置,但没有任何乐趣.

Using the ruby example code I have tried "ab" and "ab+" as various settings, but no joy.

file = File.open('data.avr', 'wb')
schema = Avro::Schema.parse(SCHEMA)
writer = Avro::IO::DatumWriter.new(schema)
dw = Avro::DataFile::Writer.new(file, writer, schema)
dw << {"username" => "john", "age" => 25, "verified" => true}
dw << {"username" => "ryan", "age" => 23, "verified" => false}
dw.close

推荐答案

不要将架构附加到文件中

don't pass the schema to append to the file

这篇关于您可以将数据附加到现有的Avro数据文件中吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆