Search code examples
hbasecolumn-familynosql

How to get column family and qualifier of a HBase Table


I want to use the following:

List<Cell> cells = sourcePut.get(CfBytes, QualBytes);

But it is returning me an empty list, since I am not specifying the correct column family and/or correct qualifier.

For my source table, how to view all column families and qualifiers?

I haven't created the HBase table, it was already available.


Solution

  • I figured out the solution as follows: 1. To get the column family, scanning the table should work 2. To get the qualifier, following is the code I used:

    Get g = new Get(Bytes.toBytes("xxxxxxx"));
    //Within quotes above, the rowkey should be entered
                try {
                    Result result = table.get(g);
                    System.out.println(result.getFamilyMap(Bytes.toBytes("")).firstEntry().getValue().toString());
                    byte[] bytes = result.getFamilyMap(Bytes.toBytes("<Column-Family Name>")).firstEntry().getKey();
                    String s = new String(bytes);
                    System.out.println("Qualifier Decrypted: " + s.toString());
                } catch (IOException e) {
                    e.printStackTrace();
                }