使用avro工具Concat Avro文件 [英] Concat Avro files using avro-tools

查看:441
本文介绍了使用avro工具Concat Avro文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图将avro文件合并成一个大文件,问题是 concat 命令不接受通配符

  hadoop jar avro-tools.jar concat / input / part * /output/bigfile.avro 

我得到:


线程main中的异常java.io.FileNotFoundException:文件
不存在:/ input / part *


我尝试使用''但没有机会。

解决方案

我很快检查了Avro的源代码(1.7.7),似乎concat不支持glob模式(基本上,它们除了最后一个参数之外,对每个参数调用 FileSystem.open())。

这意味着你必须显式地提供所有文件名作为参数。它很麻烦,但下面的命令应该做你想做的:

  IN = $(hadoop fs -ls / input / part * | awk'{printf%s,$ NF}')
hadoop jar avro-tools.jar concat $ {IN} /output/bigfile.avro

这个命令中增加了对glob模式的支持是一个很好的补充。


Im trying to merge avro files into one big file, the problem is concat command does not accept the wildcard

hadoop jar avro-tools.jar concat /input/part* /output/bigfile.avro

I get:

Exception in thread "main" java.io.FileNotFoundException: File does not exist: /input/part*

I tried to use "" and '' but no chance.

解决方案

I quickly checked Avro's source code (1.7.7) and it seems that concat does not support glob patterns (basically, they call FileSystem.open() on each argument except the last one).

It means that you have to explicitly provide all the filenames as argument. It is cumbersome, but following command should do what you want:

IN=$(hadoop fs -ls /input/part* | awk '{printf "%s ", $NF}')
hadoop jar avro-tools.jar concat ${IN} /output/bigfile.avro

It would be a nice addition to add support of glob pattern to this command.

这篇关于使用avro工具Concat Avro文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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