use of edu.iu.dsc.tws.api.dataset.DataPartitionConsumer in project twister2 by DSC-SPIDAL.
the class CheckpointingExample method execute.
@Override
public void execute(WorkerEnvironment workerEnvironment) {
BatchChkPntEnvironment env = TSetEnvironment.initCheckpointing(workerEnvironment);
int count = 5;
SourceTSet<Integer> src = dummySource(env, count, 100 * env.getWorkerID());
PersistedTSet<Integer> persist = src.direct().persist();
SourceTSet<Integer> src1 = dummySource(env, count, 100 * env.getWorkerID() + 10);
src1.direct().compute(new BaseComputeFunc<Iterator<Integer>, String>() {
private DataPartitionConsumer<Integer> in;
@Override
public void prepare(TSetContext ctx) {
super.prepare(ctx);
in = (DataPartitionConsumer<Integer>) ctx.getInput("in").getConsumer();
}
@Override
public String compute(Iterator<Integer> input) {
StringBuilder out = new StringBuilder();
while (input.hasNext() && in.hasNext()) {
out.append("(").append(input.next()).append(",").append(in.next()).append(") ");
}
return out.toString();
}
}).addInput("in", persist).direct().forEach(i -> LOG.info(i));
persist.direct().forEach(i -> LOG.info(i.toString()));
}
Aggregations