Search in sources :

Example 1 with AvroPhysicalSourceOutgoingEdgesInfo

use of edu.snu.mist.formats.avro.AvroPhysicalSourceOutgoingEdgesInfo in project mist by snuspl.

the class AvroExecutionVertexStore method saveAvroPhysicalSourceOutgoingEdgesInfo.

/**
 * Saves the AvroPhysicalSourceOutgoingEdgesInfo of the source to be reactivated.
 */
public void saveAvroPhysicalSourceOutgoingEdgesInfo(final Tuple<String, AvroPhysicalSourceOutgoingEdgesInfo> tuple) {
    try {
        final AvroPhysicalSourceOutgoingEdgesInfo avroPhysicalSourceOutgoingEdgesInfo = tuple.getValue();
        // Create file with the name of the PhysicalOperatorChain Id.
        final File avroPhysicalSourceOutgoingEdgesInfoFile = getAvroPhysicalSourceOutgoingEdgesInfoFile(tuple.getKey());
        final DataFileWriter<AvroPhysicalSourceOutgoingEdgesInfo> dataFileWriter = new DataFileWriter<>(sourceDatumWriter);
        dataFileWriter.create(avroPhysicalSourceOutgoingEdgesInfo.getSchema(), avroPhysicalSourceOutgoingEdgesInfoFile);
        dataFileWriter.append(avroPhysicalSourceOutgoingEdgesInfo);
        dataFileWriter.close();
    } catch (IOException e) {
        throw new RuntimeException("Writing AvroPhysicalSourceOutgoingEdgesInfo has failed.");
    }
}
Also used : DataFileWriter(org.apache.avro.file.DataFileWriter) IOException(java.io.IOException) File(java.io.File) AvroPhysicalSourceOutgoingEdgesInfo(edu.snu.mist.formats.avro.AvroPhysicalSourceOutgoingEdgesInfo)

Example 2 with AvroPhysicalSourceOutgoingEdgesInfo

use of edu.snu.mist.formats.avro.AvroPhysicalSourceOutgoingEdgesInfo in project mist by snuspl.

the class AvroExecutionVertexStore method loadAvroPhysicalSourceOutgoingEdgesInfoFromFile.

// TODO: [MIST-*] Implement policy for deleting from disk. Currently does not delete from disk.
private AvroPhysicalSourceOutgoingEdgesInfo loadAvroPhysicalSourceOutgoingEdgesInfoFromFile(final File storedSource) {
    try {
        final DataFileReader<AvroPhysicalSourceOutgoingEdgesInfo> dataFileReader = new DataFileReader<>(storedSource, sourceDatumReader);
        AvroPhysicalSourceOutgoingEdgesInfo avroPhysicalSourceOutgoingEdgesInfo = null;
        avroPhysicalSourceOutgoingEdgesInfo = dataFileReader.next(avroPhysicalSourceOutgoingEdgesInfo);
        return avroPhysicalSourceOutgoingEdgesInfo;
    } catch (IOException e) {
        throw new RuntimeException("Loading AvroPhysicalSourceOutgoingEdgesInfo has failed.");
    }
}
Also used : DataFileReader(org.apache.avro.file.DataFileReader) IOException(java.io.IOException) AvroPhysicalSourceOutgoingEdgesInfo(edu.snu.mist.formats.avro.AvroPhysicalSourceOutgoingEdgesInfo)

Aggregations

AvroPhysicalSourceOutgoingEdgesInfo (edu.snu.mist.formats.avro.AvroPhysicalSourceOutgoingEdgesInfo)2 IOException (java.io.IOException)2 File (java.io.File)1 DataFileReader (org.apache.avro.file.DataFileReader)1 DataFileWriter (org.apache.avro.file.DataFileWriter)1