use of org.redisson.api.mapreduce.RCollector in project redisson by redisson.
the class CollectionMapperTask method run.
@Override
public void run() {
Codec codec;
try {
codec = (Codec) objectCodecClass.getConstructor().newInstance();
} catch (Exception e) {
throw new IllegalStateException(e);
}
Injector.inject(mapper, redisson);
for (String objectName : objectNames) {
Iterable<VIn> collection = null;
if (RSetCache.class.isAssignableFrom(objectClass)) {
collection = redisson.getSetCache(objectName, codec);
} else if (RSet.class.isAssignableFrom(objectClass)) {
collection = redisson.getSet(objectName, codec);
} else if (RSortedSet.class.isAssignableFrom(objectClass)) {
collection = redisson.getSortedSet(objectName, codec);
} else if (RScoredSortedSet.class.isAssignableFrom(objectClass)) {
collection = redisson.getScoredSortedSet(objectName, codec);
} else if (RLexSortedSet.class.isAssignableFrom(objectClass)) {
collection = (Iterable<VIn>) redisson.getLexSortedSet(objectName);
} else if (RList.class.isAssignableFrom(objectClass)) {
collection = redisson.getList(objectName, codec);
} else {
throw new IllegalStateException("Unable to work with " + objectClass);
}
RCollector<KOut, VOut> collector = new Collector<KOut, VOut>(codec, redisson, collectorMapName, workersAmount, timeout);
for (VIn value : collection) {
if (Thread.currentThread().isInterrupted()) {
return;
}
mapper.map(value, collector);
}
}
}
use of org.redisson.api.mapreduce.RCollector in project redisson by redisson.
the class MapperTask method run.
@Override
public void run() {
Codec codec;
try {
codec = (Codec) objectCodecClass.getConstructor().newInstance();
} catch (Exception e) {
throw new IllegalStateException(e);
}
Injector.inject(mapper, redisson);
RCollector<KOut, VOut> collector = new Collector<KOut, VOut>(codec, redisson, collectorMapName, workersAmount, timeout);
for (String objectName : objectNames) {
RMap<KIn, VIn> map = null;
if (RMapCache.class.isAssignableFrom(objectClass)) {
map = redisson.getMapCache(objectName, codec);
} else {
map = redisson.getMap(objectName, codec);
}
for (Entry<KIn, VIn> entry : map.entrySet()) {
if (Thread.currentThread().isInterrupted()) {
return;
}
mapper.map(entry.getKey(), entry.getValue(), collector);
}
}
}
Aggregations