我在理解如何将简单 Hadoop 的输出写回 Elasticsearch 时遇到了一些麻烦。
作业配置为:
job.setOutputFormatClass(EsOutputFormat.class);
job.setOutputKeyClass(NullWritable.class);
job.setOutputValueClass(MapWritable.class);
减速机做:
final DoubleWritable average = new DoubleWritable(sum / size);
final MapWritable output = new MapWritable();
output.put(key, average);
context.write(NullWritable.get(), output);
然而,我得到了这个(对我来说)莫名其妙的异常:
14/08/15 16:59:54 INFO mapreduce.Job: Task Id : attempt_1408106733881_0013_r_000000_2, Status : FAILED Error:
org.elasticsearch.hadoop.EsHadoopIllegalArgumentException:
[org.elasticsearch.hadoop.serialization.field.MapWritableFieldExtractor@5796fabe] cannot extract value from object [org.apache.hadoop.io.MapWritable@dcdb8e97]
at org.elasticsearch.hadoop.serialization.bulk.TemplatedBulk$FieldWriter.write(TemplatedBulk.java:49)
at org.elasticsearch.hadoop.serialization.bulk.TemplatedBulk.writeTemplate(TemplatedBulk.java:101)
at org.elasticsearch.hadoop.serialization.bulk.TemplatedBulk.write(TemplatedBulk.java:77)
at org.elasticsearch.hadoop.rest.RestRepository.writeToIndex(RestRepository.java:130)
at org.elasticsearch.hadoop.mr.EsOutputFormat$EsRecordWriter.write(EsOutputFormat.java:161)
at org.apache.hadoop.mapred.ReduceTask$NewTrackingRecordWriter.write(ReduceTask.java:558)
在 context.write() 调用中。
我有点困惑,有什么想法吗?