@InterfaceAudience.LimitedPrivate(value="HDFS") @InterfaceStability.Unstable public abstract class FSOutputSummer extends OutputStream
| Modifier | Constructor and Description |
|---|---|
protected |
FSOutputSummer(Checksum sum,
int maxChunkSize,
int checksumSize) |
| Modifier and Type | Method and Description |
|---|---|
protected abstract void |
checkClosed()
Check if the implementing OutputStream is closed and should no longer
accept writes.
|
static byte[] |
convertToByteStream(Checksum sum,
int checksumSize)
Converts a checksum integer value to a byte stream
|
protected void |
flushBuffer() |
protected void |
flushBuffer(boolean keep) |
protected int |
getBufferedDataSize()
Return the number of valid bytes currently in the buffer.
|
protected void |
resetChecksumChunk(int size)
Resets existing buffer with a new one of the specified size.
|
void |
write(byte[] b,
int off,
int len)
Writes
len bytes from the specified byte array
starting at offset off and generate a checksum for
each data chunk. |
void |
write(int b)
Write one byte
|
protected abstract void |
writeChunk(byte[] b,
int offset,
int len,
byte[] checksum) |
close, flush, writeprotected FSOutputSummer(Checksum sum, int maxChunkSize, int checksumSize)
protected abstract void writeChunk(byte[] b,
int offset,
int len,
byte[] checksum)
throws IOException
IOExceptionprotected abstract void checkClosed()
throws IOException
IOException if it is closed.IOException - if this stream is already closed.public void write(int b)
throws IOException
write in class OutputStreamIOExceptionpublic void write(byte[] b,
int off,
int len)
throws IOException
len bytes from the specified byte array
starting at offset off and generate a checksum for
each data chunk.
This method stores bytes from the given array into this stream's buffer before it gets checksumed. The buffer gets checksumed and flushed to the underlying output stream when all data in a checksum chunk are in the buffer. If the buffer is empty and requested length is at least as large as the size of next checksum chunk size, this method will checksum and write the chunk directly to the underlying output stream. Thus it avoids uneccessary data copy.
write in class OutputStreamb - the data.off - the start offset in the data.len - the number of bytes to write.IOException - if an I/O error occurs.protected void flushBuffer()
throws IOException
IOExceptionprotected void flushBuffer(boolean keep)
throws IOException
IOExceptionprotected int getBufferedDataSize()
public static byte[] convertToByteStream(Checksum sum, int checksumSize)
protected void resetChecksumChunk(int size)
Copyright © 2013 Apache Software Foundation. All rights reserved.