在查询hbase时最理想的方式是设置startRow和stopRow,然后在这个范围内再设置Filter进行查询(这是查询大量数据,少量数据直接设置Filter即可),如图
那startRow和stopRow怎样设置呢。
这2个参数源码如下:
Parameters:
startRow - row to start scannerat or after (inclusive)
stopRow - row to stop scannerbefore (exclusive)
即前闭后开的
在实际应用中,假设rowkey为 101 102 103 104
如果设置startRow和stopRow = “101”,那么查出来的是101
如果设置startRow = “101” stopRow = “103” 查询结果是101 102
如果设置startRow = “101” stopRow = “103” + “ ” 查询结果是101 102 103