Class WriteChannel

java.lang.Object
org.apache.arrow.vector.ipc.WriteChannel
All Implemented Interfaces:
AutoCloseable

public class WriteChannel extends Object implements AutoCloseable
Wrapper around a WritableByteChannel that maintains the position as well adding some common serialization utilities.

All write methods in this class follow full write semantics, i.e., write calls only return after requested data has been fully written. Note this is different from java WritableByteChannel interface where partial write is allowed

Please note that objects of this class are not thread-safe.

  • Constructor Details

  • Method Details

    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Throws:
      IOException
    • getCurrentPosition

      public long getCurrentPosition()
    • write

      public long write(byte[] buffer) throws IOException
      Throws:
      IOException
    • writeZeros

      public long writeZeros(long zeroCount) throws IOException
      Writes zeroCount zeros the underlying channel.
      Throws:
      IOException
    • align

      public long align() throws IOException
      Writes enough bytes to align the channel to an 8-byte boundary.
      Throws:
      IOException
    • write

      public long write(ByteBuffer buffer) throws IOException
      Writes all data from buffer to the underlying channel.
      Throws:
      IOException
    • writeIntLittleEndian

      public long writeIntLittleEndian(int v) throws IOException
      Writes v in little-endian format to the underlying channel.
      Throws:
      IOException
    • write

      public void write(ArrowBuf buffer) throws IOException
      Writes the buffer to the underlying channel.
      Throws:
      IOException
    • write

      public long write(FBSerializable writer, boolean withSizePrefix) throws IOException
      Writes the serialized flatbuffer to the underlying channel. If withSizePrefix is true then the length in bytes of the buffer will first be written in little endian format.
      Throws:
      IOException
    • serialize

      public static ByteBuffer serialize(FBSerializable writer)
      Serializes writer to a ByteBuffer.