Hadoop Hbase:如何知道一行是否有特定的列族?

Hadoop Hbase:如何知道一行是否有特定的列族?,hadoop,hbase,Hadoop,Hbase,假设行键1具有f1:c1、f1:c2的值 其中,as rowkey 2仅具有f1:c1的值。第2行没有f1:c2 如何识别这些行(未填充列的行)? 你想知道从排然后像这样尝试 HTable t = new HTable(conf....); ResultScanner scanner = t.getScanner(new Scan()); for (Result rr = scanner.next(); rr != null; rr = scanner.next()) {

假设行键1具有f1:c1、f1:c2的值 其中,as rowkey 2仅具有f1:c1的值。第2行没有f1:c2

如何识别这些行(未填充列的行)?

  • 你想知道从排然后像这样尝试

     HTable t = new HTable(conf....);
     ResultScanner scanner = t.getScanner(new Scan());    
     for (Result rr = scanner.next(); rr != null; rr = scanner.next()) 
     {
           if (rr.getValue("YourFamily" , "YourQualifier").equals(Bytes.toBytes("d"))
           {
            // do some thing
           } else { return; // if you want to skip     } } }
    
result.getFamilyMap()
是另一种方法。但由于性能原因,不建议使用。。请参阅此方法的文档

然而,已经有了家庭方法

boolean hasFamily(byte[] familyName)
Checks to see if this table contains the given column family