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

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -