在将值从一个hbase表传输到另一个hbase表时出现以下错误。代码在从hbase表传输到文件输出时工作正常。
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)
驾驶员等级:
// 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;
Map器类是:
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));
减速器等级为:
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);
提前谢谢!!!
1条答案
按热度按时间dldeef671#
您的功能代码: