2016-11-29 60 views
0

映射器任務配置爲:如何獲得行鍵爲HBase的Java中

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

和地圖功能標題如下:

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

那希望是任何coulmn值檢索可以檢索:

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

如何在地圖任務中檢索掃描行的關鍵?

回答

1
row.get() 

將返回密鑰的字節數組。您當然必須將其解析爲您用作Bytes.toDatatype()方法的密鑰的正確數據類型。

+0

非常感謝! – dorado