根据Rowkey和ColumnFamily获取记录 [英] Get records based on Rowkey and ColumnFamily
本文介绍了根据Rowkey和ColumnFamily获取记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以根据 rowKey
和 columnFamily 读取
HBase
code>。目前我通过rowkey访问这段代码的记录:
Is it possible to read data from HBase
based on rowKey
and columnFamily
. Currently I access records by rowkey by this code:
HTable table = new HTable(conf, "tablename");
Get get = new Get(rowkey.getBytes());
Result rs = table.get(get);
for (KeyValue kv : rs.raw()) {
holdvalue = new String(kv.getValue());
}
我想将columnfamily添加为过滤器来访问属于该列的特定记录特定的 rowKey
和 columnFamily
。我怎么能做到这一点?
I want to add columnfamily as a filter to access specific records that belongs to that specific rowKey
and columnFamily
. How could I achieve this?
在此先感谢
Thanks in advance
推荐答案
您可以使用 Get
对象的 addFamily
方法将列族添加为过滤器。
You can add the column family as a filter by using the addFamily
method of the Get
object.
HTable table = new HTable(conf, "tablename");
Get get = new Get(rowkey.getBytes());
get.addFamily(family.getBytes()); // <-----------------
Result rs = table.get(get);
for (KeyValue kv : rs.raw()) {
holdvalue = new String(kv.getValue());
}
这篇关于根据Rowkey和ColumnFamily获取记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文