java - How to get all the rows given a part of the row key in Hbase -


i have following table structure in hbase:

row               column+cell  mary_ann_05/10/2013 column=cf:verified, timestamp=234454454,value=2,2013-02-12   mary_ann_06/10/2013 column=cf:verified, timestamp=2345454454,value=3,2013-02-12  mary_ann_07/10/2013 column=cf:verified, timestamp=2345454522454,value=4,2013-02-12  mary_ann_08/10/2013 column=cf:verified, timestamp=23433333454,value=1,2013-12-12  

i want retrieve records start mary_ann using java. how do that?

you achieve using prefixfilter. given prefix, specified when instantiate filter instance, rows match prefix returned client. constructor : public prefixfilter(byte[] prefix)

usage :

filter filter = new prefixfilter(bytes.tobytes("mary_ann")); scan scan = new scan(); scan.setfilter(filter); resultscanner scanner = table.getscanner(scan); (result result : scanner) {      (keyvalue kv : result.raw()) {         system.out.println("kv: " + kv + ", value: " +         bytes.tostring(kv.getvalue()));      } } scanner.close(); 

hth


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -