public abstract class StreamWriterBase<T> extends Object implements Writer<T>
Writers that write to a FSDataOutputStream.| Constructor and Description |
|---|
StreamWriterBase() |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the
Writer. |
long |
flush()
Flushes out any internally held data, and returns the offset that the file
must be truncated to at recovery.
|
long |
getPos()
Retrieves the current position, and thus size, of the output file.
|
protected org.apache.hadoop.fs.FSDataOutputStream |
getStream()
Returns the current output stream, if the stream is open.
|
protected void |
hflushOrSync(org.apache.hadoop.fs.FSDataOutputStream os)
If hflush is available in this version of HDFS, then this method calls
hflush, else it calls sync.
|
void |
open(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path path)
Initializes the
Writer for a newly opened bucket file. |
protected org.apache.hadoop.fs.FSDataOutputStream getStream()
protected void hflushOrSync(org.apache.hadoop.fs.FSDataOutputStream os)
throws IOException
os - - The stream to flush/syncIOException - Note: This code comes from Flume
public void open(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path path)
throws IOException
WriterWriter for a newly opened bucket file.
Any internal per-bucket initialization should be performed here.open in interface Writer<T>fs - The FileSystem containing the newly opened file.path - The Path of the newly opened file.IOExceptionpublic long flush()
throws IOException
Writerflush in interface Writer<T>IOExceptionpublic long getPos()
throws IOException
WritergetPos in interface Writer<T>IOExceptionpublic void close()
throws IOException
WriterWriter. If the writer is already closed, no action will be
taken. The call should close all state related to the current output file,
including the output stream opened in open.close in interface Writer<T>IOExceptionCopyright © 2014–2016 The Apache Software Foundation. All rights reserved.