HBase REST 过滤器(SingleColumnValueFilter)
我无法弄清楚如何在 HBase REST 接口(HBase 0.90.4-cdh3u3)中使用过滤器。该文档只是为我提供了“字符串”的模式定义,但没有显示如何使用它。
因此,我可以执行以下操作:
curl -v -H 'Content-Type: text/xml' -d '<Scanner startRow="ddo" stopRow="ddp" batch="1024"/>' 'http://hbasegw:8080/table/scanner'
然后检索 with
curl -s -H "Content-Type: text/xml" http://hbasegw:8080/table/scanner/13293426893883128482b | tidy -i -q -xml
但现在我想使用 SingleColumnValueFilter 并且必须以某种方式在 XML 中对其进行编码。 有人有这方面的例子吗?
谢谢, 马里奥
I cannot figure out how to use filters in the HBase REST interface (HBase 0.90.4-cdh3u3). The documentation just gives me a schema definition for a "string", but doesn't show how to use it.
So, I'm able to do this:
curl -v -H 'Content-Type: text/xml' -d '<Scanner startRow="ddo" stopRow="ddp" batch="1024"/>' 'http://hbasegw:8080/table/scanner'
and then retrieve with
curl -s -H "Content-Type: text/xml" http://hbasegw:8080/table/scanner/13293426893883128482b | tidy -i -q -xml
But now I want to use a SingleColumnValueFilter and have to encode that somehow in the XML.
Does anyone have an example for this?
Thanks,
Mario
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
扫描仪 XML 中的过滤器字段是格式化为 JSON 的字符串。由于过滤器的 JSON 中包含许多引号,因此我建议为curl 的 -d 参数使用单独的文件,以避免使用单引号。
curl -v -H "Content-Type:text/xml" -d @args.txt http://hbasegw:8080/table/scanner
文件所在位置
args.txt
是:如何发现 JSON 过滤器字符串应该是什么样子?这是一种通过 Java 代码的简单方法,根据来自 HBase 的 Java API 的标准 Filter 对象,吐出字符串化过滤器。
请注意,JSON 和 XML 需要以 Base64 编码的数据。我已经在桌子上测试了上面的curl命令,它工作得很好。
如果您想知道,是的,扫描仪的 REST API 尚未对开发人员那么友好。
Filter fields in the Scanner XML are strings formatted as JSON. Since the JSON for the filter has many quotes in it, I recommend using a separate file for curl's -d parameter, to avoid the single quote.
curl -v -H "Content-Type:text/xml" -d @args.txt http://hbasegw:8080/table/scanner
Where the file
args.txt
is:How do you discover how the JSON filter string should look like? Here's an easy way through Java code that spits out the stringified filter given a standard Filter object from HBase's Java API.
Notice that the JSON and the XML require data encoded in Base64. I've tested the above curl command on a table and it worked just fine.
In case you are wondering, yes, the REST API for scanners is not yet as developer-friendly as it can get.