2016-03-27 15 views
-1

Bir Hbase tablosundan diğerine değerler aktarılırken hatayla karşılaşıyorum Hbase tablosu. Hbase tablosundan dosya çıktısına aktarılırken kod gayet iyi çalışıyor.Hbase Hata: java.lang.ClassCastException: org.apache.hadoop.io.Text, org.apache.hadoop.hbase.client.Mutation'a dönüştürülemiyor

Error: java.lang.ClassCastException: org.apache.hadoop.io.Text cannot be cast to org.apache.hadoop.hbase.client.Mutation 
    at org.apache.hadoop.hbase.mapreduce.TableOutputFormat$TableRecordWriter.write(TableOutputFormat.java:94) 
    at org.apache.hadoop.mapred.ReduceTask$NewTrackingRecordWriter.write(ReduceTask.java:558) 
    at org.apache.hadoop.mapreduce.task.TaskInputOutputContextImpl.write(TaskInputOutputContextImpl.java:89) 
    at org.apache.hadoop.mapreduce.lib.reduce.WrappedReducer$Context.write(WrappedReducer.java:105) 
    at org.apache.hadoop.mapreduce.Reducer.reduce(Reducer.java:150) 
    at org.apache.hadoop.mapreduce.Reducer.run(Reducer.java:171) 
    at org.apache.hadoop.mapred.ReduceTask.runNewReducer(ReduceTask.java:627) 
    at org.apache.hadoop.mapred.ReduceTask.run(ReduceTask.java:389) 
    at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:164) 
    at java.security.AccessController.doPrivileged(Native Method) 
    at javax.security.auth.Subject.doAs(Subject.java:422) 
    at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1657) 
    at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:158) 

Sürücü Sınıfı:

 // Mapper 
     TableMapReduceUtil.initTableMapperJob(
       mailsTable, 
       scan, 
       SimHashMapper.class, 
       Text.class, Text.class, 
       job); 
     //reducer 
     String targetTable="old_64bit"; 
     TableMapReduceUtil.initTableReducerJob(
       targetTable,  // output table 
       SimHashReducer.class, // reducer class 
       job); 
return job; 

Mapper sınıftır:

public static class SimHashMapper extends 
      TableMapper<Text, Text> { 

     public void map(ImmutableBytesWritable row, Result value, 
       Context context) throws InterruptedException, IOException { 
         ....... 
      context.write(new Text(s),new Text(t)); 

Redüktör sınıftır: önceden

public static class SimHashReducer extends 
      TableReducer<Text, Text,ImmutableBytesWritable> { 

     public void reduce(Text key, Text values, //values is a single Text value 
       Context context) throws IOException, InterruptedException { 


      Put put = new Put(Bytes.toBytes(values.toString())); 
      put.add(Bytes.toBytes("64_bit_fingerprint"),Bytes.toBytes(""),Bytes.toBytes(values.toString())); 
      //context.write(new ImmutableBytesWritable(Bytes.toBytes("old_64bit")),put); 

      context.write(null, put); 

Teşekkür !!!

cevap

0

sizin fonksiyon kodları:

public void reduce(Text key, Text values, //values is a single Text value 
      Context context) throws IOException, InterruptedException { 


public void reduce(Text key, Iterable<Text> values, //values is a single Text value 
      Context context) throws IOException, InterruptedException { 
İlgili konular