How to Import data in HBase using Mapreduce

  • Sample code Segment

    //HBase mapper
    //Input table passed as pair to Mapper
    map(ImmutableBytesWritable rowKey, Result columns, Context context)
    //Write output of mapper as pair

  • Command

    //HBase Reducer
    //Reducer access of key-value pair from mapper output
    reduce(Text key1, Iterable value1, Context context)
    for each(IntWritable s:values1)
    end for
    // Create HBase output table with rowkey
    Put outputable = new Put(key1);
    // Insert sum value to HBase output table
    outputable.add(columnfamily,column, sum);
    // Write data to HBase ouput table
    context.write(null, outputable);