HBase中关于Bytes类的add方法疑问

espace123123 espace123123 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区

/**
* Hello world!
*/
public class PageFilterExample {
public static void main(String[] args) throws IOException {
Configuration config = HBaseConfiguration.create();
config.set("hbase.zookeeper.quorum", "QT-H-0038");

String tableName = "testTable";
String cfName = "colfam1";
final byte[] POSTFIX = new byte[] { 0x00 };
HTable table = new HTable(config, tableName);
Filter filter = new PageFilter(15);
byte[] lastRow = null;
int totalRows = 0;
while (true) {
Scan scan = new Scan();
scan.setFilter(filter);
if(lastRow != null){
//注意这里添加了POSTFIX操作,不然死循环了
byte[] startRow = Bytes.add(lastRow,POSTFIX);
scan.setStartRow(startRow);
}
ResultScanner scanner = table.getScanner(scan);
int localRows = 0;
Result result;
while((result = scanner.next()) != null){
System.out.println(localRows++ + ":" + result);
totalRows ++;
lastRow = result.getRow();
}
scanner.close();
if(localRows == 0) break;
}
System.out.println("total rows:" + totalRows);
}

}


请教,byte[] startRow = Bytes.add(lastRow,POSTFIX);
此代码返回的startRow是否就是lastRow?如果是的话,为什么要add上POSTFIX?如果不是得话返回的是什么?

...全文

相关推荐

评论 1
收藏 已收藏
分享
返回顶部
espace123123
Hadoop生态社区 20,842 成员 4,695 内容