The NamedCacheInputFormat

The NamedCacheInputFormat reads all the keys and values from the named cache within the IMDG and sends them to the mappers. It assumes that all the objects in the named cache have the same type. The key that the mapper receives for each object is its CachedObjectId identifier within the named cache. The key/value pairs are served to the mappers in random order.

The input cache name should be set as a configuration property by calling setNamedCache(…). The following example illustrates how to use the NamedCacheInputFormat and associate it with a named cache within the IMDG:

//Create the named cache and put some values in it
NamedCache cache = CacheFactory.getCache("MyNamedCache");
cache.put("key1", "foo");
cache.put("key2", "bar");

//Set up the job
Job job = new HServerJob(new Configuration());
// ...
job.setInputFormatClass(NamedCacheInputFormat.class);
NamedCacheInputFormat.setInputObjectClass(job, String.class);
NamedCacheInputFormat.setNamedCache(job, "MyNamedCache");