Package com.databricks.jdbc.api.impl.streaming

## Class StreamingBatch<T>

- java.lang.Object
- - com.databricks.jdbc.api.impl.streaming.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.

### Nested Class Summary

Nested Classes
`static class` `StreamingBatch.Status` Batch lifecycle status.

### Constructor Summary

Constructors
`StreamingBatch​(long batchIndex, long rowOffset, Consumer<T> releaseAction)` Creates a new batch with the specified release action.

### Method Summary

All Methods Instance Methods Concrete Methods
`long` `getBatchIndex()` Gets the batch index.
`T` `getData()` Gets the typed data.
`Throwable` `getError()` Gets the error if status is ERROR.
`long` `getRowCount()` Gets the row count.
`long` `getRowOffset()` Gets the row offset.
`StreamingBatch.Status` `getStatus()` Gets the current status.
`boolean` `hasMoreRows()` Checks if more rows are available after this batch.
`boolean` `isReady()` Checks if the batch is ready.
`void` `release()` Releases the batch data using the type-specific release action.
`void` `setData​(T data, long rowCount, boolean hasMoreRows)` Sets the batch data and marks as ready.
`void` `setError​(Throwable error)` Sets error state.
`void` `setFetching()` Sets the batch as currently fetching.
`void` `waitUntilReady​(long timeoutSeconds)` Waits for the batch to be ready.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### 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

#### waitUntilReady

    public void waitUntilReady​(long timeoutSeconds)
                        throws InterruptedException,
                               ExecutionException,
                               TimeoutException

Waits for the batch to be ready.

Parameters:
  `timeoutSeconds` - Maximum time to wait in seconds
Throws:
  `InterruptedException` - if waiting is interrupted
  `ExecutionException` - if the batch fetch failed
  `TimeoutException` - if the timeout is exceeded

#### 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