Package com.hazelcast.jet.core
Class AbstractProcessor.FlatMapper<T,R>
- java.lang.Object
-
- com.hazelcast.jet.core.AbstractProcessor.FlatMapper<T,R>
-
- Type Parameters:
T
- type of the input itemR
- type of the emitted item
- Enclosing class:
- AbstractProcessor
protected final class AbstractProcessor.FlatMapper<T,R> extends java.lang.Object
A helper that simplifies the implementation oftryProcess(ordinal, item)
for emitting collections. User supplies amapper
which takes an item and returns a traverser over all output items that should be emitted. ThetryProcess(Object)
method obtains and passes the traverser toAbstractProcessor.emitFromTraverser(int, Traverser)
.Example:
public static class SplitWordsP extends AbstractProcessor {
private FlatMapper<String, String> flatMapper = flatMapper(item -> Traverser.over(item.split("\\W")));
@Override
protected boolean tryProcess(int ordinal, Object item) throws Exception { return flatMapper.tryProcess((String) item); } }
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
tryProcess(T item)
Method designed to be called from one ofAbstractProcessor#tryProcessX()
methods.
-
-
-
Method Detail
-
tryProcess
public boolean tryProcess(@Nonnull T item)
Method designed to be called from one ofAbstractProcessor#tryProcessX()
methods. The calling method must return this method's return value.- Parameters:
item
- the item to process- Returns:
- what the calling
tryProcessX()
method should return
-
-