如何从 HBase 获取图像
我的 HDFS 中有大约 1 Gig 的图像 .png 文件。任何人都可以建议我一种将这些图像的索引值存储在 HBase 中并通过查询 HBase 检索图像的方法。或者我如何使用 HDFS/HBase 来提供图像。请回复。
紧急要求:(
提前致谢
I have around 1 Gig of image .png files in my HDFS. Can anyone suggest me a way to store the index values to these images in HBase and retrieve the image by querying HBase. Or how can I used HDFS/HBase to serve images. Pls reply .
Urgent requirement :(
Thanks In Advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
下面的代码会有帮助。
The following code will help.
提供图像文件有两种基本方法:将图像存储在 HBase 本身中,或者存储图像的路径。 HBase 已成功被大型商业照片共享网站用于存储和检索图像 - 尽管他们必须仔细调整和监控其系统(有关详细信息,请参阅 HBase 邮件列表)。
如果您将图像存储在 HDFS 上并且仅在 HBase 中保留路径,则必须确保不会有太多图像,因为 HDFS 不能很好地处理大量文件(取决于分配给名称节点的 RAM 大小,但仍有上限)。
除非您计划将元数据与每个图像一起存储,否则您可能可以使用非常简单的模式来存储数据或图像的路径。我想象的是一个带有两个列限定符的单列族:数据和类型。数据列可以存储路径或实际图像字节。该类型将存储图像类型(png、jpg、tiff 等)。这对于在返回图像时通过线路发送正确的 mime 类型非常有用。
一旦你完成了这个设置,你所需要的只是一个 servlet(或者 thrift 中的类似东西)来组装数据并将其返回给客户端。
There are two basic ways of serving image files: storing the image in HBase itself, or storing a path to the image. HBase has successfully been used by a large-scale commercial photo sharing site for storing and retrieving images -- although they have had to carefully tune and monitor their system (see the HBase mailing list for details).
If you store your images on HDFS and only keep a path in HBase you will have to ensure that you will not have too many images as HDFS does not deal well with a lot of files (depends on the size of RAM allocated to your namenode, but there is still an upper limit).
Unless you plan on storing meta data along with each image, you may be able to get away with a very simple schema for either storing the data or the path to the image. I am imagining something like a single column family with two column qualifiers: data, and type. The data column could store either the path or the the actual image bytes. The type would store the image type (png, jpg, tiff, etc.). This would be useful for sending the correct mime type over the wire when returning the image.
Once you have that set up, all you need is a servlet (or something equivalent in thrift) to assemble the data and return it to the client.