What is the best approach to perform updations on Hadoop File System ? For Instance I have one avro file which contains data, for the next run I need to update the data in the avro file itself.How can we approach this problem ?
Ex : I have the below data on HDFS, need to update the "subDistricts" array for the next time
{ "name": "DistrictName", "_class": "org.bitbucket.codezarvis.api.dto.DistrictDocument", "type": "district", "subDistricts": [ 256, 257 ] }
答案 0 :(得分:0)
HDFS被设计为一次写入,仅附加文件系统。这表示你有几个选项来执行update-ish操作:
建议 - 如果你在hadoop中发现自己处于这种情况,重新考虑hadoop是否是最佳选择。 ACID最好由SQL解决方案完成。
答案 1 :(得分:0)
模式演变是修改模式而不重写现有数据的通用概念。 如果数据作为AVRO存储在Hive表中(基础数据存储在HDFS中),则可以更改模式。 (虽然也有一些限制)。
答案 2 :(得分:0)
我还想出了一个approch和Document的设计
setx GOOGLE_APPLICATION_CREDENTIALS <path_to_service_account_file>
包含Diff条目的AVRO文件,其中包含必须应用于下一次运行的增量。
Diff包含一个或多个彼此关系的Diff条目。
Diff包含每个已修改,删除或添加的Sub区域条目,其中包含“之前”和“之后”信息。
如果与上一次运行相比添加了subDistrict,则“before”将为null。 如果与上一次运行相比删除了subDistrict,则“after”将为null。
如果与上一次运行相比修改了subDistrict,则“before”和“after”都将存在。
输出中存在增量记录可能有以下原因: 与HDFS上的输出相比,该区域已更改,添加或删除。