@Internal public class RefCountedBufferingFileStream extends RefCountedFSOutputStream
RefCountedFile that also uses an in-memory buffer for buffering small writes.
This is done to avoid frequent 'flushes' of the file stream to disk.| Modifier and Type | Field and Description |
|---|---|
static int |
BUFFER_SIZE |
| Constructor and Description |
|---|
RefCountedBufferingFileStream(RefCountedFile file,
int bufferSize) |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
void |
flush() |
File |
getInputFile()
Gets the underlying
File that allows to read the contents of the file. |
long |
getPos() |
int |
getReferenceCounter() |
boolean |
isClosed()
Checks if the file is closed for writes.
|
static RefCountedBufferingFileStream |
openNew(org.apache.flink.util.function.FunctionWithException<File,RefCountedFile,IOException> tmpFileProvider) |
boolean |
release()
Decreases the reference counter.
|
static RefCountedBufferingFileStream |
restore(org.apache.flink.util.function.FunctionWithException<File,RefCountedFile,IOException> tmpFileProvider,
File initialTmpFile) |
void |
retain()
Increases the reference counter.
|
void |
sync() |
String |
toString() |
void |
write(byte[] b,
int off,
int len) |
void |
write(int b) |
writepublic static final int BUFFER_SIZE
@VisibleForTesting public RefCountedBufferingFileStream(RefCountedFile file, int bufferSize)
public File getInputFile()
RefCountedFSOutputStreamFile that allows to read the contents of the file.getInputFile in class RefCountedFSOutputStreampublic long getPos()
getPos in class org.apache.flink.core.fs.FSDataOutputStreampublic void write(int b)
throws IOException
write in class OutputStreamIOExceptionpublic void write(byte[] b,
int off,
int len)
throws IOException
write in class OutputStreamIOExceptionpublic void flush()
throws IOException
flush in interface Flushableflush in class org.apache.flink.core.fs.FSDataOutputStreamIOExceptionpublic void sync()
throws IOException
sync in class org.apache.flink.core.fs.FSDataOutputStreamIOExceptionpublic boolean isClosed()
throws IOException
RefCountedFSOutputStreamisClosed in class RefCountedFSOutputStreamtrue if the file is closed, false otherwise.IOExceptionpublic void close()
close in interface Closeableclose in interface AutoCloseableclose in class org.apache.flink.core.fs.FSDataOutputStreampublic void retain()
RefCountedpublic boolean release()
RefCountedtrue if the reference
counter reached 0, false otherwise.@VisibleForTesting public int getReferenceCounter()
public static RefCountedBufferingFileStream openNew(org.apache.flink.util.function.FunctionWithException<File,RefCountedFile,IOException> tmpFileProvider) throws IOException
IOExceptionpublic static RefCountedBufferingFileStream restore(org.apache.flink.util.function.FunctionWithException<File,RefCountedFile,IOException> tmpFileProvider, File initialTmpFile) throws IOException
IOExceptionCopyright © 2014–2019 The Apache Software Foundation. All rights reserved.