Search in sources :

Example 6 with DataObjectSource

use of edu.iu.dsc.tws.task.dataobjects.DataObjectSource in project twister2 by DSC-SPIDAL.

the class KMeansDataGeneratorTest method testUniqueSchedules1.

@Test
public void testUniqueSchedules1() throws IOException {
    Config config = getConfig();
    String dinputDirectory = "/tmp/testdinput";
    int numFiles = 1;
    int dsize = 20;
    int dimension = 2;
    int parallelismValue = 2;
    KMeansDataGenerator.generateData("txt", new Path(dinputDirectory), numFiles, dsize, 100, dimension, config);
    ComputeGraphBuilder computeGraphBuilder = ComputeGraphBuilder.newBuilder(config);
    computeGraphBuilder.setTaskGraphName("kmeans");
    DataObjectSource sourceTask = new DataObjectSource("direct", dinputDirectory);
    DataObjectSink sinkTask = new DataObjectSink();
    computeGraphBuilder.addSource("source", sourceTask, parallelismValue);
    ComputeConnection computeConnection1 = computeGraphBuilder.addCompute("sink", sinkTask, parallelismValue);
    computeConnection1.direct("source").viaEdge("direct").withDataType(MessageTypes.OBJECT);
    computeGraphBuilder.setMode(OperationMode.BATCH);
    LocalTextInputPartitioner localTextInputPartitioner = new LocalTextInputPartitioner(new Path(dinputDirectory), parallelismValue, config);
    DataSource<String, ?> source = new DataSource<>(config, localTextInputPartitioner, parallelismValue);
    InputSplit<String> inputSplit;
    for (int i = 0; i < parallelismValue; i++) {
        inputSplit = source.getNextSplit(i);
        Assert.assertNotNull(inputSplit);
    }
}
Also used : Path(edu.iu.dsc.tws.api.data.Path) LocalTextInputPartitioner(edu.iu.dsc.tws.data.api.formatters.LocalTextInputPartitioner) DataObjectSink(edu.iu.dsc.tws.task.dataobjects.DataObjectSink) Config(edu.iu.dsc.tws.api.config.Config) ComputeGraphBuilder(edu.iu.dsc.tws.task.impl.ComputeGraphBuilder) DataObjectSource(edu.iu.dsc.tws.task.dataobjects.DataObjectSource) ComputeConnection(edu.iu.dsc.tws.task.impl.ComputeConnection) DataSource(edu.iu.dsc.tws.dataset.DataSource) Test(org.junit.Test)

Aggregations

DataObjectSource (edu.iu.dsc.tws.task.dataobjects.DataObjectSource)6 ComputeConnection (edu.iu.dsc.tws.task.impl.ComputeConnection)6 ComputeGraph (edu.iu.dsc.tws.api.compute.graph.ComputeGraph)5 DataObjectSink (edu.iu.dsc.tws.task.dataobjects.DataObjectSink)5 ExecutionPlan (edu.iu.dsc.tws.api.compute.executor.ExecutionPlan)4 DataObject (edu.iu.dsc.tws.api.dataset.DataObject)4 ComputeGraphBuilder (edu.iu.dsc.tws.task.impl.ComputeGraphBuilder)3 Config (edu.iu.dsc.tws.api.config.Config)1 Path (edu.iu.dsc.tws.api.data.Path)1 LocalTextInputPartitioner (edu.iu.dsc.tws.data.api.formatters.LocalTextInputPartitioner)1 DataSource (edu.iu.dsc.tws.dataset.DataSource)1 DataFlowGraph (edu.iu.dsc.tws.task.cdfw.DataFlowGraph)1 Test (org.junit.Test)1