Class ArrowStreamReader

java.lang.Object
org.apache.arrow.vector.ipc.ArrowReader
org.apache.arrow.vector.ipc.ArrowStreamReader
All Implemented Interfaces:
AutoCloseable, DictionaryProvider

public class ArrowStreamReader extends ArrowReader
This class reads from an input stream and produces ArrowRecordBatches.
  • Constructor Details

    • ArrowStreamReader

      public ArrowStreamReader(MessageChannelReader messageReader, BufferAllocator allocator, CompressionCodec.Factory compressionFactory)
      Constructs a streaming reader using a MessageChannelReader. Non-blocking.
      Parameters:
      messageReader - reader used to get messages from a ReadChannel
      allocator - to allocate new buffers
      compressionFactory - the factory to create compression codec.
    • ArrowStreamReader

      public ArrowStreamReader(MessageChannelReader messageReader, BufferAllocator allocator)
      Constructs a streaming reader using a MessageChannelReader. Non-blocking.
      Parameters:
      messageReader - reader used to get messages from a ReadChannel
      allocator - to allocate new buffers
    • ArrowStreamReader

      public ArrowStreamReader(ReadableByteChannel in, BufferAllocator allocator, CompressionCodec.Factory compressionFactory)
      Constructs a streaming reader from a ReadableByteChannel input. Non-blocking.
      Parameters:
      in - ReadableByteChannel to read messages from
      allocator - to allocate new buffers
      compressionFactory - the factory to create compression codec.
    • ArrowStreamReader

      public ArrowStreamReader(ReadableByteChannel in, BufferAllocator allocator)
      Constructs a streaming reader from a ReadableByteChannel input. Non-blocking.
      Parameters:
      in - ReadableByteChannel to read messages from
      allocator - to allocate new buffers
    • ArrowStreamReader

      public ArrowStreamReader(InputStream in, BufferAllocator allocator, CompressionCodec.Factory compressionFactory)
      Constructs a streaming reader from a ReadableByteChannel input. Non-blocking.
      Parameters:
      in - InputStream to read messages from
      allocator - to allocate new buffers
      compressionFactory - the factory to create compression codec.
    • ArrowStreamReader

      public ArrowStreamReader(InputStream in, BufferAllocator allocator)
      Constructs a streaming reader from an InputStream. Non-blocking.
      Parameters:
      in - InputStream to read messages from
      allocator - to allocate new buffers
  • Method Details

    • bytesRead

      public long bytesRead()
      Get the number of bytes read from the stream since constructing the reader.
      Specified by:
      bytesRead in class ArrowReader
      Returns:
      number of bytes
    • closeReadSource

      protected void closeReadSource() throws IOException
      Closes the underlying read source.
      Specified by:
      closeReadSource in class ArrowReader
      Throws:
      IOException - on error
    • loadNextBatch

      public boolean loadNextBatch() throws IOException
      Load the next ArrowRecordBatch to the vector schema root if available.
      Specified by:
      loadNextBatch in class ArrowReader
      Returns:
      true if a batch was read, false on EOS
      Throws:
      IOException - on error
    • readSchema

      protected Schema readSchema() throws IOException
      Reads the schema message from the beginning of the stream.
      Specified by:
      readSchema in class ArrowReader
      Returns:
      the deserialized arrow schema
      Throws:
      IOException - on error