Class StreamingInlineArrowResult

  • All Implemented Interfaces:
    IExecutionResult

    public class StreamingInlineArrowResult
    extends Object
    implements IExecutionResult
    High-throughput streaming implementation for inline Arrow results.

    Uses ThriftStreamingProvider for proactive batch prefetching, achieving throughput comparable to eager loading while maintaining the memory benefits of lazy loading.

    Key features:

    • Background prefetch thread fetches Arrow batches ahead of consumption
    • Sliding window limits memory usage to a configurable number of batches
    • Non-blocking iteration when prefetch keeps up with consumption
    • Automatic native memory cleanup via type-safe release actions
    • Type-safe: Uses generic ThriftStreamingProvider<ArrowResultChunk>

    This implementation replaces LazyThriftInlineArrowResult for improved throughput.

    • Constructor Detail

      • StreamingInlineArrowResult

        public StreamingInlineArrowResult​(TFetchResultsResp initialResponse,
                                          IDatabricksStatementInternal statement,
                                          IDatabricksSession session)
                                   throws DatabricksSQLException
        Creates a new StreamingInlineArrowResult.

        Configuration values (maxBatchesInMemory, timeout) are read from the session's connection context.

        Parameters:
        initialResponse - The initial Thrift response containing the first Arrow batch
        statement - The statement that generated this result
        session - The session for fetching additional batches
        Throws:
        DatabricksSQLException - if initialization fails
    • Method Detail

      • getCurrentRow

        public long getCurrentRow()
        Gets the current row index (0-based). Returns -1 if before the first row.
        Specified by:
        getCurrentRow in interface IExecutionResult
        Returns:
        the current row index
      • hasNext

        public boolean hasNext()
        Checks if there are more rows available without advancing the cursor.
        Specified by:
        hasNext in interface IExecutionResult
        Returns:
        true if there are more rows, false otherwise
      • close

        public void close()
        Closes this result and releases associated resources.
        Specified by:
        close in interface IExecutionResult
      • getRowCount

        public long getRowCount()
        Gets the number of rows in the current batch.
        Specified by:
        getRowCount in interface IExecutionResult
        Returns:
        the number of rows in the current batch
      • getChunkCount

        public long getChunkCount()
        Gets the chunk count. Always returns 0 for streaming results.
        Specified by:
        getChunkCount in interface IExecutionResult
        Returns:
        0
      • getTotalRowsFetched

        public long getTotalRowsFetched()
        Gets the total number of rows fetched from the server so far.
        Returns:
        the total rows fetched
      • isCompletelyFetched

        public boolean isCompletelyFetched()
        Checks if all data has been fetched from the server.
        Returns:
        true if end of stream reached
      • getBatchesInMemory

        public int getBatchesInMemory()
        Gets the number of batches currently in memory.
        Returns:
        the batch count in memory