Data read hbase salt (Part coprocessor)

Each region has startkey and EndKey, coprocessor code is performed on the region, and when the code is executed on the region, we can get information about the current region, comprising startkey and EndKey, and then we can use startkey rowkey splicing, can be found on the data we need.

1) the definition of proto file: This file is the definition of a query because we need to pass parameters, such as tablename, startkey, endkey and whether salt, etc., and we query the data, the data needs to be returned.

2) preparation of a coprocessor Code: RowCountEndpoint hbase sample code and provide very similar, the main logic function implemented inside the queryByStartRowAndEndRow. We got the table, StartKey and EndKey data such as client queries by DataQueryRequest. By this.env.getRegion (). GetRegionInfo (). GetStartKey () can get the current Region of StartKey, and then the client passed in StartKey and EndKey splicing can get a complete Rowkey prefix. The rest of the query is normal HBase Scan code.

Guess you like

Origin www.cnblogs.com/ww5566/p/11459514.html