java - HBase mapreduce: write into HBase in Reducer -
i learning hbase. know how write java program using hadoop mapreduce , write output hdfs; want write same output hbase, instead of hdfs. should have similar code did before in hdfs thing:
context.write(key,value);
could show me example achieve this?
here's 1 way this:
public static class mymapper extends tablemapper<immutablebyteswritable, put> { public void map(immutablebyteswritable row, result value, context context) throws ioexception, interruptedexception { // example copying data source table... context.write(row, resulttoput(row,value)); } private static put resulttoput(immutablebyteswritable key, result result) throws ioexception { put put = new put(key.get()); (keyvalue kv : result.raw()) { put.add(kv); } return put; } }
you can read here table mapper
Comments
Post a Comment