Class DirectReader
- java.lang.Object
-
- org.apache.bookkeeper.bookie.storage.directentrylogger.DirectReader
-
-
Constructor Summary
Constructors Constructor Description DirectReader(int logId, java.lang.String filename, io.netty.buffer.ByteBufAllocator allocator, NativeIO nativeIO, int bufferSize, int maxSaneEntrySize, OpStatsLogger readBlockStats)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
boolean
isClosed()
int
logId()
long
maxOffset()
(package private) void
readBlock(long offset)
io.netty.buffer.ByteBuf
readBufferAt(long offset, int size)
Read a buffer from the file.io.netty.buffer.ByteBuf
readEntryAt(int offset)
Read an entry at a given offset.int
readIntAt(long offset)
Read an integer at a given offset.void
readIntoBufferAt(io.netty.buffer.ByteBuf buffer, long offset, int size)
long
readLongAt(long offset)
Read an long at a given offset.
-
-
-
Constructor Detail
-
DirectReader
DirectReader(int logId, java.lang.String filename, io.netty.buffer.ByteBufAllocator allocator, NativeIO nativeIO, int bufferSize, int maxSaneEntrySize, OpStatsLogger readBlockStats) throws java.io.IOException
- Throws:
java.io.IOException
-
-
Method Detail
-
logId
public int logId()
-
readBufferAt
public io.netty.buffer.ByteBuf readBufferAt(long offset, int size) throws java.io.IOException, java.io.EOFException
Description copied from interface:LogReader
Read a buffer from the file. It is the responsibility of the caller to release the returned buffer.- Specified by:
readBufferAt
in interfaceLogReader
- Parameters:
offset
- the offset to read atsize
- the number of bytes to read- Returns:
- a bytebuf. The caller must release.
- Throws:
java.io.IOException
java.io.EOFException
-
readIntoBufferAt
public void readIntoBufferAt(io.netty.buffer.ByteBuf buffer, long offset, int size) throws java.io.IOException, java.io.EOFException
- Specified by:
readIntoBufferAt
in interfaceLogReader
- Throws:
java.io.IOException
java.io.EOFException
-
readIntAt
public int readIntAt(long offset) throws java.io.IOException, java.io.EOFException
Description copied from interface:LogReader
Read an integer at a given offset.
-
readLongAt
public long readLongAt(long offset) throws java.io.IOException, java.io.EOFException
Description copied from interface:LogReader
Read an long at a given offset.- Specified by:
readLongAt
in interfaceLogReader
- Parameters:
offset
- the offset to read from.- Returns:
- the long at that offset.
- Throws:
java.io.IOException
java.io.EOFException
-
readEntryAt
public io.netty.buffer.ByteBuf readEntryAt(int offset) throws java.io.IOException, java.io.EOFException
Description copied from interface:LogReader
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.- Specified by:
readEntryAt
in interfaceLogReader
- Parameters:
offset
- the offset at which to read the entry.- Returns:
- a bytebuf. The caller must release.
- Throws:
java.io.IOException
java.io.EOFException
-
readBlock
void readBlock(long offset) throws java.io.IOException
- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException
-
-