Reputation: 1827
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
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
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