如何在 Java 中获取 HBase 的行键

How to get row key for HBase in Java

映射器任务配置为:

TableMapReduceUtil.initTableMapperJob("PaperAbout1", scan, InputMapper.class, Text.class, Text.class, job);

而map函数头如下:

protected void map(ImmutableBytesWritable row, Result value,
            Mapper<ImmutableBytesWritable, Result, Text, Text>.Context context)
            throws IOException, InterruptedException {

任何需要检索的列值都可以通过以下方式检索:

String columnValue = Bytes.toString(result.getValue(Bytes.toBytes("ColumnFamily"), Bytes.toBytes("column"))));

map任务中如何获取扫描行的key?

row.get() 

将 return 您的密钥的字节数组。您当然必须使用 Bytes.toDatatype() 方法将其解析为您用作密钥的正确数据类型。