Search in sources :

Example 1 with SKeyedReduce

use of edu.iu.dsc.tws.comms.stream.SKeyedReduce in project twister2 by DSC-SPIDAL.

the class SKeyedReduceExample method compute.

@Override
protected void compute(WorkerEnvironment workerEnv) {
    LogicalPlanBuilder logicalPlanBuilder = LogicalPlanBuilder.plan(jobParameters.getSources(), jobParameters.getTargets(), workerEnv).withFairDistribution();
    keyedReduce = new SKeyedReduce(workerEnv.getCommunicator(), logicalPlanBuilder, MessageTypes.INTEGER, MessageTypes.INTEGER_ARRAY, new ReduceOperationFunction(Op.SUM, MessageTypes.INTEGER_ARRAY), new FinalSingularReceiver(jobParameters.getIterations()), new SimpleKeyBasedSelector());
    Set<Integer> tasksOfExecutor = logicalPlanBuilder.getSourcesOnThisWorker();
    for (int t : tasksOfExecutor) {
        finishedSources.put(t, false);
    }
    if (tasksOfExecutor.size() == 0) {
        sourcesDone = true;
    }
    LOG.log(Level.INFO, String.format("%d Sources %s target %d this %s", workerId, logicalPlanBuilder.getSources(), 1, tasksOfExecutor));
    // now initialize the workers
    for (int t : tasksOfExecutor) {
        // the map thread where data is produced
        Thread mapThread = new Thread(new KeyedBenchWorker.MapWorker(t));
        mapThread.start();
    }
}
Also used : SimpleKeyBasedSelector(edu.iu.dsc.tws.comms.selectors.SimpleKeyBasedSelector) ReduceOperationFunction(edu.iu.dsc.tws.comms.functions.reduction.ReduceOperationFunction) KeyedBenchWorker(edu.iu.dsc.tws.examples.comms.KeyedBenchWorker) LogicalPlanBuilder(edu.iu.dsc.tws.comms.utils.LogicalPlanBuilder) SKeyedReduce(edu.iu.dsc.tws.comms.stream.SKeyedReduce)

Aggregations

ReduceOperationFunction (edu.iu.dsc.tws.comms.functions.reduction.ReduceOperationFunction)1 SimpleKeyBasedSelector (edu.iu.dsc.tws.comms.selectors.SimpleKeyBasedSelector)1 SKeyedReduce (edu.iu.dsc.tws.comms.stream.SKeyedReduce)1 LogicalPlanBuilder (edu.iu.dsc.tws.comms.utils.LogicalPlanBuilder)1 KeyedBenchWorker (edu.iu.dsc.tws.examples.comms.KeyedBenchWorker)1