从hbase获取数据时出错

时间:2018-05-01 12:36:58

标签: java hbase

我在HBase表中有一些具有大量数据和1000个区域的特定数据。

当我从shell查询数据时,通过列名使用正常扫描需要175秒。但我尝试使用前缀过滤器在我的java代码中获取同样的东西,我收到超时错误。

任何人都可以知道为什么会发生这件事以及如何从我的基表中获取数据?

请在下面找到我使用

的代码
@Override
public Scan getScanForRowRange(List rowKeys, List columnList) {
    try {
        List rowrangeList = new ArrayList<>();
        for (String rowKey : rowKeys) {
            byte[] startRow = Bytes.toBytes(rowKey);
            byte[] endRow = new byte[startRow.length + 1];
            System.arraycopy(startRow, 0, endRow, 0, startRow.length);
            endRow[startRow.length] = (byte) 255;
            RowRange rowRange = new RowRange(startRow, true, endRow, false);
            rowrangeList.add(rowRange);
        }
        logger.info("row range size" + rowrangeList.size());
        Scan scan = new Scan();
        for (String columnName : columnList) {
            if (columnName.contains(ForesightConstants.COLON)) {
                String cellValues[] = columnName.split(ForesightConstants.COLON);
                scan.addColumn(Bytes.toBytes(cellValues[ForesightConstants.ZERO]), Bytes.toBytes(cellValues[ForesightConstants.ONE]));
            }
        }
        scan.setFilter(new MultiRowRangeFilter(rowrangeList));
        scan.setCacheBlocks(true);
        scan.setCaching(10);
        return scan;
    } catch (IOException e) {
        logger.info("Exception Inside @Method getScanForRowRange }", Utils.getStackTrace(e));
    }
    return null;
}

0 个答案:

没有答案
相关问题