[英]Using Scan in HBase with start row, end row and a filter
我需要使用HBase中的扫描来扫描符合特定条件的所有行:这就是我将使用过滤器的原因(实际上是包含两个SingleColumnValueFilter的复合过滤器列表)。 现在,我以这种方式构建了rowKeys:
a.b.x|1|1252525
a.b.x|1|2373273
a.b.x|1|2999238
...
a.b.x|2|3000320
a.b.x|2|4000023
...
a.b.y|1|1202002
a.b.y|1|1778949
a.b.y|1|2738273
作为一个额外的要求,我只需要迭代那些具有以“abx | 1”开头的rowKey的行
现在,问题
提前致谢
安德里亚
行键在hbase中排序(词汇)。 因此所有“abx | 1”都将出现在“abx | 2”之前,依此类推。由于行键存储为字节数组并按字典顺序排序,因此请注意非固定长度的行键以及混合时不同的角色类。 但是对于你的要求,这方面的东西应该有效:
Scan scan = new Scan(Bytes.toBytes("a.b.x|1"),Bytes.toBytes("a.b.x|2"); //creating a scan object with start and stop row keys
scan.setFilter(colFilter);//set the Column filters you have to this scan object.
//And then you can get a scanner object and iterate through your results
ResultScanner scanner = table.getScanner(scan);
for (Result result = scanner.next(); result != null; result = scanner.next())
{
//Use the result object
}
更新:ToBytes应该是toBytes
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.