HBase学习之七: 如何定位一条记录所属region,如何查看一个region的数据量,如何查看一个Cell的所有版本

1.如何定位一条记录所属region
HTable table = new HTable(conf, "testhbase");
HRegionLocation location = table.getRegionLocation("01-1468404017235-1320");
HRegionInfo rg = location.getRegionInfo();
String regionname = Bytes.toString(rg.getRegionName());
String strkey = Bytes.toString(rg.getStartKey());
String endkey = Bytes.toString(rg.getEndKey());

2.如何查看一个region的数据量
hbase hfile -p -f /apps/hbase/data/data/default/testhbase/2979e781050cd01129716bf924166870/info/40881a75e45c4293b506bde9288cadc2|grep Scanned
......
Scanned kv count -> 896
其中2979e781050cd01129716bf924166870是region的名字
info是列簇的名字
40881a75e45c4293b506bde9288cadc2是hfile

3.如何查看一个Cell的所有版本
HTable table = new HTable(conf, "testhbase");
Scan scan=new Scan();
scan.setMaxVersions();
命令:scan 'testhbase',{FILTER => "PrefixFilter ('90-1468404017328-8552')",RAW => true, VERSIONS => 10}
testhbase====表名
90-1468404017328-8552=====rowkey

猜你喜欢

转载自blog.csdn.net/javajxz008/article/details/51913533