简体   繁体   中英

How to set start and end row key HBASE

If i have row keys like

a_c
b_c
j_f
f_d
d_c

I should get all the rows matching _c. How to set start and stop row key here . I am trying to get the scan result out of start and stop row key and not with rowfilter or other filter types.

You can write your own filter function if you don't want to use RowFilter . But I suggest you to use PrefixFilter if you can't write your own filter function and don't want to use RowFilter

Example for Java:

byte[] prefixF= Bytes.toBytes("_c");
Scan scan = new Scan(prefixF));
PrefixFilter prefixFilter = new PrefixFilter(prefixF);
scan.addFilter(prefixFilter);
ResultScanner resultScanner = table.getScanner(scan);

Above code is equal to hbase> scan 'YourTablename', { FILTER => "PrefixFilter('_c')"}

You can use Hbase STARTROW and ENDROW filter. It basically scans data between the rowkey range (ENDROW excluded).

 scan 'table_name', {STARTROW=>"<start_row_key>", ENDROW=>"<end_row_key>"}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM