如何将二进制数据存储在Hive中? [英] How to Store Binary Data in Hive?

查看:2116
本文介绍了如何将二进制数据存储在Hive中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



任何人都可以给我一个关于如何在Hive中存储二进制数据(例如图片)的示例查询。



在此先感谢...

解决方案

在Hive中,您将文件存储在HDFS中,添加元数据告诉Hive哪种类型的字段在文件中的每个位置(文本文件中的分隔符和分隔符,不同二进制格式的行...)

您可以生成自己的输出并将其与输入和输出格式一起使用。可以将图像转换为像BASE64一样的附件并使用TextFile ....很多可能性,但不是用于存储图像的查询。



您可以有继续TextFile示例,但不是最好的方法,这种格式的文件:

1; image1.jpg; 65400 ;< BASE64_DATA>



加载配置单元:

  CREATE TABLE img_store(
id INT
,filename STRING
,size BIGINT
,data STRING
);
LOAD DATA INPATH'/ where / your / file / is / in / HDFS'
INTO TABLE img_Store;

如果您使用Hive +0.8的版本,则可以在表定义中使用DataType BINARY并加载它。



问候。


I am learning Hive.

Could anyone please give me an example query regarding how to store binary data (For e.g., Images) in Hive.

Thanks in Advance...

解决方案

In Hive you store Files in HDFS and add metadata to tell Hive which kind of field are you waiting to be in each position in the file( separator and delimitators in text file, rows in different binary formats...)

You can generate your own output and use it with Input and Outpu formats. Can convert images to, as example BASE64 like an attachment and use a TextFile.... Lot of possibilities, but not a "query" to store images.

You could have, to continue the TextFile Example but is not the "best method", a file with this format:

1;image1.jpg;65400;<BASE64_DATA>

And load in hive:

CREATE TABLE img_store(
   id INT
   , filename STRING
   , size BIGINT
   , data STRING
);
LOAD DATA INPATH '/where/your/file/is/in/HDFS' 
INTO TABLE img_Store;

If you use a version of Hive +0.8 you can use the DataType BINARY in the table definition and load it.

Regards.

这篇关于如何将二进制数据存储在Hive中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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