All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.infinispan.distexec.mapreduce.MapReduceCacheLoaderTask Maven / Gradle / Ivy

There is a newer version: 9.1.7.Final
Show newest version
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