Although the importtsv
tool is very useful for loading text files into HBase, in many cases, for full control of the loading process you may want to write your own MapReduce job to import data into HBase. For example, the importtsv
tool does not work if you are going to load files of other formats.
HBase provides TableOutputFormat
for writing data into an HBase table from a MapReduce job. You can also generate its internal HFile format files in your MapReduce job by using the HFileOutputFormat
class, and then load the generated files into a running HBase cluster, using the completebulkload
tool we described in the previous recipe.
In this recipe, we will explain the steps for loading data using your own MapReduce job. We will first describe how to use TableOutputFormat
. In the There's more... section, we will explain how to generate HFile format files in a MapReduce job.