Mahdi
Mahdi

Reputation: 1827

Get Columns in a specific Column Family for a row HBase

I'm writing a application that shows data in a specific table in HBase by JSP. I want to get all columns in a specific column family for a row.

is there any way for do this?

Upvotes: 9

Views: 16133

Answers (2)

Arnon Rotem-Gal-Oz
Arnon Rotem-Gal-Oz

Reputation: 25909

If you are just interested in a single family you can set the scanner to fetch only that family

    Scan scan = new Scan(Bytes.toBytes(startKey),Bytes.toBytes(endKey);
    scan.addFamily(Bytes.toBytes(familyName));

Upvotes: 9

Mahdi
Mahdi

Reputation: 1827

public String[] getColumnsInColumnFamily(Result r, String ColumnFamily)
{

      NavigableMap<byte[], byte[]> familyMap = r.getFamilyMap(Bytes.toBytes(ColumnFamily));
      String[] Quantifers = new String[familyMap.size()];

      int counter = 0;
      for(byte[] bQunitifer : familyMap.keySet())
      {
          Quantifers[counter++] = Bytes.toString(bQunitifer);

      }

      return Quantifers;
}

Result r is as a desirable row.

Upvotes: 12

Related Questions