Search in sources :

Example 1 with BJoin

use of edu.iu.dsc.tws.comms.batch.BJoin in project twister2 by DSC-SPIDAL.

the class BDJoinExample method compute.

@Override
protected void compute(WorkerEnvironment workerEnv) {
    LogicalPlanBuilder logicalPlanBuilder = LogicalPlanBuilder.plan(jobParameters.getSources(), jobParameters.getTargets(), workerEnv).withFairDistribution();
    // create the communication
    join = new BJoin(workerEnv.getCommunicator(), logicalPlanBuilder, MessageTypes.INTEGER, MessageTypes.INTEGER_ARRAY, MessageTypes.INTEGER_ARRAY, new JoinReceiver(), new SimpleKeyBasedSelector(), true, Comparator.comparingInt(o -> (Integer) o), CommunicationContext.JoinType.INNER, CommunicationContext.JoinAlgorithm.SORT);
    Set<Integer> tasksOfExecutor = logicalPlanBuilder.getSourcesOnThisWorker();
    // now initialize the workers
    LOG.log(Level.INFO, String.format("%d Sources %s target %d this %s", workerId, logicalPlanBuilder.getSources(), 1, tasksOfExecutor));
    for (int t : tasksOfExecutor) {
        // the map thread where data is produced
        Thread mapThread = new Thread(new MapWorker(t));
        mapThread.start();
    }
}
Also used : SimpleKeyBasedSelector(edu.iu.dsc.tws.comms.selectors.SimpleKeyBasedSelector) LogicalPlanBuilder(edu.iu.dsc.tws.comms.utils.LogicalPlanBuilder) BJoin(edu.iu.dsc.tws.comms.batch.BJoin)

Example 2 with BJoin

use of edu.iu.dsc.tws.comms.batch.BJoin in project twister2 by DSC-SPIDAL.

the class BJoinStudentExample method compute.

@Override
protected void compute(WorkerEnvironment workerEnv) {
    LogicalPlanBuilder logicalPlanBuilder = LogicalPlanBuilder.plan(jobParameters.getSources(), jobParameters.getTargets(), workerEnv).withFairDistribution();
    // create the join communication
    join = new BJoin(workerEnv.getCommunicator(), logicalPlanBuilder, MessageTypes.INTEGER, MessageTypes.OBJECT, MessageTypes.OBJECT, new JoinReceiver(), new SimpleKeyBasedSelector(), false, (o1, o2) -> {
        if (o1 instanceof String && o2 instanceof String) {
            return ((String) o1).compareTo((String) o2);
        }
        return 0;
    }, CommunicationContext.JoinType.INNER, CommunicationContext.JoinAlgorithm.SORT);
    Set<Integer> tasksOfExecutor = logicalPlanBuilder.getSourcesOnThisWorker();
    // now initialize the workers
    LOG.log(Level.INFO, String.format("%d Sources %s target %d this %s", workerId, logicalPlanBuilder.getSources(), 1, tasksOfExecutor));
    for (int t : tasksOfExecutor) {
        // the map thread where data is produced
        Thread mapThread = new Thread(new MapWorker(t));
        mapThread.start();
    }
}
Also used : SimpleKeyBasedSelector(edu.iu.dsc.tws.comms.selectors.SimpleKeyBasedSelector) DataGenerator(edu.iu.dsc.tws.examples.comms.DataGenerator) CommunicationContext(edu.iu.dsc.tws.api.comms.CommunicationContext) BulkReceiver(edu.iu.dsc.tws.api.comms.BulkReceiver) Iterator(java.util.Iterator) ReentrantLock(java.util.concurrent.locks.ReentrantLock) Set(java.util.Set) LogicalPlanBuilder(edu.iu.dsc.tws.comms.utils.LogicalPlanBuilder) JoinedTuple(edu.iu.dsc.tws.api.comms.structs.JoinedTuple) Config(edu.iu.dsc.tws.api.config.Config) MessageTypes(edu.iu.dsc.tws.api.comms.messaging.types.MessageTypes) SimpleKeyBasedSelector(edu.iu.dsc.tws.comms.selectors.SimpleKeyBasedSelector) Logger(java.util.logging.Logger) Level(java.util.logging.Level) Lock(java.util.concurrent.locks.Lock) WorkerEnvironment(edu.iu.dsc.tws.api.resource.WorkerEnvironment) KeyedBenchWorker(edu.iu.dsc.tws.examples.comms.KeyedBenchWorker) BJoin(edu.iu.dsc.tws.comms.batch.BJoin) Map(java.util.Map) LogicalPlanBuilder(edu.iu.dsc.tws.comms.utils.LogicalPlanBuilder) BJoin(edu.iu.dsc.tws.comms.batch.BJoin)

Example 3 with BJoin

use of edu.iu.dsc.tws.comms.batch.BJoin in project twister2 by DSC-SPIDAL.

the class BJoinExample method compute.

@Override
protected void compute(WorkerEnvironment workerEnv) {
    Set<Integer> sources = new HashSet<>();
    Set<Integer> targets = new HashSet<>();
    Integer noOfSourceTasks = jobParameters.getTaskStages().get(0);
    for (int i = 0; i < noOfSourceTasks; i++) {
        sources.add(i);
    }
    Integer noOfTargetTasks = jobParameters.getTaskStages().get(1);
    for (int i = 0; i < noOfTargetTasks; i++) {
        targets.add(noOfSourceTasks + i);
    }
    LogicalPlanBuilder logicalPlanBuilder = LogicalPlanBuilder.plan(jobParameters.getSources(), jobParameters.getTargets(), workerEnv).withFairDistribution();
    // create the communication
    join = new BJoin(workerEnv.getCommunicator(), logicalPlanBuilder, MessageTypes.INTEGER, MessageTypes.INTEGER_ARRAY, MessageTypes.INTEGER_ARRAY, new JoinReceiver(), new SimpleKeyBasedSelector(), false, Comparator.comparingInt(o -> (Integer) o), CommunicationContext.JoinType.INNER, CommunicationContext.JoinAlgorithm.SORT);
    Set<Integer> tasksOfExecutor = logicalPlanBuilder.getSourcesOnThisWorker();
    // now initialize the workers
    LOG.log(Level.INFO, String.format("%d Sources %s target %d this %s", workerId, sources, 1, tasksOfExecutor));
    for (int t : tasksOfExecutor) {
        // the map thread where data is produced
        Thread mapThread = new Thread(new JoinedKeyedBenchWorker.MapWorker(t));
        mapThread.start();
    }
}
Also used : SimpleKeyBasedSelector(edu.iu.dsc.tws.comms.selectors.SimpleKeyBasedSelector) JoinedKeyedBenchWorker(edu.iu.dsc.tws.examples.comms.JoinedKeyedBenchWorker) LogicalPlanBuilder(edu.iu.dsc.tws.comms.utils.LogicalPlanBuilder) BJoin(edu.iu.dsc.tws.comms.batch.BJoin) HashSet(java.util.HashSet)

Aggregations

BJoin (edu.iu.dsc.tws.comms.batch.BJoin)3 SimpleKeyBasedSelector (edu.iu.dsc.tws.comms.selectors.SimpleKeyBasedSelector)3 LogicalPlanBuilder (edu.iu.dsc.tws.comms.utils.LogicalPlanBuilder)3 BulkReceiver (edu.iu.dsc.tws.api.comms.BulkReceiver)1 CommunicationContext (edu.iu.dsc.tws.api.comms.CommunicationContext)1 MessageTypes (edu.iu.dsc.tws.api.comms.messaging.types.MessageTypes)1 JoinedTuple (edu.iu.dsc.tws.api.comms.structs.JoinedTuple)1 Config (edu.iu.dsc.tws.api.config.Config)1 WorkerEnvironment (edu.iu.dsc.tws.api.resource.WorkerEnvironment)1 DataGenerator (edu.iu.dsc.tws.examples.comms.DataGenerator)1 JoinedKeyedBenchWorker (edu.iu.dsc.tws.examples.comms.JoinedKeyedBenchWorker)1 KeyedBenchWorker (edu.iu.dsc.tws.examples.comms.KeyedBenchWorker)1 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1 Map (java.util.Map)1 Set (java.util.Set)1 Lock (java.util.concurrent.locks.Lock)1 ReentrantLock (java.util.concurrent.locks.ReentrantLock)1 Level (java.util.logging.Level)1 Logger (java.util.logging.Logger)1