Package org.apache.arrow.vector.ipc
Class ArrowStreamReader
java.lang.Object
org.apache.arrow.vector.ipc.ArrowReader
org.apache.arrow.vector.ipc.ArrowStreamReader
- All Implemented Interfaces:
AutoCloseable
,DictionaryProvider
This class reads from an input stream and produces ArrowRecordBatches.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.arrow.vector.dictionary.DictionaryProvider
DictionaryProvider.MapDictionaryProvider
-
Field Summary
Fields inherited from class org.apache.arrow.vector.ipc.ArrowReader
allocator, dictionaries
-
Constructor Summary
ConstructorDescriptionArrowStreamReader
(InputStream in, BufferAllocator allocator) Constructs a streaming reader from an InputStream.ArrowStreamReader
(InputStream in, BufferAllocator allocator, CompressionCodec.Factory compressionFactory) Constructs a streaming reader from a ReadableByteChannel input.ArrowStreamReader
(ReadableByteChannel in, BufferAllocator allocator) Constructs a streaming reader from a ReadableByteChannel input.ArrowStreamReader
(ReadableByteChannel in, BufferAllocator allocator, CompressionCodec.Factory compressionFactory) Constructs a streaming reader from a ReadableByteChannel input.ArrowStreamReader
(MessageChannelReader messageReader, BufferAllocator allocator) Constructs a streaming reader using a MessageChannelReader.ArrowStreamReader
(MessageChannelReader messageReader, BufferAllocator allocator, CompressionCodec.Factory compressionFactory) Constructs a streaming reader using a MessageChannelReader. -
Method Summary
Modifier and TypeMethodDescriptionlong
Get the number of bytes read from the stream since constructing the reader.protected void
Closes the underlying read source.boolean
Load the next ArrowRecordBatch to the vector schema root if available.protected Schema
Reads the schema message from the beginning of the stream.Methods inherited from class org.apache.arrow.vector.ipc.ArrowReader
close, close, ensureInitialized, getDictionaryIds, getDictionaryVectors, getVectorSchemaRoot, initialize, loadDictionary, loadRecordBatch, lookup, prepareLoadNextBatch
-
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 ReadChannelallocator
- to allocate new bufferscompressionFactory
- the factory to create compression codec.
-
ArrowStreamReader
Constructs a streaming reader using a MessageChannelReader. Non-blocking.- Parameters:
messageReader
- reader used to get messages from a ReadChannelallocator
- 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 fromallocator
- to allocate new bufferscompressionFactory
- the factory to create compression codec.
-
ArrowStreamReader
Constructs a streaming reader from a ReadableByteChannel input. Non-blocking.- Parameters:
in
- ReadableByteChannel to read messages fromallocator
- 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 fromallocator
- to allocate new bufferscompressionFactory
- the factory to create compression codec.
-
ArrowStreamReader
Constructs a streaming reader from an InputStream. Non-blocking.- Parameters:
in
- InputStream to read messages fromallocator
- 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 classArrowReader
- Returns:
- number of bytes
-
closeReadSource
Closes the underlying read source.- Specified by:
closeReadSource
in classArrowReader
- Throws:
IOException
- on error
-
loadNextBatch
Load the next ArrowRecordBatch to the vector schema root if available.- Specified by:
loadNextBatch
in classArrowReader
- Returns:
- true if a batch was read, false on EOS
- Throws:
IOException
- on error
-
readSchema
Reads the schema message from the beginning of the stream.- Specified by:
readSchema
in classArrowReader
- Returns:
- the deserialized arrow schema
- Throws:
IOException
- on error
-