Research breakthrough possible @S-Logix pro@slogix.in

Office Address

Social List

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
    context.write(key1,value1);

  • Command

    //HBase Reducer
    //Reducer access of key-value pair from mapper output
    reduce(Text key1, Iterable value1, Context context)
    for each(IntWritable s:values1)
    sum+=s
    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);