How to lookup HBase REST API (Stargate) if the row-keys are reversed urls

回眸只為那壹抹淺笑 提交于 2019-12-07 21:10:01

问题


I am using nutch2.2.1 + hbase0.90.4, and wanting to access the data via the HBase REST API Stargate. If I seed nutch with a url (eg. www.usatoday.com), the reversed url becomes the HBase row-key in the designated table ('webpage'). I can lookup the data via the hbase shell as follows:

hbase(main):001:0> get 'webpage', 'com.usatoday.www:http/'
COLUMN                                         CELL                                                                                                                                 
 f:fi                                          timestamp=1404762373394,value=\x00'\x8D\x00                                                                                         
 f:ts                                          timestamp=1404762373394, value=\x00\x00\x01G\x12\\xB5\xB3                                                                            
 mk:_injmrk_                                   timestamp=1404762373394, value=y                                                                                                     
 mk:dist                                       timestamp=1404762373394, value=0                                                                                                     
 mtdt:_csh_                                    timestamp=1404762373394, value=?\x80\x00\x00                                                                                         
 s:s                                           timestamp=1404762373394, value=?\x80\x00\x00       

However, I am having trouble using the REST API. Presumably I need to do some pretty simple URL encoding to suppress the colon before 'http' that is making trouble for me?

For eg., I get a HTTP 404 when I try

curl http://localhost:8900/webpage/com.usatoday.www:http/

also when I try

curl http://localhost:8900/webpage/com.usatoday.www%3Ahttp/

I know that the REST API is working fine as I can create a row called 'row3' into a table called 'test' and lookup

curl http://localhost:8900/test/row3  

to see the following expected result:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?><CellSet><Row key="cm93Mw=="><Cell timestamp="1404761922130" column="Y2Y6Yw==">dGhpcyBpcyBzb3J0YSB3b3JraW5nIG5vdw==</Cell></Row></CellSet>

Thanks for the help!


回答1:


Needed to URL encode the forward slash as well. The following works.

curl http://localhost:8900/webpage/com.usatoday.www%3Ahttp%2F


来源:https://stackoverflow.com/questions/24734045/how-to-lookup-hbase-rest-api-stargate-if-the-row-keys-are-reversed-urls

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!