为了账号安全,请及时绑定邮箱和手机立即绑定

java 访问 hbase 得不到 result或者resultScanner

java 访问 hbase 得不到 result或者resultScanner

Liu__ 2018-07-26 10:31:58
代码如下:package hbase.test; import java.io.IOException; import java.util.List; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.Cell; import org.apache.hadoop.hbase.HBaseConfiguration; import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.client.Admin; import org.apache.hadoop.hbase.client.Connection; import org.apache.hadoop.hbase.client.ConnectionFactory; import org.apache.hadoop.hbase.client.Result; import org.apache.hadoop.hbase.client.ResultScanner; import org.apache.hadoop.hbase.client.Scan; import org.apache.hadoop.hbase.client.Table; import org.junit.Before; import org.junit.Test; public class HbaseDemo {     Connection connection;     Admin admin;     @Before     public void setUp() throws IOException {         Configuration conf = HBaseConfiguration.create();         connection = ConnectionFactory.createConnection(conf);         admin = connection.getAdmin();     }     @Test     public void queryTable() throws IOException {         System.out.println("----------------------查询整表数据 START-----------------------");         Table table = connection.getTable(TableName.valueOf("nsl:t1"));         System.out.println(123);         ResultScanner scanner = table.getScanner(new Scan());                  for (Result result : scanner) {             byte[] row = result.getRow();             System.out.println("rowkey is :" + new String(row));             List<Cell> listCells = result.listCells();             for (Cell cell : listCells) {                 byte[] familyArray = cell.getFamilyArray();                 byte[] qualifierArray = cell.getQualifierArray();                 byte[] valueArray = cell.getValueArray();                 System.out.println("row value is:" + new String(familyArray) + new String(qualifierArray)                         + new String(valueArray));             }         }         System.out.println("---------------查询整表数据 END-----------------");     } }Debug如下:
查看完整描述

1 回答

?
zengjun89

TA贡献1条经验 获得超0个赞

  1. 检查drivers/etc/hosts 里面配置的 域名,ip是否正确

  2. hbase检查表数据有无问题 hbase hbck details xxtb

  3. 如果 inconsistencies detected,这个字样出现,并且大于0个;说明表结构数据可能有问题

  4. 修复此表hbase hbck repair xxtb

  5. 如果不能修复此表,hbase shell ,进入命令行,删除旧表,disable 'xxtb',drop 'xxtb'

  6. 再次调试应用程序

查看完整回答
反对 回复 2019-11-13
  • 1 回答
  • 1 关注
  • 2552 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信