Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/hadoop/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 检查HBase表中是否存在值_Java_Hadoop_Hbase - Fatal编程技术网

Java 检查HBase表中是否存在值

Java 检查HBase表中是否存在值,java,hadoop,hbase,Java,Hadoop,Hbase,我有一个包含如下数据的HBase表: key1 c:hasErrors false key2 c:hasErrors true key3 c:hasErrors false 我想检查列限定符hasrerrors在表中的任何位置是否有值true 显然,我可以做扫描: Scan scan = new Scan(); scan.addColumn(colFam, colQual); Filter filter = new SingleColumnValueFilter(colFam, colQual

我有一个包含如下数据的HBase表:

key1 c:hasErrors false
key2 c:hasErrors true
key3 c:hasErrors false
我想检查列限定符
hasrerrors
在表中的任何位置是否有值
true

显然,我可以做扫描:

Scan scan = new Scan();
scan.addColumn(colFam, colQual);
Filter filter = new SingleColumnValueFilter(colFam, colQual, CompareFilter.CompareOp.EQUAL,
                new BinaryComparator(Bytes.toBytes("true")));
scan.setFilter(filter);
ResultScanner results = table.scan(scan, auditTableName);
但这是不可取的,因为任何匹配的行都将被拉回到我的应用程序,我必须检查
是否有结果。next()!=错误

是否有一种方法可以返回一个布尔值,告诉我该值是否至少存在于一行中?

请查看

org.apache.hadoop.hbase.filter.SingleColumnValueFilter

/**
 * Set whether entire row should be filtered if column is not found.
 * 
 * If true, the entire row will be skipped if the column is not found.
 * 
 * If false, the row will pass if the column is not found.  This is default.
 * @param filterIfMissing flag
 */
public void setFilterIfMissing(boolean filterIfMissing) {
  this.filterIfMissing = filterIfMissing;
}
根据文档,它不会返回不匹配的行


注意:如果您使用Get,您有类似目的的
setCheckExistency
方法

我没有其他方法,出于性能原因应避免扫描。考虑使用另一个HBASE表来跟踪HasError的计数,并将其与初始表一起填充。@哈罗德,谢谢,我还没有找到另一种方法。幸运的是,这不是一个大问题(我使用行键前缀进行扫描,并且扫描并不经常运行)。