Class ChannelWriterOutputView

    • Field Detail

      • HEADER_MAGIC_NUMBER

        protected static final short HEADER_MAGIC_NUMBER
        The magic number that identifies blocks as blocks from a ChannelWriterOutputView.
        See Also:
        Constant Field Values
      • HEADER_LENGTH

        protected static final int HEADER_LENGTH
        The length of the header put into the blocks.
        See Also:
        Constant Field Values
      • HEADER_FLAGS_OFFSET

        protected static final int HEADER_FLAGS_OFFSET
        The offset to the flags in the header;
        See Also:
        Constant Field Values
      • HEAD_BLOCK_LENGTH_OFFSET

        protected static final int HEAD_BLOCK_LENGTH_OFFSET
        The offset to the header field indicating the number of bytes in the block
        See Also:
        Constant Field Values
      • FLAG_LAST_BLOCK

        protected static final short FLAG_LAST_BLOCK
        The flag marking a block as the last block.
        See Also:
        Constant Field Values
    • Constructor Detail

      • ChannelWriterOutputView

        public ChannelWriterOutputView​(BlockChannelWriter<MemorySegment> writer,
                                       List<MemorySegment> memory,
                                       int segmentSize)
        Creates an new ChannelWriterOutputView that writes to the given channel and buffers data in the given memory segments. If the given memory segments are null, the writer takes its buffers directly from the return queue of the writer. Note that this variant locks if no buffers are contained in the return queue.
        Parameters:
        writer - The writer to write to.
        memory - The memory used to buffer data, or null, to utilize solely the return queue.
        segmentSize - The size of the memory segments.
      • ChannelWriterOutputView

        public ChannelWriterOutputView​(BlockChannelWriter<MemorySegment> writer,
                                       int segmentSize)
        Creates an new ChannelWriterOutputView that writes to the given channel. It uses only a single memory segment for the buffering, which it takes from the writer's return queue. Note that this variant locks if no buffers are contained in the return queue.
        Parameters:
        writer - The writer to write to.
        segmentSize - The size of the memory segments.
    • Method Detail

      • close

        public List<MemorySegment> close()
                                  throws IOException
        Closes this OutputView, closing the underlying writer and returning all memory segments.
        Returns:
        A list containing all memory segments originally supplied to this view.
        Throws:
        IOException - Thrown, if the underlying writer could not be properly closed.
      • getBlockCount

        public int getBlockCount()
        Gets the number of blocks used by this view.
        Returns:
        The number of blocks used.
      • getBytesWritten

        public long getBytesWritten()
        Gets the number of pay-load bytes already written. This excludes the number of bytes spent on headers in the segments.
        Returns:
        The number of bytes that have been written to this output view.
      • getBytesMemoryUsed

        public long getBytesMemoryUsed()
        Gets the number of bytes used by this output view, including written bytes and header bytes.
        Returns:
        The number of bytes that have been written to this output view.