Class DelegatingSeekableInputStream
- java.lang.Object
-
- java.io.InputStream
-
- org.apache.parquet.io.SeekableInputStream
-
- org.apache.parquet.io.DelegatingSeekableInputStream
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
public abstract class DelegatingSeekableInputStream extends SeekableInputStream
Implements read methods required bySeekableInputStream
for generic input streams.Implementations must implement
getPos()
andseek(long)
and may optionally implement other read methods to improve performance.
-
-
Constructor Summary
Constructors Constructor Description DelegatingSeekableInputStream(InputStream stream)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
close()
abstract long
getPos()
Return the current position in the InputStream.InputStream
getStream()
int
read()
int
read(byte[] b, int off, int len)
int
read(ByteBuffer buf)
Readbuf.remaining()
bytes of data into aByteBuffer
.void
readFully(byte[] bytes)
Read a byte array of data, from position 0 to the end of the array.void
readFully(byte[] bytes, int start, int len)
Readlen
bytes of data into an array, at positionstart
.void
readFully(ByteBuffer buf)
Readbuf.remaining()
bytes of data into aByteBuffer
.abstract void
seek(long newPos)
Seek to a new position in the InputStream.-
Methods inherited from class java.io.InputStream
available, mark, markSupported, nullInputStream, read, readAllBytes, readNBytes, readNBytes, reset, skip, transferTo
-
-
-
-
Constructor Detail
-
DelegatingSeekableInputStream
public DelegatingSeekableInputStream(InputStream stream)
-
-
Method Detail
-
getStream
public InputStream getStream()
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classInputStream
- Throws:
IOException
-
getPos
public abstract long getPos() throws IOException
Description copied from class:SeekableInputStream
Return the current position in the InputStream.- Specified by:
getPos
in classSeekableInputStream
- Returns:
- current position in bytes from the start of the stream
- Throws:
IOException
- If the underlying stream throws IOException
-
seek
public abstract void seek(long newPos) throws IOException
Description copied from class:SeekableInputStream
Seek to a new position in the InputStream.- Specified by:
seek
in classSeekableInputStream
- Parameters:
newPos
- the new position to seek to- Throws:
IOException
- If the underlying stream throws IOException
-
read
public int read() throws IOException
- Specified by:
read
in classInputStream
- Throws:
IOException
-
read
public int read(byte[] b, int off, int len) throws IOException
- Overrides:
read
in classInputStream
- Throws:
IOException
-
readFully
public void readFully(byte[] bytes) throws IOException
Description copied from class:SeekableInputStream
Read a byte array of data, from position 0 to the end of the array.This method is equivalent to
read(bytes, 0, bytes.length)
.This method will block until len bytes are available to copy into the array, or will throw
EOFException
if the stream ends before the array is full.- Specified by:
readFully
in classSeekableInputStream
- Parameters:
bytes
- a byte array to fill with data from the stream- Throws:
IOException
- If the underlying stream throws IOExceptionEOFException
- If the stream has fewer bytes left than are needed to fill the array,bytes.length
-
readFully
public void readFully(byte[] bytes, int start, int len) throws IOException
Description copied from class:SeekableInputStream
Readlen
bytes of data into an array, at positionstart
.This method will block until len bytes are available to copy into the array, or will throw
EOFException
if the stream ends before the array is full.- Specified by:
readFully
in classSeekableInputStream
- Parameters:
bytes
- a byte array to fill with data from the streamstart
- the starting position in the byte array for datalen
- the length of bytes to read into the byte array- Throws:
IOException
- If the underlying stream throws IOExceptionEOFException
- If the stream has fewer thanlen
bytes left
-
read
public int read(ByteBuffer buf) throws IOException
Description copied from class:SeekableInputStream
Readbuf.remaining()
bytes of data into aByteBuffer
.This method will copy available bytes into the buffer, reading at most
buf.remaining()
bytes. The number of bytes actually copied is returned by the method, or -1 is returned to signal that the end of the underlying stream has been reached.- Specified by:
read
in classSeekableInputStream
- Parameters:
buf
- a byte buffer to fill with data from the stream- Returns:
- the number of bytes read or -1 if the stream ended
- Throws:
IOException
- If the underlying stream throws IOException
-
readFully
public void readFully(ByteBuffer buf) throws IOException
Description copied from class:SeekableInputStream
Readbuf.remaining()
bytes of data into aByteBuffer
.This method will block until
buf.remaining()
bytes are available to copy into the buffer, or will throwEOFException
if the stream ends before the buffer is full.- Specified by:
readFully
in classSeekableInputStream
- Parameters:
buf
- a byte buffer to fill with data from the stream- Throws:
IOException
- If the underlying stream throws IOExceptionEOFException
- If the stream has fewer bytes left than are needed to fill the buffer,buf.remaining()
-
-