Interface LogReader
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
DirectReader
Interface for reading from a bookkeeper entry log.
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()booleanisClosed()intlogId()longio.netty.buffer.ByteBufreadBufferAt(long offset, int size) Read a buffer from the file.io.netty.buffer.ByteBufreadEntryAt(int offset) Read an entry at a given offset.intreadIntAt(long offset) Read an integer at a given offset.voidreadIntoBufferAt(io.netty.buffer.ByteBuf buffer, long offset, int size) longreadLongAt(long offset) Read an long at a given offset.
-
Method Details
-
logId
int logId()- Returns:
- the id of the log being read from.
-
maxOffset
long maxOffset()- Returns:
- the maximum offset in the file that can be read from.
-
readBufferAt
Read a buffer from the file. It is the responsibility of the caller to release the returned buffer.- Parameters:
offset- the offset to read atsize- the number of bytes to read- Returns:
- a bytebuf. The caller must release.
- Throws:
IOExceptionEOFException
-
readIntoBufferAt
void readIntoBufferAt(io.netty.buffer.ByteBuf buffer, long offset, int size) throws IOException, EOFException - Throws:
IOExceptionEOFException
-
readIntAt
Read an integer at a given offset.- Parameters:
offset- the offset to read from.- Returns:
- the integer at that offset.
- Throws:
IOExceptionEOFException
-
readLongAt
Read an long at a given offset.- Parameters:
offset- the offset to read from.- Returns:
- the long at that offset.
- Throws:
IOExceptionEOFException
-
readEntryAt
Read an entry at a given offset. The size of the entry must be at (offset - Integer.BYTES). The payload of the entry starts at offset. It is the responsibility of the caller to release the returned buffer.- Parameters:
offset- the offset at which to read the entry.- Returns:
- a bytebuf. The caller must release.
- Throws:
IOExceptionEOFException
-
close
- Specified by:
closein interfaceAutoCloseable- Throws:
IOException
-
isClosed
boolean isClosed()
-