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 TypeMethodDescriptioncreate(boolean atomicWrite) Get the output stream to write to the file.path()Get the path of the file.voidwriteAtomically(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
Get the output stream to write to the file.- If the file already exists, (either at the time of creating the
PositionOutputStreamor at the time of closing it), it will be overwritten. - if
atomicWriteis 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.
- If the file already exists, (either at the time of creating the
-
writeAtomically
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 ifreplaceis false. Ifreplaceis 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.
-