gpt4 book ai didi

hadoop - Hbase错误:java.lang.ClassCastException:org.apache.hadoop.io.Text无法转换为org.apache.hadoop.hbase.client.Mutation

转载 作者:行者123 更新时间:2023-12-02 22:04:09 24 4
gpt4 key购买 nike

将值从一个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;

映射器类为:
 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));

reducer 类为:
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);

提前致谢 !!!

最佳答案

您的功能代码:

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 {

关于hadoop - Hbase错误:java.lang.ClassCastException:org.apache.hadoop.io.Text无法转换为org.apache.hadoop.hbase.client.Mutation,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36247387/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com