How to list all row keys in an hbase table? How to list all row keys in an hbase table? hadoop hadoop

How to list all row keys in an hbase table?


If you are listing all of the keys in an HBase table, then you are using the wrong tool. HBase is for large data systems where it is impractical to list all of the keys.

What may be more sensible is to start at a given key and list the next N keys (for values of N less than 10K). There are nice Java interfaces for doing this type of thing with a scan -- setting a start key and/or an end key.

Most HBase functionality is exposed via the Thrift interface. I would suggest looking there


I have found a way..

http://localhost:8080/tablename/* will return an xml data and i can preg-match it to get the rows.

Inviting better suggestions..


I don't know what the REST interface is like, but you probably want to filter some data out client-side to avoid large RPC responses. You can do this by adding server-side filters to your scan:

Scan s = new Scan();FilterList fl = new FilterList();// returns first instance of a row, then skip to next rowfl.addFilter(new FirstKeyOnlyFilter());// only return the Key, don't return the valuefl.addFilter(new KeyOnlyFilter());s.setFilter(fl);HTable myTable;ResultScanner rs = myTable.getScanner(s);Result row = rs.next();while (row != null) ...

http://svn.apache.org/repos/asf/hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/filter/