Search in sources :

Example 1 with SharedTextInputPartitioner

use of edu.iu.dsc.tws.data.api.formatters.SharedTextInputPartitioner in project twister2 by DSC-SPIDAL.

the class TestLocalFileSystem method main.

public static void main(String[] args) {
    Config.Builder builder = new Config.Builder();
    builder.put("input.file.path", "/home/pulasthi/git/twister2/twister2/data/src/test" + "/resources/TextInputFormatTestFile.text");
    Config txtFileConf = builder.build();
    Path path = new Path("/home/pulasthi/git/twister2/twister2/data/src/test/resources" + "/TextInputFormatTestFile.text");
    InputPartitioner txtInput = new SharedTextInputPartitioner(path);
    txtInput.configure(txtFileConf);
    int minSplits = 8;
    try {
        InputSplit[] inputSplits = txtInput.createInputSplits(minSplits);
        InputSplitAssigner inputSplitAssigner = txtInput.getInputSplitAssigner(inputSplits);
        InputSplit cur = inputSplitAssigner.getNextInputSplit(null, 0);
        cur.open();
        String line = "";
        line = (String) cur.nextRecord(line);
        System.out.println(line);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : Path(edu.iu.dsc.tws.api.data.Path) InputSplitAssigner(edu.iu.dsc.tws.data.fs.io.InputSplitAssigner) Config(edu.iu.dsc.tws.api.config.Config) SharedTextInputPartitioner(edu.iu.dsc.tws.data.api.formatters.SharedTextInputPartitioner) InputSplit(edu.iu.dsc.tws.data.fs.io.InputSplit) InputPartitioner(edu.iu.dsc.tws.data.api.InputPartitioner) SharedTextInputPartitioner(edu.iu.dsc.tws.data.api.formatters.SharedTextInputPartitioner)

Example 2 with SharedTextInputPartitioner

use of edu.iu.dsc.tws.data.api.formatters.SharedTextInputPartitioner in project twister2 by DSC-SPIDAL.

the class DataParallelTask method prepare.

@Override
public void prepare(Config cfg, TaskContext context) {
    super.prepare(cfg, context);
    String directory = cfg.getStringValue(Constants.ARGS_INPUT_DIRECTORY);
    ExecutionRuntime runtime = (ExecutionRuntime) config.get(ExecutorContext.TWISTER2_RUNTIME_OBJECT);
    String outDir = cfg.getStringValue(Constants.ARGS_OUTPUT_DIRECTORY);
    boolean shared = cfg.getBooleanValue(Constants.ARGS_SHARED_FILE_SYSTEM);
    if (!shared) {
        this.source = runtime.createInput(cfg, context, new LocalTextInputPartitioner(new Path(directory), context.getParallelism()));
    } else {
        this.source = runtime.createInput(cfg, context, new SharedTextInputPartitioner(new Path(directory)));
    }
    this.sink = new DataSink<String>(cfg, new TextOutputWriter(FileSystem.WriteMode.OVERWRITE, new Path(outDir)));
}
Also used : LocalTextInputPartitioner(edu.iu.dsc.tws.data.api.formatters.LocalTextInputPartitioner) Path(edu.iu.dsc.tws.api.data.Path) SharedTextInputPartitioner(edu.iu.dsc.tws.data.api.formatters.SharedTextInputPartitioner) TextOutputWriter(edu.iu.dsc.tws.data.api.out.TextOutputWriter) ExecutionRuntime(edu.iu.dsc.tws.executor.core.ExecutionRuntime)

Aggregations

Path (edu.iu.dsc.tws.api.data.Path)2 SharedTextInputPartitioner (edu.iu.dsc.tws.data.api.formatters.SharedTextInputPartitioner)2 Config (edu.iu.dsc.tws.api.config.Config)1 InputPartitioner (edu.iu.dsc.tws.data.api.InputPartitioner)1 LocalTextInputPartitioner (edu.iu.dsc.tws.data.api.formatters.LocalTextInputPartitioner)1 TextOutputWriter (edu.iu.dsc.tws.data.api.out.TextOutputWriter)1 InputSplit (edu.iu.dsc.tws.data.fs.io.InputSplit)1 InputSplitAssigner (edu.iu.dsc.tws.data.fs.io.InputSplitAssigner)1 ExecutionRuntime (edu.iu.dsc.tws.executor.core.ExecutionRuntime)1