Class SampleUploader

java.lang.Object
org.apache.hadoop.conf.Configured
org.apache.hadoop.hbase.mapreduce.SampleUploader
All Implemented Interfaces:
org.apache.hadoop.conf.Configurable, org.apache.hadoop.util.Tool

@Private public class SampleUploader extends org.apache.hadoop.conf.Configured implements org.apache.hadoop.util.Tool
Sample Uploader MapReduce

This is EXAMPLE code. You will need to change it to work for your context.

Uses TableReducer to put the data into HBase. Change the InputFormat to suit your data. In this example, we are importing a CSV file.

 row,family,qualifier,value
 

The table and columnfamily we're to insert into must preexist.

There is no reducer in this example as it is not necessary and adds significant overhead. If you need to do any massaging of data before inserting into HBase, you can do this in the map as well.

Do the following to start the MR job:

 ./bin/hadoop org.apache.hadoop.hbase.mapreduce.SampleUploader /tmp/input.csv TABLE_NAME
 

This code was written against HBase 0.21 trunk.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    (package private) static class 
     
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final org.slf4j.Logger
     
    private static final String
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static org.apache.hadoop.mapreduce.Job
    configureJob(org.apache.hadoop.conf.Configuration conf, String[] args)
    Job configuration.
    static void
    main(String[] args)
     
    int
    run(String[] otherArgs)
    Main entry point.

    Methods inherited from class org.apache.hadoop.conf.Configured

    getConf, setConf

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.apache.hadoop.conf.Configurable

    getConf, setConf
  • Field Details

  • Constructor Details

  • Method Details

    • configureJob

      public static org.apache.hadoop.mapreduce.Job configureJob(org.apache.hadoop.conf.Configuration conf, String[] args) throws IOException
      Job configuration.
      Throws:
      IOException
    • run

      public int run(String[] otherArgs) throws Exception
      Main entry point.
      Specified by:
      run in interface org.apache.hadoop.util.Tool
      Parameters:
      otherArgs - The command line parameters after ToolRunner handles standard.
      Throws:
      Exception - When running the job fails.
    • main

      public static void main(String[] args) throws Exception
      Throws:
      Exception