[英]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.