Search in sources :

Example 31 with MessageType

use of edu.iu.dsc.tws.api.comms.messaging.types.MessageType in project twister2 by DSC-SPIDAL.

the class STKeyedGatherExample method buildTaskGraph.

@Override
public ComputeGraphBuilder buildTaskGraph() {
    List<Integer> taskStages = jobParameters.getTaskStages();
    int sourceParallelism = taskStages.get(0);
    int sinkParallelism = taskStages.get(1);
    MessageType keyType = MessageTypes.INTEGER;
    MessageType dataType = MessageTypes.INTEGER_ARRAY;
    String edge = "edge";
    BaseSource g = new SourceTask(edge, true);
    ICompute r = new KeyedGatherSinkTask();
    computeGraphBuilder.addSource(SOURCE, g, sourceParallelism);
    computeConnection = computeGraphBuilder.addCompute(SINK, r, sinkParallelism);
    computeConnection.keyedGather(SOURCE).viaEdge(edge).withKeyType(keyType).withDataType(dataType);
    return computeGraphBuilder;
}
Also used : BaseSource(edu.iu.dsc.tws.api.compute.nodes.BaseSource) ICompute(edu.iu.dsc.tws.api.compute.nodes.ICompute) MessageType(edu.iu.dsc.tws.api.comms.messaging.types.MessageType)

Example 32 with MessageType

use of edu.iu.dsc.tws.api.comms.messaging.types.MessageType in project twister2 by DSC-SPIDAL.

the class BTDirectExample method buildTaskGraph.

@Override
public ComputeGraphBuilder buildTaskGraph() {
    List<Integer> taskStages = jobParameters.getTaskStages();
    int sourceParallelism = taskStages.get(0);
    int sinkParallelism = taskStages.get(1);
    MessageType dataType = MessageTypes.INTEGER_ARRAY;
    String edge = "edge";
    BaseSource g = new SourceTask(edge);
    ICompute r = new PartitionSinkTask();
    computeGraphBuilder.addSource(SOURCE, g, sourceParallelism);
    computeConnection = computeGraphBuilder.addCompute(SINK, r, sinkParallelism);
    computeConnection.direct(SOURCE).viaEdge(edge).withDataType(dataType);
    return computeGraphBuilder;
}
Also used : BaseSource(edu.iu.dsc.tws.api.compute.nodes.BaseSource) ICompute(edu.iu.dsc.tws.api.compute.nodes.ICompute) MessageType(edu.iu.dsc.tws.api.comms.messaging.types.MessageType)

Example 33 with MessageType

use of edu.iu.dsc.tws.api.comms.messaging.types.MessageType in project twister2 by DSC-SPIDAL.

the class BTGatherExample method buildTaskGraph.

@Override
public ComputeGraphBuilder buildTaskGraph() {
    List<Integer> taskStages = jobParameters.getTaskStages();
    int sourceParallelism = taskStages.get(0);
    int sinkParallelism = taskStages.get(1);
    MessageType dataType = MessageTypes.INTEGER_ARRAY;
    String edge = "edge";
    BaseSource g = new SourceTask(edge);
    ICompute r = new GatherSinkTask();
    computeGraphBuilder.addSource(SOURCE, g, sourceParallelism);
    computeConnection = computeGraphBuilder.addCompute(SINK, r, sinkParallelism);
    computeConnection.gather(SOURCE).viaEdge(edge).withDataType(dataType);
    return computeGraphBuilder;
}
Also used : BaseSource(edu.iu.dsc.tws.api.compute.nodes.BaseSource) ICompute(edu.iu.dsc.tws.api.compute.nodes.ICompute) MessageType(edu.iu.dsc.tws.api.comms.messaging.types.MessageType)

Example 34 with MessageType

use of edu.iu.dsc.tws.api.comms.messaging.types.MessageType in project twister2 by DSC-SPIDAL.

the class BTJoinExample method buildTaskGraph.

@Override
public ComputeGraphBuilder buildTaskGraph() {
    List<Integer> taskStages = jobParameters.getTaskStages();
    int sourceParallelism = taskStages.get(0);
    int sinkParallelism = taskStages.get(1);
    MessageType keyType = MessageTypes.INTEGER;
    MessageType dataType = MessageTypes.INTEGER_ARRAY;
    BaseSource source1 = new JoinSource(JoinRelation.LEFT);
    BaseSource source2 = new JoinSource(JoinRelation.RIGHT);
    ICompute r = new JoinSinkTask();
    computeGraphBuilder.addSource(SOURCE, source1, sourceParallelism);
    computeGraphBuilder.addSource(SOURCE2, source2, sourceParallelism);
    computeConnection = computeGraphBuilder.addCompute(SINK, r, sinkParallelism);
    computeConnection.innerJoin(SOURCE, SOURCE2, CommunicationContext.JoinAlgorithm.SORT).viaLeftEdge(LEFT_EDGE).viaRightEdge(RIGHT_EDGE).withKeyType(keyType).withLeftDataType(dataType).withRightDataType(dataType).withTaskPartitioner(new TaskPartitioner() {

        private List<Integer> dst;

        @Override
        public void prepare(Set sources, Set destinations) {
            this.dst = new ArrayList<>(destinations);
            Collections.sort(this.dst);
        }

        @Override
        public int partition(int source, Object data) {
            return dst.get((Integer) data % dst.size());
        }

        @Override
        public void commit(int source, int partition) {
        }
    }).withComparator(Integer::compareTo);
    return computeGraphBuilder;
}
Also used : BaseSource(edu.iu.dsc.tws.api.compute.nodes.BaseSource) Set(java.util.Set) ArrayList(java.util.ArrayList) List(java.util.List) ICompute(edu.iu.dsc.tws.api.compute.nodes.ICompute) TaskPartitioner(edu.iu.dsc.tws.api.compute.TaskPartitioner) MessageType(edu.iu.dsc.tws.api.comms.messaging.types.MessageType)

Example 35 with MessageType

use of edu.iu.dsc.tws.api.comms.messaging.types.MessageType in project twister2 by DSC-SPIDAL.

the class BTKeyedGatherExample method buildTaskGraph.

@Override
public ComputeGraphBuilder buildTaskGraph() {
    List<Integer> taskStages = jobParameters.getTaskStages();
    int sourceParallelism = taskStages.get(0);
    int sinkParallelism = taskStages.get(1);
    MessageType keyType = MessageTypes.INTEGER;
    MessageType dataType = MessageTypes.INTEGER_ARRAY;
    String edge = "edge";
    BaseSource g = new SourceTask(edge, true);
    ICompute r = new KeyedGatherGroupedSinkTask();
    computeGraphBuilder.addSource(SOURCE, g, sourceParallelism);
    computeConnection = computeGraphBuilder.addCompute(SINK, r, sinkParallelism);
    computeConnection.keyedGather(SOURCE).viaEdge(edge).withKeyType(keyType).withTaskPartitioner(new HashingPartitioner()).withDataType(dataType);
    return computeGraphBuilder;
}
Also used : BaseSource(edu.iu.dsc.tws.api.compute.nodes.BaseSource) HashingPartitioner(edu.iu.dsc.tws.tset.fn.HashingPartitioner) ICompute(edu.iu.dsc.tws.api.compute.nodes.ICompute) MessageType(edu.iu.dsc.tws.api.comms.messaging.types.MessageType)

Aggregations

MessageType (edu.iu.dsc.tws.api.comms.messaging.types.MessageType)37 InMessage (edu.iu.dsc.tws.comms.dfw.InMessage)15 ICompute (edu.iu.dsc.tws.api.compute.nodes.ICompute)14 BaseSource (edu.iu.dsc.tws.api.compute.nodes.BaseSource)13 Test (org.junit.Test)13 Tuple (edu.iu.dsc.tws.api.comms.structs.Tuple)11 ArrayList (java.util.ArrayList)8 List (java.util.List)5 CommunicationContext (edu.iu.dsc.tws.api.comms.CommunicationContext)4 MessageHeader (edu.iu.dsc.tws.api.comms.messaging.MessageHeader)4 JoinedTuple (edu.iu.dsc.tws.api.comms.structs.JoinedTuple)4 Twister2RuntimeException (edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException)4 ResettableIterator (edu.iu.dsc.tws.comms.shuffle.ResettableIterator)4 Collections (java.util.Collections)4 Iterator (java.util.Iterator)4 Map (java.util.Map)4 Logger (java.util.logging.Logger)4 Op (edu.iu.dsc.tws.api.comms.Op)2 ChannelMessage (edu.iu.dsc.tws.api.comms.messaging.ChannelMessage)2 DataBuffer (edu.iu.dsc.tws.api.comms.packing.DataBuffer)2