且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何从HBase中的特定行和列中获取多个版本

更新时间:2023-01-20 19:55:07

您可以指定扫描版本的数量并且它会检索它们:

  HTable tbl = new HTable(tableName); 
Get q = new Get(Bytes.toBytes(key));
q.setMaxVersions(numberOfVersionsYouWant);
结果行= tbl.get(q);
NavigableMap< byte [],NavigableMap< byte [],NavigableMap< Long,byte []>>> allVersions = row.getMap();


As we know, hbase has a feature that a specific Row and specific Column can record recent change values by timestamps. So my question is, HOW TO list all the changed values using any HBase command? I googled a lot, but didn't find any useful links.

You can specify the number of version you get for Scan and Get and it will retrieve them:

 HTable tbl = new HTable(tableName);
 Get q= new Get(Bytes.toBytes(key));
 q.setMaxVersions(numberOfVersionsYouWant);
 Result row= tbl.get(q);
 NavigableMap<byte[],NavigableMap<byte[],NavigableMap<Long,byte[]>>> allVersions=row.getMap();