Search in sources :

Example 6 with FSDataOutputStream

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

the class FileOutputWriter method write.

public void write(T out) {
    FSDataOutputStream fsOut;
    try {
        if (fs.exists(outPath)) {
            fs.delete(outPath, true);
        }
        fsOut = fs.create(new Path(outPath, generateRandom(10) + ".csv"));
        pw = new PrintWriter(fsOut);
    } catch (IOException e) {
        throw new RuntimeException("IOException Occured");
    }
    writeRecord(out);
}
Also used : Path(edu.iu.dsc.tws.api.data.Path) FSDataOutputStream(edu.iu.dsc.tws.api.data.FSDataOutputStream) IOException(java.io.IOException) PrintWriter(java.io.PrintWriter)

Example 7 with FSDataOutputStream

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

the class DataGenerator method generate.

public void generate(Path directory, int size, int dimension) {
    try {
        FileSystem fs = FileSystemUtils.get(directory.toUri(), config);
        if (fs.exists(directory)) {
            fs.delete(directory, true);
        }
        FSDataOutputStream outputStream = fs.create(new Path(directory, generateRandom(10) + ".txt"));
        PrintWriter pw = new PrintWriter(outputStream);
        String points = generatePoints(size, dimension, 100);
        pw.print(points);
        outputStream.sync();
        pw.close();
    } catch (IOException e) {
        throw new RuntimeException("Data Generation Error Occured", e);
    }
}
Also used : Path(edu.iu.dsc.tws.api.data.Path) FileSystem(edu.iu.dsc.tws.api.data.FileSystem) FSDataOutputStream(edu.iu.dsc.tws.api.data.FSDataOutputStream) IOException(java.io.IOException) PrintWriter(java.io.PrintWriter)

Aggregations

FSDataOutputStream (edu.iu.dsc.tws.api.data.FSDataOutputStream)7 Path (edu.iu.dsc.tws.api.data.Path)7 PrintWriter (java.io.PrintWriter)5 FileSystem (edu.iu.dsc.tws.api.data.FileSystem)4 IOException (java.io.IOException)4 Random (java.util.Random)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1