0

重写以简化。为什么会这样编译:

MapReduceSpecification.of(
   "Something, anything", 
   input,
   mapper, // (extends Mapper<Job, Long, String>)
   Marshallers.getLongMarshaller(),
   Marshallers.getStringMarshaller(),
   NoReducer.<Long, String, String>create(),
   NoOutput.<String, String>create((int)1L)
);

但事实并非如此。注意评论中不同的“映射器”扩展:

MapReduceSpecification.of(
   "Something, anything", 
   input,
   mapper, // (extends Mapper<Job, Long, JobSummary>)
   Marshallers.getLongMarshaller(),
   Marshallers.getSerializationMarshaller(),
   NoReducer.<Long, JobSummary, JobSummary>create(),
   NoOutput.<JobSummary, JobSummary>create((int)1L)
);

抛出此编译异常:

The method
of(String,
Input<I>,
Mapper<I,K,V>,
Marshaller<K>,
Marshaller<V>,
Reducer<K,V,O>, Output<O,R>)
in the type MapReduceSpecification is not applicable for the arguments
(String,
JobInput,
JobMapper,
Marshaller<Long>,
Marshaller<Serializable>,
NoReducer<Long,JobSummary,JobSummary>,
NoOutput<JobSummary,JobSummary>)    

JobSummary 很简单(出于本示例的目的):

public class JobSummary implements Serializable {
   public String Text;
}

任何关于我错过了 I、K、V、O、R 的神秘组合的任何见解?

4

1 回答 1

0

使用特定于类的实现复制 SerializationMarshaller 似乎已经解决了这个问题。这是一个非常不令人满意的解决方案,但它确实有效。

于 2013-09-04T20:07:55.273 回答