HBase中关于Bytes类的add方法疑问
/**
* 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?如果不是得话返回的是什么?
...全文
相关推荐
eclipse构建HBase开发环境并运行实例对Hbase建表增删改查
首先需要创建一个HBaseConfiguration对象,然后使用HBaseAdmin类的createTable方法创建表。
hbase海量数据的全量导入方法
**使用HFileOutputFormat**:HBase提供了HFileOutputFormat类,可以将数据直接写入HFile格式,跳过HBase的内部流程,从而提高数据导入效率。
Hbase笔记 —— 利用JavaAPI的方式操作Hbase数据库(往hbase的表中批量插入数据).pdf
: result.listCells()) { byte[] value = CellUtil.cloneValue(cell); // 处理每个Cell的值}```在读取数据时,`CellUtil`类提供了便利的方法来访问
java链接及操作hbase实例代码
在Java中,我们使用`ConnectionFactory`类的`createConnection()`方法来建立连接:```javaConfiguration config = HBaseConfiguration.create
Hive数据导入HBase的方法.docx
hbase-client-1.1.1.jar;ADD JAR /mnt/hive/lib/hbase-protocol-1.1.1.jar;ADD JAR /mnt/hive/lib/hbase-server


