public class ChannelBufferUnsafeInputStream extends InputStreamChannel
ChannelBufferInputStream
using internal unsafe class (~30% in raw read calls).
Use UnsafeHolder.newChannelBufferInputStream(java.nio.channels.ReadableByteChannel, int) method to
create either this or ChannelBufferInputStream depending on
availability.
Note that the close() method of this class does not closing the underlying channel.
| Modifier and Type | Field and Description |
|---|---|
protected long |
addrLimit |
protected long |
addrPosition
Actual buffer position (+baseAddress) accounting is done by this.
|
protected long |
baseAddress |
protected ByteBuffer |
buffer |
bytesRead, channel, PARK_NANOS_MAX, parkedThread| Constructor and Description |
|---|
ChannelBufferUnsafeInputStream(ReadableByteChannel channel) |
ChannelBufferUnsafeInputStream(ReadableByteChannel channel,
int bufferSize) |
| Modifier and Type | Method and Description |
|---|---|
protected ByteBuffer |
allocateBuffer(int bufferSize) |
int |
available() |
void |
close() |
boolean |
isOpen() |
int |
read() |
int |
read(byte[] buf) |
int |
read(byte[] buf,
int off,
int len) |
int |
read(ByteBuffer dst) |
int |
readInt()
Reads four input bytes and returns an
int value. |
protected int |
refillBuffer(ByteBuffer channelBuffer,
int tryReadBytes,
String eofMessage) |
protected void |
resetBufferPositions() |
getBytesRead, getParkedThread, getUnderlyingChannel, readBuffered, readFrame, readFrameFragment, readIntoBuffer, readIntoBufferNonBlocking, refillBufferBase, resetAndCopyLeftOverBytesmark, markSupported, reset, skipprotected ByteBuffer buffer
protected final long baseAddress
protected long addrPosition
protected long addrLimit
public ChannelBufferUnsafeInputStream(ReadableByteChannel channel)
public ChannelBufferUnsafeInputStream(ReadableByteChannel channel, int bufferSize)
protected final void resetBufferPositions()
protected ByteBuffer allocateBuffer(int bufferSize)
public final int read()
throws IOException
read in class InputStreamIOExceptionpublic final int read(@Nonnull byte[] buf) throws IOException
read in class InputStreamIOExceptionpublic final int read(@Nonnull byte[] buf, int off, int len) throws IOException
read in class InputStreamIOExceptionpublic final int read(ByteBuffer dst) throws IOException
read in interface ReadableByteChannelread in class InputStreamChannelIOExceptionpublic final int readInt()
throws IOException
int value. Let
a-d be the first through fourth bytes read. The value returned
is:
(((a & 0xff) << 24) | ((b & 0xff) << 16) |
((c & 0xff) << 8) | (d & 0xff))
This method is suitable for reading bytes written by the
writeInt method of interface DataOutput.readInt in class InputStreamChannelint value read.EOFException - if this stream reaches the end before reading all the bytes.IOException - if an I/O error occurs.public final int available()
available in class InputStreamprotected int refillBuffer(ByteBuffer channelBuffer, int tryReadBytes, String eofMessage) throws IOException
refillBuffer in class InputStreamChannelIOExceptionpublic final boolean isOpen()
public void close()
close in interface Closeableclose in interface AutoCloseableclose in interface Channelclose in class InputStreamCopyright © 2010-2015 Pivotal Software, Inc. All rights reserved.