MapReduce to HBase: Read from & write to

This tutorial extends 1. HBase Tutorial Getting Started & 1. Hadoop MapReduce Basic Tutorial to read an HBase table with data from the mapper and write the max marks for each subject to another HBase table from the reducer..

Input Data Marks secured by 4 students

Step 1: Let’s store this Data in HBase database as described in tutorial 1. HBase Tutorial Getting Started.

Step 2: Let’s extend the tutorial 1. Hadoop MapReduce Basic Tutorial to use HBase database tables we created in step 1 to read from and write to. The pom.xml file should have the following dependencies:

Step 3: The “ScoreTableMapper” class that extends “TableMapper” from the “hbase-server.jar”.

Step 4: The “ScoreTableReducer”.

Step 5: Finally, the class with the main method to run as a stand-alone class. Make use of the “TableMapReduceUtil” to map to HBase tables.

Step 6: Run the above class and then go to “Hbase shell” command to see if the “max mark” has been added to the table “marks-summary“.

Output:

You can also execute: hbase(main):002:0> scan ‘marks-summary’


Categories Menu - Q&As, FAQs & Tutorials

Top