Class BlockWriter

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable
    Direct Known Subclasses:
    LocalFileBlockWriter

    public abstract class BlockWriter
    extends BlockClient
    An abstract writer class to write or update a block stored in managed storage.

    This class does not provide thread-safety.

    • Constructor Summary

      Constructors 
      Constructor Description
      BlockWriter()
      Default constructor for the abstract writer implementations.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      abstract long append​(DataBuffer buffer)
      Appends buffer.readableBytes() bytes to the end of this block writer from the given buffer.
      abstract long append​(io.netty.buffer.ByteBuf buf)
      Appends buf.readableBytes() bytes to the end of this block writer from the given buf.
      abstract long append​(java.nio.ByteBuffer inputBuf)
      Appends data to the end of a block from an input ByteBuffer.
      abstract java.nio.channels.WritableByteChannel getChannel()  
      abstract long getPosition()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • BlockWriter

        public BlockWriter()
        Default constructor for the abstract writer implementations.
    • Method Detail

      • append

        public abstract long append​(java.nio.ByteBuffer inputBuf)
        Appends data to the end of a block from an input ByteBuffer.
        Parameters:
        inputBuf - ByteBuffer that input data is stored in
        Returns:
        the size of data that was appended in bytes
      • append

        public abstract long append​(io.netty.buffer.ByteBuf buf)
                             throws java.io.IOException
        Appends buf.readableBytes() bytes to the end of this block writer from the given buf.
        Parameters:
        buf - the byte buffer that holds the data
        Returns:
        the size of data that was appended in bytes
        Throws:
        java.io.IOException
      • append

        public abstract long append​(DataBuffer buffer)
                             throws java.io.IOException
        Appends buffer.readableBytes() bytes to the end of this block writer from the given buffer.
        Parameters:
        buffer - the byte buffer that holds the data
        Returns:
        the size of data that was appended in bytes
        Throws:
        java.io.IOException
      • getPosition

        public abstract long getPosition()
        Returns:
        the current write position (same as the number of bytes written)
      • getChannel

        public abstract java.nio.channels.WritableByteChannel getChannel()
        Returns:
        a writeable byte channel of the block