J'utilise Hazelcast 3.6.1 et implémente des fonctionnalités agrégées distinctes en utilisant mapreduce personnalisé pour obtenir des résultats de type facette.NullPointerException dans Custom Dstinct Mapper
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);
}
}
}
et mapper échoue avec NullPointerException. et l'instruction sysout indique que l'objet d'entrée est null.
Pouvez-vous me rappeler la question dans le code ci-dessus? Merci.
Y at-il un avantage de transitoire dans le code du mappeur en noisette? –