public class BufferedDirectBufInputStream extends DirectBufInputStream implements Closeable
BufferedDirectBufInputStream reads from the
underlying InputStream in blocks of data, into an
internal buffer. The internal buffer is a direct memory backed
buffer. The implementation is similar to the BufferedInputStream
class except that the internal buffer is a Drillbuf and
not a byte array. The mark and reset methods of the underlying
InputStreamare not supported.| Modifier and Type | Field and Description |
|---|---|
protected int |
count
The number of valid bytes in
internalBuffer. |
protected int |
curPosInBuffer
The current read position in the buffer; the index of the next
character to be read from the
internalBuffer array. |
protected long |
curPosInStream |
protected DrillBuf |
internalBuffer
The internal buffer to keep data read from the underlying inputStream.
|
allocator, enableHints, enforceTotalByteSize, startOffset, streamId, totalByteSizein| Constructor and Description |
|---|
BufferedDirectBufInputStream(InputStream in,
BufferAllocator allocator,
String id,
long startOffset,
long totalByteSize,
boolean enforceTotalByteSize,
boolean enableHints)
Creates a
BufferedDirectBufInputStream
with the default (8 MiB) buffer size. |
BufferedDirectBufInputStream(InputStream in,
BufferAllocator allocator,
String id,
long startOffset,
long totalByteSize,
int bufSize,
boolean enforceTotalByteSize,
boolean enableHints)
Creates a
BufferedDirectBufInputStream
with the specified buffer size. |
| Modifier and Type | Method and Description |
|---|---|
int |
available() |
void |
close() |
long |
getPos() |
void |
init() |
void |
mark(int readlimit) |
boolean |
markSupported() |
int |
read()
Implements the
read method of InputStream. |
int |
read(byte[] b) |
int |
read(byte[] buf,
int off,
int len) |
int |
read(DrillBuf buf,
int off,
int len)
Has the same contract as
InputStream.read(byte[], int, int)
Except with DrillBuf |
void |
reset() |
long |
skip(long n)
Has the same contract as
InputStream.skip(long)
Skips upto the next n bytes. |
checkInputStreamState, checkStreamSupportsByteBuffer, fadviseIfAvailable, getInputStream, getNext, hasRemainderprotected volatile DrillBuf internalBuffer
internalBuffer[0] through internalBuffer[count-1]
contains data read from the underlying input stream.protected int count
internalBuffer.
count is always in the range [0,internalBuffer.capacity]
internalBuffer[count-1] is the last valid byte in the buffer.protected int curPosInBuffer
internalBuffer array.
This value is always in the range [0,count].
If curPosInBuffer is equal to count> then we have read
all the buffered data and the next read (or skip) will require more data to be read
from the underlying input stream.protected long curPosInStream
public BufferedDirectBufInputStream(InputStream in, BufferAllocator allocator, String id, long startOffset, long totalByteSize, boolean enforceTotalByteSize, boolean enableHints)
BufferedDirectBufInputStream
with the default (8 MiB) buffer size.public BufferedDirectBufInputStream(InputStream in, BufferAllocator allocator, String id, long startOffset, long totalByteSize, int bufSize, boolean enforceTotalByteSize, boolean enableHints)
BufferedDirectBufInputStream
with the specified buffer size.public void init()
throws UnsupportedOperationException,
IOException
init in class DirectBufInputStreamUnsupportedOperationExceptionIOExceptionpublic int read()
throws IOException
read method of InputStream.
returns one more byte or -1 if end of stream is reached.read in class DirectBufInputStreamIOExceptionpublic int read(DrillBuf buf, int off, int len) throws IOException
InputStream.read(byte[], int, int)
Except with DrillBufread in class DirectBufInputStreamIOExceptionpublic int read(byte[] b)
throws IOException
read in class FilterInputStreamIOExceptionpublic int read(byte[] buf,
int off,
int len)
throws IOException
read in class FilterInputStreamIOExceptionpublic long skip(long n)
throws IOException
InputStream.skip(long)
Skips upto the next n bytes.
Skip may return with less than n bytes skippedskip in class FilterInputStreamIOExceptionpublic int available()
throws IOException
available in class FilterInputStreamIOExceptionpublic void mark(int readlimit)
mark in class FilterInputStreampublic void reset()
throws IOException
reset in class FilterInputStreamIOExceptionpublic boolean markSupported()
markSupported in class FilterInputStreampublic long getPos()
throws IOException
getPos in class DirectBufInputStreamIOExceptionpublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in class DirectBufInputStreamIOExceptionCopyright © 2022 The Apache Software Foundation. All rights reserved.