Interface TsFileInput
-
- All Known Implementing Classes:
LocalTsFileInput
public interface TsFileInput
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description voidclose()Closes this channel.StringgetFilePath()longposition()Returns this input's current position.TsFileInputposition(long newPosition)Sets this input's position.intread(ByteBuffer dst)Reads a sequence of bytes from this TsFileInput into the given buffer.intread(ByteBuffer dst, long position)Reads a sequence of bytes from this TsFileInput into the given buffer, starting at the given position.default StringreadVarIntString(long offset)read a string from the Input at the given positionlongsize()Returns the current size of this input.InputStreamwrapAsInputStream()
-
-
-
Method Detail
-
size
long size() throws IOException
Returns the current size of this input.- Returns:
- The current size of this input, measured in bytes
- Throws:
ClosedChannelException- If this channel is closedIOException- If some other I/O error occurs
-
position
long position() throws IOExceptionReturns this input's current position.- Returns:
- This input's current position, a non-negative integer counting the number of bytes from the beginning of the input to the current position
- Throws:
ClosedChannelException- If this input is closedIOException- If some other I/O error occurs
-
position
TsFileInput position(long newPosition) throws IOException
Sets this input's position.Setting the position to a value that is greater than the input's current size is legal but does not change the size of the TsFileInput. A later attempt to read bytes at such a position will immediately return an end-of-file indication.
- Parameters:
newPosition- The new position, a non-negative integer counting the number of bytes from the beginning of the TsFileInput- Returns:
- This TsFileInput
- Throws:
ClosedChannelException- If this TsFileInput is closedIllegalArgumentException- If the new position is negativeIOException- If some other I/O error occurs
-
read
int read(ByteBuffer dst) throws IOException
Reads a sequence of bytes from this TsFileInput into the given buffer.Bytes are read starting at this TsFileInput's current position, and then the position is updated with the number of bytes actually read. Otherwise this method behaves exactly as specified in the
ReadableByteChannelinterface.- Throws:
IOException
-
read
int read(ByteBuffer dst, long position) throws IOException
Reads a sequence of bytes from this TsFileInput into the given buffer, starting at the given position.This method works in the same manner as the
read(ByteBuffer)method, except that bytes are read starting at the given position rather than at the TsFileInput's current position. This method does not modify this TsFileInput's position. If the given position is greater than the TsFileInput's current size then no bytes are read.- Parameters:
dst- The buffer into which bytes are to be transferredposition- The position at which the transfer is to begin; must be non-negative- Returns:
- The number of bytes read, possibly zero, or -1 if the given position is greater than or equal to the file's current size
- Throws:
IllegalArgumentException- If the position is negativeClosedChannelException- If this TsFileInput is closedAsynchronousCloseException- If another thread closes this TsFileInput while the read operation is in progressClosedByInterruptException- If another thread interrupts the current thread while the read operation is in progress, thereby closing the channel and setting the current thread's interrupt statusIOException- If some other I/O error occurs
-
wrapAsInputStream
InputStream wrapAsInputStream() throws IOException
- Throws:
IOException
-
close
void close() throws IOExceptionCloses this channel.If the channel has already been closed then this method returns immediately.
- Throws:
IOException- If an I/O error occurs
-
readVarIntString
default String readVarIntString(long offset) throws IOException
read a string from the Input at the given position- Throws:
IOException
-
getFilePath
String getFilePath()
-
-