Class StreamingColumnarResult

  • All Implemented Interfaces:
    IExecutionResult

    public class StreamingColumnarResult
    extends Object
    implements IExecutionResult
    High-throughput streaming implementation for Thrift columnar 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 batches ahead of consumption
    • Sliding window limits memory usage to a configurable number of batches
    • Non-blocking iteration when prefetch keeps up with consumption
    • Maintains correct row ordering through sequential fetch
    • Type-safe: Uses generic ThriftStreamingProvider<ColumnarRowView>

    This implementation replaces LazyThriftResult for improved throughput while maintaining the same IExecutionResult interface.

    • Constructor Detail

      • StreamingColumnarResult

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

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

        Parameters:
        initialResponse - The initial Thrift response containing the first 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 thrift columnar results (chunks are an Arrow concept).
        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