我正在编写一个基于 jave 的 hadoop map reduce 代码——。我正在调用一个外部库来处理我的数据。我得到了类转换异常。请告诉我原因和可能的解决方案。
public void map(Object key, DocR value, Context context) {
DataToHdfs test = null;
try {
docs = new DocR(new File(AnnotationExtration.INPUT_LOCATION));
compiledAql=AnnotationExtration.aog;
SystemX.Single syst = new SystemX.Single(compiledAql, AnnotationExtration.docSchema);
String combinedResult="";
while (docs.hasNext()) {
...........做一些处理和发送数据HDFS。
if((combinedResult)!=null){
test.writToHdfs(combinedResult);
}
System.out.println(combinedResult);
// Writing to HDFS.
context.write(new Text("1",),new Text(combinedResult));
例外是:-
java.lang.ClassCastException: org.apache.hadoop.io.Text cannot be cast to com.somepackage.api.DocR
at com.somePackage.AnnotationExtrationMapper.map(AnnotationExtrationMapper.java:1)
at org.apache.hadoop.mapreduce.Mapper.run(Mapper.java:144)
at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:764)
at org.apache.hadoop.mapred.MapTask.run(MapTask.java:370)
at org.apache.hadoop.mapred.LocalJobRunner$Job.run(LocalJobRunner.java:212)
12/08/28 13:02:23 INFO mapred.JobClient: map 0% reduce 0%
12/08/28 13:02:23 INFO mapred.JobClient: Job complete: job_local_0001
谢谢