【问题标题】:Hbase countRow Nullpointer exception at validateArgAndGetPBvalidateArgAndGetPB 处的 Hbase countRow Nullpointer 异常
【发布时间】:2018-07-20 07:32:58
【问题描述】:

您好,我正在使用 Hbase。 我想计算我的表的行数,所以我使用了 AggregationClient.rowCount()

        Configuration conf = HBaseConfiguration.create();
    AggregationClient aggregationClient = new AggregationClient(conf);
    HTable htable=new HTable(conf,Bytes.toBytes("comment"));
    Scan scan =  new  Scan();
    scan.addFamily(Bytes.toBytes("user"));
    try{
        long  rowCount = aggregationClient.rowCount( htable ,  null , scan);
        System.out.println("Row Count : "+rowCount);

    }catch(Throwable e) {
        e.printStackTrace();
    }

然而我遇到了空点异常

java.lang.NullPointerException 在 org.apache.hadoop.hbase.client.coprocessor.AggregationClient.validateArgAndGetPB(AggregationClient.java:804) 在 org.apache.hadoop.hbase.client.coprocessor.AggregationClient.rowCount(AggregationClient.java:306) 在 com.naver.hbase.Main.countRows(Main.java:131) 在 com.naver.hbase.Main.main(Main.java:58)

我该如何解决?

【问题讨论】:

标签: java hadoop nullpointerexception hbase bigdata


【解决方案1】:

我最近遇到了同样的问题,通过向 rowCount 提供 ColumnInterpreter 解决了这个问题。下面是代码:

ColumnInterpreter ci = new LongColumnInterpreter();
long  rowCount = aggregationClient.rowCount(htable,  ci, scan);

【讨论】:

    【解决方案2】:

    好吧,rowCount 方法需要 3 个参数

    long rowCount(final Table table, final ColumnInterpreter<R, S, P, Q, T> ci, final Scan scan) throws Throwable {
    

    然后调用

    final AggregateRequest requestArg = validateArgAndGetPB(scan, ci, false);
    

    你正在传递ci = null,问题就在那里

    【讨论】:

    猜你喜欢
    • 2014-02-24
    • 2018-06-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多