我使用hazelcast 3.6.1并使用自定义mapreduce实现不同的聚合功能以获得solr facet种类的结果。自定义Dstinct映射器中的NullPointerException
public class DistinctMapper implements Mapper<String, Employee, String, Long>{
private transient SimpleEntry<String, Employee> entry = new SimpleEntry<String, Employee>();
private static final Long ONE = Long.valueOf(1L);
private Supplier<String, Employee, String> supplier;
public DistinctMapper(Supplier<String, Employee, String> supplier) {
this.supplier = supplier;
}
@Override
public void map(String key, Employee value, Context<String, Long> context) {
System.out.println("Object "+ entry + " and key "+key);
entry.setKey(key);
entry.setValue(value);
String fieldValue = (String) supplier.apply(entry);
//getValue(value, fieldName);
if (null != fieldValue){
context.emit(fieldValue, ONE);
}
}
}
和映射程序与NullPointerException失败。而sysout声明表示入口对象为空。
你能指出我在上面的代码中的问题?谢谢。
在hazelcast中的mapper代码中是否有任何优势? –