Package org.apache.bookkeeper.client.api
Interface LedgerEntry
-
- All Superinterfaces:
java.lang.AutoCloseable
- All Known Implementing Classes:
LedgerEntryImpl
@Public @Unstable public interface LedgerEntry extends java.lang.AutoCloseable
An entry in a ledger.The entry implementation may hold references to byte buffers under the hood. The users holding the references to the instances of this class, are responsible for calling
close()
to release resources held by the entry instances.- Since:
- 4.6
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
close()
LedgerEntry
duplicate()
Returns a duplicate of this entry.io.netty.buffer.ByteBuf
getEntryBuffer()
Return the internalByteBuf
that contains the entry payload.byte[]
getEntryBytes()
Returns the content of the entry as a byte array.long
getEntryId()
The id of the entry.java.nio.ByteBuffer
getEntryNioBuffer()
Exposes this entry's data as an NIOByteBuffer
.long
getLedgerId()
The id of the ledger which contains the entry.long
getLength()
The length of the entry, that is the size of the content expressed in bytes.
-
-
-
Method Detail
-
getLedgerId
long getLedgerId()
The id of the ledger which contains the entry.- Returns:
- the id of the ledger
-
getEntryId
long getEntryId()
The id of the entry.- Returns:
- the id of the entry
-
getLength
long getLength()
The length of the entry, that is the size of the content expressed in bytes.- Returns:
- the size of the content
-
getEntryBytes
byte[] getEntryBytes()
Returns the content of the entry as a byte array.- Returns:
- the content of the entry
-
getEntryNioBuffer
java.nio.ByteBuffer getEntryNioBuffer()
Exposes this entry's data as an NIOByteBuffer
. The returned buffer shares the content with this underneath bytebuf (which you can get it bygetEntryBuffer()
). Changing the position and limit of the returned NIO buffer does not affect the indexes and marks of this underneath buffer. This method is identical toentry.getEntryBuffer().nioBuffer()
. This method does not modifyreaderIndex
orwriterIndex
of the underlying bytebuf.
-
getEntryBuffer
io.netty.buffer.ByteBuf getEntryBuffer()
Return the internalByteBuf
that contains the entry payload.This call doesn't change the reference count on the returned bytebuf. If you want to use the bytebuf after the entry is released (via
close()
, the caller must retain the references of the bytebuf.- Returns:
- a ByteBuf which contains the data
-
duplicate
LedgerEntry duplicate()
Returns a duplicate of this entry.This call will retain a slice of the underneath byte buffer.
- Returns:
- a duplicated ledger entry
-
close
void close()
- Specified by:
close
in interfacejava.lang.AutoCloseable
-
-