我如何读取Hbase Hadoop缓存的寄存器并通过mapReduce处理它们

时间:2019-04-06 20:10:58

标签: hadoop hbase

如果我有Main类,我想阅读de Hbase表的寄存器,应该如何设置Job类,InputFormat是什么?在job.setInputFormatClass中,Map中的值类型是什么(键/值)

公共类Main扩展Configuracion实施工具{

Path pathEntrada;
Path pathSalida;
SystemaFds fs;
Job job;
public Main() throws IOException {
    super();
    fs=new SystemaFds();
}




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

    int res=ToolRunner.run(new Main(), args);       
    System.exit(res);

}

@Override
public Configuration getConf() {
    // TODO Auto-generated method stub
    return null;
}

@Override
public void setConf(Configuration arg0) {
    // TODO Auto-generated method stub

}

@Override
public int run(String[] arg) throws Exception {

    String archivoEntrada="input/parrafos.txt";
    String archivoSalida="output/parrafos.txt";     
        job=new Job(this.conf,"EquilibradoCargas");     
    job.setInputFormatClass(TextInputFormat.class);     
    job.setJarByClass(Main.class);      
    job.setMapperClass(Map.class);      
    job.setReducerClass(Reduce.class);      
        this.pathEntrada=new Path(archivoEntrada);          InputFormatPersonalizado.addInputPath(job,this.pathEntrada);

    this.pathSalida=new Path(archivoSalida);
    if (this.fs.existeArchivo(archivoSalida))
    {
        this.fs.borrarArchivo(archivoSalida);
    }
    TextOutputFormat.setOutputPath(job,this.pathSalida);        
    and what are the types of values in Map (key / value)
    job.setOutputFormatClass(TextOutputFormat.class);       
    //Especificamos los tipos de datos para clave/valor     
    job.setOutputKeyClass(Text.class);
    job.setOutputValueClass(IntWritable.class);   
    job.setJobName("Parrafos");


    boolean ejecutar=job.waitForCompletion(true);

    if (ejecutar)
    {
        return 0;
    }
    else 
    {
        return 1;
    }   

}

}

公共类Map扩展了Mapper {

private final static IntWritable one=new IntWritable(1);
private Text word= new Text();
public void  map(LongWritable key,Text value,Context context) throws IOException, InterruptedException {

}

}

公共类Reduce扩展Reducer {

public Reduce() {

}
//Vamos a sobreEscribir el metodo reduce
public void reduce(Text key, Iterable<IntWritable> val, Context context) throws IOException, InterruptedException
{

}

}

0 个答案:

没有答案