org.infinispan.distexec.mapreduce.MapReduceCacheLoaderTask Maven / Gradle / Ivy
package org.infinispan.distexec.mapreduce;
import org.infinispan.persistence.spi.AdvancedCacheLoader;
import org.infinispan.marshall.core.MarshalledEntry;
import org.infinispan.marshall.core.MarshalledValue;
/**
* This is an internal class, not intended to be used by clients.
*
* @author Mircea Markus
* @since 6.0
*/
public class MapReduceCacheLoaderTask implements AdvancedCacheLoader.CacheLoaderTask {
final Mapper mapper;
final Collector collector;
public MapReduceCacheLoaderTask(Mapper mapper, Collector collector) {
this.mapper = mapper;
this.collector = collector;
}
@Override
public void processEntry(MarshalledEntry marshalledEntry, AdvancedCacheLoader.TaskContext taskContext) {
mapper.map(marshalledEntry.getKey(), getValue(marshalledEntry), collector);
}
@SuppressWarnings("unchecked")
private VIn getValue(MarshalledEntry marshalledEntry) {
Object loadedValue = marshalledEntry.getValue();
if (loadedValue instanceof MarshalledValue) {
return (VIn)((MarshalledValue) loadedValue).get();
} else {
return (VIn) loadedValue;
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy