Class StreamingBatch<T>

  • Type Parameters:
    T - The type of data held (ColumnarRowView or ArrowResultChunk)

    public class StreamingBatch<T>
    extends Object
    Type-safe batch container for streaming results.

    This generic container holds batch data of any type (ColumnarRowView or ArrowResultChunk) and manages batch lifecycle including status tracking and resource cleanup.

    • Constructor Detail

      • StreamingBatch

        public StreamingBatch​(long batchIndex,
                              long rowOffset,
                              Consumer<T> releaseAction)
        Creates a new batch with the specified release action.
        Parameters:
        batchIndex - The batch index
        rowOffset - The starting row offset
        releaseAction - Action to call when releasing data (e.g., ArrowResultChunk::releaseChunk)
    • Method Detail

      • setData

        public void setData​(T data,
                            long rowCount,
                            boolean hasMoreRows)
        Sets the batch data and marks as ready.
        Parameters:
        data - The batch data
        rowCount - Number of rows in this batch
        hasMoreRows - Whether more batches are available after this one
      • getData

        public T getData()
        Gets the typed data. No casting required!
        Returns:
        The batch data
      • setFetching

        public void setFetching()
        Sets the batch as currently fetching.
      • setError

        public void setError​(Throwable error)
        Sets error state.
        Parameters:
        error - The error that occurred
      • isReady

        public boolean isReady()
        Checks if the batch is ready.
        Returns:
        true if data is available
      • release

        public void release()
        Releases the batch data using the type-specific release action.
      • getBatchIndex

        public long getBatchIndex()
        Gets the batch index.
        Returns:
        The zero-based batch index
      • getRowOffset

        public long getRowOffset()
        Gets the row offset.
        Returns:
        The starting row offset for this batch
      • getRowCount

        public long getRowCount()
        Gets the row count.
        Returns:
        The number of rows in this batch
      • hasMoreRows

        public boolean hasMoreRows()
        Checks if more rows are available after this batch.
        Returns:
        true if more batches are available
      • getStatus

        public StreamingBatch.Status getStatus()
        Gets the current status.
        Returns:
        The batch status
      • getError

        public Throwable getError()
        Gets the error if status is ERROR.
        Returns:
        The error, or null if no error occurred