Interface Batch
- All Known Subinterfaces:
GroupedBatch, SingleStatementBatch
Represents the lifecycle of a batch of statements to be executed together.
The base contract intentionally exposes only lifecycle operations shared by all batching strategies. Concrete specializations define how rows are added to the batch:
GroupedBatchbatches rows through a group of prepared statements.SingleStatementBatchbatches rows for one prepared mutation statement shape.
A batch is usually associated with a JdbcCoordinator,
which owns the currently active batch for a session and coordinates execution
when the active batch changes.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddObserver(BatchObserver observer) Adds an observer to this batch.voidexecute()Execute this batch.getKey()Retrieve the object used to identify compatible rows for this batch.voidrelease()Used to indicate that the batch instance is no longer needed and that, therefore, it can release its resources.
-
Method Details
-
getKey
BatchKey getKey()Retrieve the object used to identify compatible rows for this batch.
The
JdbcCoordinatoruses the key to decide whether a requested batch can reuse the currently active batch or must first execute and release it.- Returns:
- The batch key.
-
addObserver
Adds an observer to this batch.
Observers are notified when a batch is executed explicitly, for example at the end of a flush, or implicitly, for example when adding a row fills the configured JDBC batch size.
- Parameters:
observer- The batch observer.
-
execute
void execute()Execute this batch.
Implementations should tolerate being called when there is no pending row. This method is also responsible for any observer notification associated with explicit execution.
-
release
void release()Used to indicate that the batch instance is no longer needed and that, therefore, it can release its resources.
This is called when the batch instance is no longer the active batch for the owning coordinator. Implementations should release JDBC statements and clear transient row state, but should not execute pending work that has not already been executed by
execute().
-