Interface OutputFile

All Known Implementing Classes:
HadoopOutputFile

public interface OutputFile
Interface for writing to a file and getting metadata about it.
  • Method Summary

    Modifier and Type
    Method
    Description
    create(boolean atomicWrite)
    Get the output stream to write to the file.
    Get the path of the file.
    void
    writeAtomically(CloseableIterator<String> data, boolean overwrite)
    Atomically write (either write is completely or don't write all - i.e.
  • Method Details

    • path

      String path()
      Get the path of the file.
      Returns:
      the path of the file.
    • create

      PositionOutputStream create(boolean atomicWrite) throws IOException
      Get the output stream to write to the file.
      • If the file already exists, (either at the time of creating the PositionOutputStream or at the time of closing it), it will be overwritten.
      • if atomicWrite is set, then the entire content is written or none, but won't create a file with the partial contents.
      Returns:
      the output stream to write to the file. It is the responsibility of the caller to close the stream.
      Throws:
      IOException - if an I/O error occurs.
    • writeAtomically

      void writeAtomically(CloseableIterator<String> data, boolean overwrite) throws IOException
      Atomically write (either write is completely or don't write all - i.e. don't leave file with partial content) the data to a file at the given path. If the file already exists do not replace it if replace is false. If replace is true, then replace the file with the new data.

      TODO: the semantics are very loose here, see if there is a better API name. One of the reasons why the data is passed as an iterator is because of the existing LogStore interface which are used in the Hadoop implementation of the FileIO

      Parameters:
      data - the data to write. Each element in the iterator is a line in the file.
      overwrite - if true, overwrite the file with the new data. If false, do not overwrite the file.
      Throws:
      FileAlreadyExistsException - if the file already exists and replace is false.
      IOException - for any IO error.