Hbase:如何知道一行是否有特定的列族?
Hbase: How to know if a row had particular column family or not?
让我们假设行键 1 具有 f1:c1、f1:c2 的值
其中 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()
是另一种方式。但由于性能原因不推荐使用。请参阅此方法的文档
但是,HTableDescriptor.html已经有家庭方法了。
boolean hasFamily(byte[] familyName)
Checks to see if this table contains the given column family
让我们假设行键 1 具有 f1:c1、f1:c2 的值 其中 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()
是另一种方式。但由于性能原因不推荐使用。请参阅此方法的文档
但是,HTableDescriptor.html已经有家庭方法了。
boolean hasFamily(byte[] familyName)
Checks to see if this table contains the given column family