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 Modifier and Type Class Description static classStreamingBatch.StatusBatch lifecycle status.
-
Constructor Summary
Constructors Constructor Description 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 Modifier and Type Method Description longgetBatchIndex()Gets the batch index.TgetData()Gets the typed data.ThrowablegetError()Gets the error if status is ERROR.longgetRowCount()Gets the row count.longgetRowOffset()Gets the row offset.StreamingBatch.StatusgetStatus()Gets the current status.booleanhasMoreRows()Checks if more rows are available after this batch.booleanisReady()Checks if the batch is ready.voidrelease()Releases the batch data using the type-specific release action.voidsetData(T data, long rowCount, boolean hasMoreRows)Sets the batch data and marks as ready.voidsetError(Throwable error)Sets error state.voidsetFetching()Sets the batch as currently fetching.voidwaitUntilReady(long timeoutSeconds)Waits for the batch to be ready.
-
-
-
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 indexrowOffset- The starting row offsetreleaseAction- 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 datarowCount- Number of rows in this batchhasMoreRows- 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, TimeoutExceptionWaits for the batch to be ready.- Parameters:
timeoutSeconds- Maximum time to wait in seconds- Throws:
InterruptedException- if waiting is interruptedExecutionException- if the batch fetch failedTimeoutException- 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
-
-