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 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 NIO ByteBuffer. The returned buffer shares the content with this underneath bytebuf (which you can get it by getEntryBuffer()). 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 to entry.getEntryBuffer().nioBuffer(). This method does not modify readerIndex or writerIndex of the underlying bytebuf.
      • getEntryBuffer

        io.netty.buffer.ByteBuf getEntryBuffer()
        Return the internal ByteBuf 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 interface java.lang.AutoCloseable