Class ArrowArrayStream

java.lang.Object
org.apache.arrow.c.ArrowArrayStream
All Implemented Interfaces:
AutoCloseable, BaseStruct

public class ArrowArrayStream extends Object implements BaseStruct
C Stream Interface ArrowArrayStream.

Represents a wrapper for the following C structure:

 struct ArrowArrayStream {
   int (*get_schema)(struct ArrowArrayStream*, struct ArrowSchema* out);
   int (*get_next)(struct ArrowArrayStream*, struct ArrowArray* out);
   const char* (*get_last_error)(struct ArrowArrayStream*);
   void (*release)(struct ArrowArrayStream*);
   void* private_data;
 };
 
  • Method Details

    • wrap

      public static ArrowArrayStream wrap(long memoryAddress)
      Create ArrowArrayStream from an existing memory address.

      The resulting ArrowArrayStream does not own the memory.

      Parameters:
      memoryAddress - Memory address to wrap
      Returns:
      A new ArrowArrayStream instance
    • allocateNew

      public static ArrowArrayStream allocateNew(BufferAllocator allocator)
      Create ArrowArrayStream by allocating memory.

      The resulting ArrowArrayStream owns the memory.

      Parameters:
      allocator - Allocator for memory allocations
      Returns:
      A new ArrowArrayStream instance
    • markReleased

      public void markReleased()
      Mark the array as released.
    • memoryAddress

      public long memoryAddress()
      Description copied from interface: BaseStruct
      Get memory address.
      Specified by:
      memoryAddress in interface BaseStruct
      Returns:
      Memory address
    • release

      public void release()
      Description copied from interface: BaseStruct
      Call the release callback of an ArrowArray.

      This function must not be called for child arrays.

      Specified by:
      release in interface BaseStruct
    • getSchema

      public void getSchema(ArrowSchema schema) throws IOException
      Get the schema of the stream.
      Parameters:
      schema - The ArrowSchema struct to output to
      Throws:
      IOException - if the stream returns an error
    • getNext

      public void getNext(ArrowArray array) throws IOException
      Get the next batch in the stream.
      Parameters:
      array - The ArrowArray struct to output to
      Throws:
      IOException - if the stream returns an error
    • close

      public void close()
      Description copied from interface: BaseStruct
      Close to release the main buffer.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface BaseStruct
    • snapshot

      public ArrowArrayStream.Snapshot snapshot()
      Take a snapshot of the ArrowArrayStream raw values.
      Returns:
      snapshot
    • save

      public void save(ArrowArrayStream.Snapshot snapshot)
      Write values from Snapshot to the underlying ArrowArrayStream memory buffer.