Search in sources :

Example 1 with AvroPhysicalOperatorChain

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

the class AvroExecutionVertexStore method loadAvroPhysicalOperatorChain.

/**
 * Loads the AvroPhysicalOperatorChain with the chainId.
 */
public AvroPhysicalOperatorChain loadAvroPhysicalOperatorChain(final String chainId) throws IOException {
    try {
        final File storedChain = getAvroPhysicalOperatorChainFile(chainId);
        final DataFileReader<AvroPhysicalOperatorChain> dataFileReader = new DataFileReader<>(storedChain, operatorChainDatumReader);
        AvroPhysicalOperatorChain avroPhysicalOperatorChain = null;
        avroPhysicalOperatorChain = dataFileReader.next(avroPhysicalOperatorChain);
        return avroPhysicalOperatorChain;
    } catch (final IOException e) {
        LOG.log(Level.SEVERE, "An exception occurred while loading the AvroPhysicalOperatorChain with ID {0}.", new Object[] { chainId });
        throw e;
    }
}
Also used : DataFileReader(org.apache.avro.file.DataFileReader) AvroPhysicalOperatorChain(edu.snu.mist.formats.avro.AvroPhysicalOperatorChain) IOException(java.io.IOException) File(java.io.File)

Example 2 with AvroPhysicalOperatorChain

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

the class AvroExecutionVertexStore method saveAvroPhysicalOperatorChain.

/**
 * Saves the AvroPhysicalOperatorChain as operatorChainId.chain to disk.
 */
public void saveAvroPhysicalOperatorChain(final Tuple<String, AvroPhysicalOperatorChain> tuple) {
    try {
        final AvroPhysicalOperatorChain avroPhysicalOperatorChain = tuple.getValue();
        // Create file with the name of the PhysicalOperatorChain Id.
        final File avroPhysicalOperatorChainFile = getAvroPhysicalOperatorChainFile(tuple.getKey());
        final DataFileWriter<AvroPhysicalOperatorChain> dataFileWriter = new DataFileWriter<>(operatorChainDatumWriter);
        dataFileWriter.create(avroPhysicalOperatorChain.getSchema(), avroPhysicalOperatorChainFile);
        dataFileWriter.append(avroPhysicalOperatorChain);
        dataFileWriter.close();
    } catch (IOException e) {
        throw new RuntimeException("Writing AvroPhysicalOperatorChain has failed.");
    }
}
Also used : DataFileWriter(org.apache.avro.file.DataFileWriter) AvroPhysicalOperatorChain(edu.snu.mist.formats.avro.AvroPhysicalOperatorChain) IOException(java.io.IOException) File(java.io.File)

Aggregations

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