Package org.apache.hadoop.hbase.io
Class ByteBufferWriterOutputStream
java.lang.Object
java.io.OutputStream
org.apache.hadoop.hbase.io.ByteBufferWriterOutputStream
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable,ByteBufferWriter
When deal with OutputStream which is not ByteBufferWriter type, wrap it with this class. We will
have to write offheap ByteBuffer (DBB) data into the OS. This class is having a temp byte array
to which we can copy the DBB data for writing to the OS.
This is used while writing Cell data to WAL. In case of AsyncWAL, the OS created there is ByteBufferWriter. But in case of FSHLog, the OS passed by DFS client, is not of type ByteBufferWriter. We will need this temp solution until DFS client supports writing ByteBuffer directly to the OS it creates.
Note: This class is not thread safe.
This is used while writing Cell data to WAL. In case of AsyncWAL, the OS created there is ByteBufferWriter. But in case of FSHLog, the OS passed by DFS client, is not of type ByteBufferWriter. We will need this temp solution until DFS client supports writing ByteBuffer directly to the OS it creates.
Note: This class is not thread safe.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate byte[]private final intprivate static final intprivate final OutputStream -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()voidflush()voidwrite(byte[] b, int off, int len) voidwrite(int b) voidwrite(ByteBuffer b, int off, int len) Writes len bytes from the specified ByteBuffer starting at offset off to this OutputStream.voidwriteInt(int i) Writes anintto the underlying output stream as four bytes, high byte first.Methods inherited from class java.io.OutputStream
write
-
Field Details
-
DEFAULT_BUFFER_SIZE
- See Also:
-
os
-
bufSize
-
buf
-
-
Constructor Details
-
ByteBufferWriterOutputStream
-
ByteBufferWriterOutputStream
-
-
Method Details
-
write
Writes len bytes from the specified ByteBuffer starting at offset off to this OutputStream. If b is null, a NullPointerException is thrown. If off is negative or larger than the ByteBuffer then an ArrayIndexOutOfBoundsException is thrown. If len is greater than the length of the ByteBuffer, then an ArrayIndexOutOfBoundsException is thrown. This method does not change the position of the ByteBuffer.- Specified by:
writein interfaceByteBufferWriter- Parameters:
b- the ByteBufferoff- the start offset in the datalen- the number of bytes to write if an I/O error occurs. In particular, an IOException is thrown if the output stream is closed.- Throws:
IOException- if an I/O error occurs.
-
writeInt
Description copied from interface:ByteBufferWriterWrites anintto the underlying output stream as four bytes, high byte first.- Specified by:
writeIntin interfaceByteBufferWriter- Parameters:
i- theintto write- Throws:
IOException- if an I/O error occurs.
-
write
- Specified by:
writein classOutputStream- Throws:
IOException
-
write
- Overrides:
writein classOutputStream- Throws:
IOException
-
flush
- Specified by:
flushin interfaceFlushable- Overrides:
flushin classOutputStream- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classOutputStream- Throws:
IOException
-