Class SeekableBAIS
java.lang.Object
java.io.InputStream
java.io.ByteArrayInputStream
org.apache.drill.exec.vector.complex.fn.SeekableBAIS
- All Implemented Interfaces:
Closeable
,AutoCloseable
,org.apache.hadoop.fs.PositionedReadable
,org.apache.hadoop.fs.Seekable
public class SeekableBAIS
extends ByteArrayInputStream
implements org.apache.hadoop.fs.Seekable, org.apache.hadoop.fs.PositionedReadable
A ByteArrayInputStream that supports the HDFS Seekable API.
-
Field Summary
Fields inherited from class java.io.ByteArrayInputStream
buf, count, mark, pos
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionlong
getPos()
int
read
(long position, byte[] buffer, int offset, int length) Read up to the specified number of bytes, from a given position within a file, and return the number of bytes read.void
readFully
(long position, byte[] buffer) Read number of bytes equal to the length of the buffer, from a given position within a file.void
readFully
(long position, byte[] buffer, int offset, int length) Read the specified number of bytes, from a given position within a file.void
seek
(long pos) boolean
seekToNewSource
(long targetPos) Methods inherited from class java.io.ByteArrayInputStream
available, close, mark, markSupported, read, read, reset, skip
Methods inherited from class java.io.InputStream
read
-
Constructor Details
-
SeekableBAIS
public SeekableBAIS(byte[] buf, int offset, int length) -
SeekableBAIS
public SeekableBAIS(byte[] buf)
-
-
Method Details
-
seek
- Specified by:
seek
in interfaceorg.apache.hadoop.fs.Seekable
- Throws:
IOException
-
getPos
- Specified by:
getPos
in interfaceorg.apache.hadoop.fs.Seekable
- Throws:
IOException
-
seekToNewSource
- Specified by:
seekToNewSource
in interfaceorg.apache.hadoop.fs.Seekable
- Throws:
IOException
-
read
Read up to the specified number of bytes, from a given position within a file, and return the number of bytes read. This does not change the current offset of a file, and is thread-safe. Warning: Not all filesystems satisfy the thread-safety requirement.- Specified by:
read
in interfaceorg.apache.hadoop.fs.PositionedReadable
- Parameters:
position
- position within filebuffer
- destination bufferoffset
- offset in the bufferlength
- number of bytes to read- Returns:
- actual number of bytes read; -1 means "none"
- Throws:
IOException
- IO problems.
-
readFully
Read the specified number of bytes, from a given position within a file. This does not change the current offset of a file, and is thread-safe. Warning: Not all filesystems satisfy the thread-safety requirement.- Specified by:
readFully
in interfaceorg.apache.hadoop.fs.PositionedReadable
- Parameters:
position
- position within filebuffer
- destination bufferoffset
- offset in the bufferlength
- number of bytes to read- Throws:
IOException
- IO problems.EOFException
- the end of the data was reached before the read operation completed
-
readFully
Read number of bytes equal to the length of the buffer, from a given position within a file. This does not change the current offset of a file, and is thread-safe. Warning: Not all filesystems satisfy the thread-safety requirement.- Specified by:
readFully
in interfaceorg.apache.hadoop.fs.PositionedReadable
- Parameters:
position
- position within filebuffer
- destination buffer- Throws:
IOException
- IO problems.EOFException
- the end of the data was reached before the read operation completed
-