Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Threaded View
HBase >> mail # user >> Reading table sequentially...

Copy link to this message
Reading table sequentially...
I know I am doing something really dumb, so apologies in advance.

All I want to do is to read a table sequentially.  I tried several versions
of this, but nothing gives me the "value of the Key".  I am sure there's an
easier way.... please help.  Thanks.

        HTable table;
        table = new HTable(new HBaseConfiguration(), "mytable");
        Scan scan = new Scan();
        // scan.addFamily("myfamily");

        ResultScanner scanner = table.getScanner(scan);
        Result result;
        while ((result = scanner.next()) != null) {
            NavigableMap<byte[], NavigableMap<byte[], NavigableMap<Long,
byte[]>>> map = result.getMap();
            for (Map.Entry<byte[], NavigableMap<byte[], NavigableMap<Long,
byte[]>>> entry : map.entrySet()) {
            byte[] key = entry.getKey();
            *LOG.info("key = " + Bytes.toString(key));*
            NavigableMap<byte[], NavigableMap<Long, byte[]>> value entry.getValue();
              for (Entry<byte[], NavigableMap<Long, byte[]>> entry1 :
value.entrySet()) {
                  byte[] key1 = entry1.getKey();
                  *LOG.info("key1 = " + Bytes.toString(key1));*
                  NavigableMap<byte[], NavigableMap<Long, byte[]>> value1 entry.getValue();
                  for (Entry<byte[], NavigableMap<Long, byte[]>> entry2 :
value1.entrySet()) {
                      String key2 = Bytes.toString(entry2.getKey());
                      *LOG.info("key2 = " + key2);*