Java 获取行 HBase 的特定列族中的列

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9749527/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-16 07:07:38  来源:igfitidea点击:

Get Columns in a specific Column Family for a row HBase

javahadoophbase

提问by Mahdi

I'm writing a application that shows data in a specific table in HBase by JSP. I want to get all columns in a specific column family for a row.

我正在编写一个应用程序,通过 JSP 显示 HBase 中特定表中的数据。我想为一行获取特定列族中的所有列。

is there any way for do this?

有没有办法做到这一点?

采纳答案by Mahdi

public String[] getColumnsInColumnFamily(Result r, String ColumnFamily)
{

      NavigableMap<byte[], byte[]> familyMap = r.getFamilyMap(Bytes.toBytes(ColumnFamily));
      String[] Quantifers = new String[familyMap.size()];

      int counter = 0;
      for(byte[] bQunitifer : familyMap.keySet())
      {
          Quantifers[counter++] = Bytes.toString(bQunitifer);

      }

      return Quantifers;
}

Result r is as a desirable row.

结果 r 是理想的行。

回答by Arnon Rotem-Gal-Oz

If you are just interested in a single family you can set the scanner to fetch only that family

如果您只对一个家庭感兴趣,您可以将扫描仪设置为仅获取该家庭

    Scan scan = new Scan(Bytes.toBytes(startKey),Bytes.toBytes(endKey);
    scan.addFamily(Bytes.toBytes(familyName));