Hbase REST操作Json格式

来源:互联网 发布:2017淘宝新店扶持多久 编辑:程序博客网 时间:2024/06/05 17:19

以下操作均在chrome的postman中完成,这个小插件很适合做rest调试,推荐。


Table相关操作:

建表:    POST(or PUT)——http://192.168.1.107:8000/test/schema

Request Body:

 

Response Headers:


获取表的模式(schema):  GET——http:// 192.168.1.107:8000/test /schema

Response Headers:


Response Body:


修改表的模式(schema):

修改表的模式根据需求可用POST和PUT完成,与建表时的请求URL和Request Body模式相同。但POST的执行过程为update,而PUT为overwrite;另外每次执行PUT请求后response headers均含有location参数,POST没有。

针对表test分别执行POST和PUT操作,均使用如下request body:


POST——http:// 192.168.1.107:8000/test/schema:

Response Headers:


修改后的表test模式为:


PUT——http:// 192.168.1.107:8000/test/schema:

Response Headers:


修改后的表test模式为:


列出表的域(regions):            GET——http:// 192.168.1.107:8000/test/regions

Response Headers:


Response Body:

     

删除表:       DELETE——http://192.168.1.107:8000/test/schema

Response Headers:


如果删除不存在的表会报错——NOT FOUND!

 

往表中插入数据:     PUT——http://192.168.1.107:8000/test/row1

待插入数据row、column、value值都需要经过base64_encode,具体格式如下request body所示:

Request Body:

 

另外经过测试,请求URL最后的参数row_key,本例中的’row1’,可以为任意字符串,只要不为空均可正常运行插入数据,插入行只与JSON串中的’key’值有关。

 

获得表中一行的数据:    GET——http://192.168.1.107:8000/test/row1

Response Body:


获得表中一列的数据:    GET——http://192.168.1.107:8000/test/row1/family1:test1

Response Body:

 

获得表中一列的前V个版本的数据:

GET——http://192.168.1.107:8000/test/row1/family1:test1?v=3

Response Body:


Scanner相关操作:

生成一个scanner:   PUT——http://192.168.1.107:8000/test/scanner/

Request Body:


Response Headers:


其中返回头部中的location为生成的scanner地址,使用这个地址来操作和释放scanner。

 

利用scanner获取next batch的数据:

GET——http://192.168.1.107:8000/test/scanner/14876867455073273d766

Response Body:


删除一个scanner:   

DELETE——http://192.168.1.107:8000/test/scanner/14876867455073273d766

0 0