[[HBase] [Get]使用外壳程序但不可通过Java API检索行

问题描述 投票:0回答:1

我正在研究一个简单的代码,以从HBase获取行,该行无法通过HBase Java API进行操作,但是可以从外壳程序检索同一行。

示例行ID:

F\x0A@z\x11\x0D\xB4\xD3\x05"S273320039#999279720
=\x0A@z\x1AI\xA4\xD8h\x12\x09754427158#999598625
F\x0A@z\x11\x0D\xA6@\x0C\x04\xDA490229991#999279958
M\x0A@z\x13\x092\x89a\x12\x111059947933#999223281
\x00\x0A@E\xFFn[\x18\x9F\xD4-1447846881#5241968320

通过外壳从RowId之一获得的结果:

hbase(main):003:0> get 'OSMNodes_z3_geometry_ingestionTimestamp_v6',"\x00\x0A@E\xFFn[\x18\x9F\xD4-1447846881#5241968320"
COLUMN                            CELL                                                                                            
 d:                               timestamp=1588532276719, value=\x03\x00\x06\x02\x00\x12\x00-\x005\x00=\x00R\x00Y\x01x\x00\x00\x0
                                  0\x00\x01\x08\x03\xC0V\xE9\x9AU\x81;\xD5\xBF\xF5\xA7FE^\xAE\xE2\x7F\xF8\x00\x00\x00\x00\x00\x00\
                                  x00\x00\x01q\x9Av\xA9\x00\x00\x00\x01q\x9B\x89Q\x801447846881#524196832\xB0geojso\xEE\xDE\x04{"g
                                  eometry":{"type":"Point","coordinates":[-91.6500448,-1.3533385]},"id":"5241968320","properties":
                                  {"tags":{},"changesetId":53988821,"version":1,"uid":1975220,"user":"jptolosa87","featureSource":
                                  "OSM","sourceTimestamp":"2017-11-22 00:01:26","ingestionTimestamp":"2020-04-21 02:00:00"}}

Java API代码

    public static void main(String[] args) {

        Configuration conf = HBaseConfiguration.create();
        conf.addResource(new Path("/etc/hbase/conf/hbase-default.xml"));
        conf.addResource(new Path("/etc/hbase/conf/hbase-site.xml"));

        try {
            HBaseAdmin.checkHBaseAvailable(conf);
        } catch (Exception e) {
            e.printStackTrace();
            return;
        }

        Map<String, String> argVector = parseArgVector(args);

        final String fileName = argVector.get("fileName");
        final String hbaseTableName = argVector.get("hbaseTableName");
        final String rowId = argVector.get("rowId");
        final HTable table = getTable(hbaseTableName, conf);

        Result result = getRow(table, rowId);
        System.out.println(result);
        System.out.println(result.isEmpty());
        System.out.println(Bytes.toString(result.getRow()));
        System.out.println(Bytes.toString(result.getValue(Bytes.toBytes("d"), Bytes.toBytes(""))));
    }

    private static Result getRow(final HTable table, final String rowId) {
        try {
            Get get = new Get(Bytes.toBytes(rowId));
            System.out.println(Bytes.toString(get.getRow()));
            return table.get(get);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
    

我正在研究一个简单的代码,以从HBase获取行,该行无法通过HBase Java API进行操作,但是可以从Shell检索同一行。示例行ID:F \ x0A @ z \ x11 \ x0D \ xB4 \ xD3 \ x05“ ...

hbase
1个回答
0
投票

您可以使用此Java代码从HBase表中读取数据

© www.soinside.com 2019 - 2024. All rights reserved.