2012-03-17 72 views
7

我正在編寫一個應用程序,該應用程序在HBase by JSP中的特定表中顯示數據。我想要獲得特定列族中的所有列。爲特定行列獲取行HBase

有沒有辦法做到這一點?

+0

我達到一個答案,如果你有另一種解決方案,請諮詢我。 爲(結果RR = scanner.next(); RR = NULL;!RR = scanner.next()){ \t \t \t \t的NavigableMap familyMap = rr.getFamilyMap(Bytes.toBytes( 「信息」)); \t \t \t \t byte [] y =(byte [])familyMap.firstEntry()。getKey(); \t \t \t \t System.out.println(Bytes.toString(y)); \t \t } – Mahdi 2012-03-17 11:27:35

回答

9
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; 
} 

結果r是一個理想的行。

8

如果你是在一個家庭只是有興趣,你可以設置掃描儀獲取只有家庭

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