Class DirectReader
java.lang.Object
org.apache.bookkeeper.bookie.storage.directentrylogger.DirectReader
- All Implemented Interfaces:
AutoCloseable,LogReader
-
Constructor Summary
ConstructorsConstructorDescriptionDirectReader(int logId, String filename, io.netty.buffer.ByteBufAllocator allocator, NativeIO nativeIO, int bufferSize, int maxSaneEntrySize, OpStatsLogger readBlockStats) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()booleanisClosed()intlogId()long(package private) voidreadBlock(long offset) io.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.
-
Constructor Details
-
DirectReader
DirectReader(int logId, String filename, io.netty.buffer.ByteBufAllocator allocator, NativeIO nativeIO, int bufferSize, int maxSaneEntrySize, OpStatsLogger readBlockStats) throws IOException - Throws:
IOException
-
-
Method Details
-
logId
public int logId() -
readBufferAt
Description copied from interface:LogReaderRead a buffer from the file. It is the responsibility of the caller to release the returned buffer.- Specified by:
readBufferAtin interfaceLogReader- Parameters:
offset- the offset to read atsize- the number of bytes to read- Returns:
- a bytebuf. The caller must release.
- Throws:
IOExceptionEOFException
-
readIntoBufferAt
public void readIntoBufferAt(io.netty.buffer.ByteBuf buffer, long offset, int size) throws IOException, EOFException - Specified by:
readIntoBufferAtin interfaceLogReader- Throws:
IOExceptionEOFException
-
readIntAt
Description copied from interface:LogReaderRead an integer at a given offset.- Specified by:
readIntAtin interfaceLogReader- Parameters:
offset- the offset to read from.- Returns:
- the integer at that offset.
- Throws:
IOExceptionEOFException
-
readLongAt
Description copied from interface:LogReaderRead an long at a given offset.- Specified by:
readLongAtin interfaceLogReader- Parameters:
offset- the offset to read from.- Returns:
- the long at that offset.
- Throws:
IOExceptionEOFException
-
readEntryAt
Description copied from interface:LogReaderRead 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.- Specified by:
readEntryAtin interfaceLogReader- Parameters:
offset- the offset at which to read the entry.- Returns:
- a bytebuf. The caller must release.
- Throws:
IOExceptionEOFException
-
readBlock
- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceLogReader- Throws:
IOException
-
isClosed
public boolean isClosed() -
maxOffset
public long maxOffset()
-