Search in sources :

Example 1 with TextOutputWriter

use of edu.iu.dsc.tws.data.api.out.TextOutputWriter 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)

Example 2 with TextOutputWriter

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

the class DataFileSink method prepare.

@Override
public void prepare(Config cfg, TaskContext context) {
    super.prepare(cfg, context);
    String outDir = cfg.getStringValue(DataObjectConstants.OUTPUT_DIRECTORY);
    this.datasink = new DataSink<>(cfg, new TextOutputWriter(FileSystem.WriteMode.OVERWRITE, new Path(outDir)));
}
Also used : Path(edu.iu.dsc.tws.api.data.Path) TextOutputWriter(edu.iu.dsc.tws.data.api.out.TextOutputWriter)

Example 3 with TextOutputWriter

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

the class KMeansDataGenerator method generateText.

private static void generateText(Path directory, int numOfFiles, int sizeOfFile, int sizeMargin, int dimension, Config config) {
    for (int i = 0; i < numOfFiles; i++) {
        String points = generatePoints(sizeOfFile, dimension, sizeMargin);
        TextOutputWriter textOutputWriter = new TextOutputWriter(FileSystem.WriteMode.OVERWRITE, directory, config);
        textOutputWriter.createOutput();
        textOutputWriter.writeRecord(points);
        textOutputWriter.close();
    }
}
Also used : TextOutputWriter(edu.iu.dsc.tws.data.api.out.TextOutputWriter)

Aggregations

TextOutputWriter (edu.iu.dsc.tws.data.api.out.TextOutputWriter)3 Path (edu.iu.dsc.tws.api.data.Path)2 LocalTextInputPartitioner (edu.iu.dsc.tws.data.api.formatters.LocalTextInputPartitioner)1 SharedTextInputPartitioner (edu.iu.dsc.tws.data.api.formatters.SharedTextInputPartitioner)1 ExecutionRuntime (edu.iu.dsc.tws.executor.core.ExecutionRuntime)1