这两天看了一下HBase的基本操作,然后又重温了下Hadoop的MapReduce的基本操作(虽然之前看的也是一般般,理解不是很深)。本来打算昨晚完成两件事情的:1、使用map任务读出HDFS 上的文件,并把他导入到HBase中;2、使用map任务读出HBase中的数据,并使用reduce输出到文件中。
我的数据使用如下:(只是很少的数据)
首先贴代码,然后再说明问题吧:
package org.fansy.date830;
import java.io.IOException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
import org.apache.hadoop.hbase.mapreduce.TableMapReduceUtil;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.Mapper;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.util.GenericOptionsParser;
public class JobOne {
/**
* use map job to read file data and then import the data to HBase
* start:22:44
* test:OK
* end: 22:59
*/
public static void main(String[] args) throws Exception{
// TODO Auto-generated method stub
Configuration conf = HBaseConfiguration.create();
String[] otherArgs = new GenericOptionsParser(conf, args).getRemainingArgs();
if(otherArgs.length != 2) {
System.err.println("Wrong number of arguments: " + otherArgs.length);
System.err.println("Usage: <