繁体   English   中英

获取 Hbase 中特定行的所有列值

[英]Getting all the column values for a particular row in Hbase

我想为特定行获取 hbase 中不同列族下的所有列,下面是我尝试使用 getFamilyMap 实现的代码。 它生成一个以 byte[] 作为键和值的 navigablemap。但是当我尝试执行 entry.getValue() 时,我没有得到任何数据。

    Table table = connection.getTable(TableName.valueOf(tableName));
Get getVal = new Get(Bytes.toBytes(input));
// Reading the data
Result result = table.get(getVal);
NavigableMap<byte[], byte[]>  byteMap = result.getFamilyMap(cfName.getBytes());
for(Map.Entry<byte[],byte[]> entries: byteMap.entrySet()){
    byte[] temp = entries.getKey();
    byte[] value = entries.getValue();
    logger.debug("key:: "+Bytes.toString(temp));
    logger.debug("Value:: "+Bytes.toString(byteMap.get(value)));
}

但是如果我提供下面的代码,我确实得到了键和值。 请让我知道这两个代码之间的区别是什么以及地图的值如何受到影响?

for(byte[] map : byteMap.keySet()){
    logger.debug("key:: "+Bytes.toString(map));
    logger.debug("Value:: "+Bytes.toString(byteMap.get(map)));      
}

查看失败示例的这些行:

byte[] value = entries.getValue();
logger.debug("Value:: "+Bytes.toString(byteMap.get(value)));

您已经获得了byte[]的值,因此您不需要从byteMap检索任何byteMap 实际上,您在byteMap中不会有对应于该值的键。 您只需要登录:

logger.debug("Value:: "+Bytes.toString(value));

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM