Module spring.data.cassandra
Interface ReactiveCassandraBatchOperations
public interface ReactiveCassandraBatchOperations
Reactive Batch operations for insert/update/delete actions on a table.
ReactiveCassandraBatchOperations use
logged Cassandra BATCHes for single entities, collections of entities, and statements. A ReactiveCassandraBatchOperations instance cannot be modified/used once it was executed.
Batches are atomic by default. In the context of a Cassandra batch operation, atomic means that if any of the batch
succeeds, all of it will. Statement order does not matter within a batch. ReactiveCassandraBatchOperations
applies all rows using the same timestamp if supplied, otherwise Cassandra will generate
a timestamp.
Multi partition batches should only be used to achieve atomicity for a few writes on different tables. Apart from this they should be avoided because they’re too expensive. Single partition batches can be used to get atomicity and isolation, they're not much more expensive than normal writes.
- Since:
- 2.1
- Author:
- Oleh Dokuka, Mark Paluch
-
Method Summary
Modifier and TypeMethodDescriptiondefault ReactiveCassandraBatchOperationsaddStatement(com.datastax.oss.driver.api.core.cql.BatchableStatement<?> statement) Add astatementto the batch.addStatement(reactor.core.publisher.Mono<? extends com.datastax.oss.driver.api.core.cql.BatchableStatement<?>> statement) Add a Mono ofstatementto the batch.default ReactiveCassandraBatchOperationsaddStatements(com.datastax.oss.driver.api.core.cql.BatchableStatement<?>... statements) Addstatementsto the batch.default ReactiveCassandraBatchOperationsaddStatements(Iterable<? extends com.datastax.oss.driver.api.core.cql.BatchableStatement<?>> statements) Addstatementsto the batch.addStatements(reactor.core.publisher.Mono<? extends Iterable<? extends com.datastax.oss.driver.api.core.cql.BatchableStatement<?>>> statements) Add Mono ofstatementsto the batch.Add a collection of deletes to the batch.delete(Iterable<?> entities, WriteOptions options) Add a collection of deletes with givenWriteOptionsto the batch.Add an array of deletes to the batch.default ReactiveCassandraBatchOperationsdelete(Object entity, WriteOptions options) Add delete to the batch.Add a collection of deletes to the batch.delete(reactor.core.publisher.Mono<? extends Iterable<?>> entities, WriteOptions options) Add a collection of deletes with givenWriteOptionsto the batch.reactor.core.publisher.Mono<WriteResult>execute()Execute the batch.Add a collection of inserts to the batch.insert(Iterable<?> entities, WriteOptions options) Add a collection of inserts with givenWriteOptionsto the batch.Add an array of inserts to the batch.default ReactiveCassandraBatchOperationsinsert(Object entity, WriteOptions options) Add an insert to the batch.Add a collection of inserts to the batch.insert(reactor.core.publisher.Mono<? extends Iterable<?>> entities, WriteOptions options) Add a collection of inserts with givenWriteOptionsto the batch.Add a collection of updates to the batch.update(Iterable<?> entities, WriteOptions options) Add a collection of updates with givenWriteOptionsto the batch.Add an array of updates to the batch.default ReactiveCassandraBatchOperationsupdate(Object entity, WriteOptions options) Add an update to the batch.Add a collection of updates to the batch.update(reactor.core.publisher.Mono<? extends Iterable<?>> entities, WriteOptions options) Add a collection of updates with givenWriteOptionsto the batch.withQueryOptions(QueryOptions options) Apply givenQueryOptionsto the whole batch statement.withTimestamp(long timestamp) Apply a giventimestampto the whole batch.
-
Method Details
-
execute
reactor.core.publisher.Mono<WriteResult> execute()Execute the batch. The batch can be executed only once. An execution is registered onsubscribe.- Returns:
- the
reactor.core.publisher.Mono<WriteResult>for the bulk operation. Terminates withIllegalStateExceptionif an already executed batch is being attempted to execute.
-
withTimestamp
Apply a giventimestampto the whole batch.- Parameters:
timestamp- the timestamp to apply.- Returns:
thisReactiveCassandraBatchOperations.- Throws:
IllegalStateException- if the batch was already executed.
-
withQueryOptions
Apply givenQueryOptionsto the whole batch statement.- Parameters:
options- the options to apply.- Returns:
thisCassandraBatchOperations.- Throws:
IllegalStateException- if the batch was already executed.- Since:
- 4.4
-
addStatement
default ReactiveCassandraBatchOperations addStatement(com.datastax.oss.driver.api.core.cql.BatchableStatement<?> statement) Add astatementto the batch.- Parameters:
statement- the batchable statement such asINSERT,UPDATE,DELETE.- Returns:
thisReactiveCassandraBatchOperations.- Throws:
IllegalStateException- if the batch was already executed.- Since:
- 4.4
-
addStatement
ReactiveCassandraBatchOperations addStatement(reactor.core.publisher.Mono<? extends com.datastax.oss.driver.api.core.cql.BatchableStatement<?>> statement) Add a Mono ofstatementto the batch.- Parameters:
statement- the batchable statement such asINSERT,UPDATE,DELETE.- Returns:
thisReactiveCassandraBatchOperations.- Throws:
IllegalStateException- if the batch was already executed.- Since:
- 4.4
-
addStatements
default ReactiveCassandraBatchOperations addStatements(com.datastax.oss.driver.api.core.cql.BatchableStatement<?>... statements) Addstatementsto the batch.- Parameters:
statements- the batchable statements such asINSERT,UPDATE,DELETE.- Returns:
thisReactiveCassandraBatchOperations.- Throws:
IllegalStateException- if the batch was already executed.- Since:
- 4.4
-
addStatements
default ReactiveCassandraBatchOperations addStatements(Iterable<? extends com.datastax.oss.driver.api.core.cql.BatchableStatement<?>> statements) Addstatementsto the batch.- Parameters:
statements- the batchable statements such asINSERT,UPDATE,DELETE.- Returns:
thisReactiveCassandraBatchOperations.- Throws:
IllegalStateException- if the batch was already executed.- Since:
- 4.4
-
addStatements
ReactiveCassandraBatchOperations addStatements(reactor.core.publisher.Mono<? extends Iterable<? extends com.datastax.oss.driver.api.core.cql.BatchableStatement<?>>> statements) Add Mono ofstatementsto the batch.- Parameters:
statements- the batchable statements such asINSERT,UPDATE,DELETE.- Returns:
thisReactiveCassandraBatchOperations.- Throws:
IllegalStateException- if the batch was already executed.- Since:
- 4.4
-
insert
Add an insert to the batch.- Parameters:
entity- the entity to insert; must not be null.options- the WriteOptions to apply; must not be null.- Returns:
thisReactiveCassandraBatchOperations.- Throws:
IllegalStateException- if the batch was already executed.- Since:
- 3.2.2
-
insert
Add an array of inserts to the batch.- Parameters:
entities- the entities to insert; must not be null.- Returns:
thisReactiveCassandraBatchOperations.- Throws:
IllegalStateException- if the batch was already executed.
-
insert
Add a collection of inserts to the batch.- Parameters:
entities- the entities to insert; must not be null.- Returns:
thisReactiveCassandraBatchOperations.- Throws:
IllegalStateException- if the batch was already executed.
-
insert
ReactiveCassandraBatchOperations insert(reactor.core.publisher.Mono<? extends Iterable<?>> entities) Add a collection of inserts to the batch.- Parameters:
entities- the entities to insert; must not be null.- Returns:
thisReactiveCassandraBatchOperations.- Throws:
IllegalStateException- if the batch was already executed.
-
insert
Add a collection of inserts with givenWriteOptionsto the batch.- Parameters:
entities- the entities to insert; must not be null.options- the WriteOptions to apply; must not be null.- Returns:
thisReactiveCassandraBatchOperations.- Throws:
IllegalStateException- if the batch was already executed.- See Also:
-
insert
ReactiveCassandraBatchOperations insert(reactor.core.publisher.Mono<? extends Iterable<?>> entities, WriteOptions options) Add a collection of inserts with givenWriteOptionsto the batch.- Parameters:
entities- the entities to insert; must not be null.options- the WriteOptions to apply; must not be null.- Returns:
thisReactiveCassandraBatchOperations.- Throws:
IllegalStateException- if the batch was already executed.- See Also:
-
update
Add an update to the batch.- Parameters:
entity- the entity to update; must not be null.options- the WriteOptions to apply; must not be null.- Returns:
thisReactiveCassandraBatchOperations.- Throws:
IllegalStateException- if the batch was already executed.- Since:
- 3.2.2
-
update
Add an array of updates to the batch.- Parameters:
entities- the entities to update; must not be null.- Returns:
thisReactiveCassandraBatchOperations.- Throws:
IllegalStateException- if the batch was already executed.
-
update
Add a collection of updates to the batch.- Parameters:
entities- the entities to update; must not be null.- Returns:
thisReactiveCassandraBatchOperations.- Throws:
IllegalStateException- if the batch was already executed.
-
update
ReactiveCassandraBatchOperations update(reactor.core.publisher.Mono<? extends Iterable<?>> entities) Add a collection of updates to the batch.- Parameters:
entities- the entities to update; must not be null.- Returns:
thisReactiveCassandraBatchOperations.- Throws:
IllegalStateException- if the batch was already executed.
-
update
Add a collection of updates with givenWriteOptionsto the batch.- Parameters:
entities- the entities to update; must not be null.options- the WriteOptions to apply; must not be null.- Returns:
thisReactiveCassandraBatchOperations.- Throws:
IllegalStateException- if the batch was already executed.- See Also:
-
update
ReactiveCassandraBatchOperations update(reactor.core.publisher.Mono<? extends Iterable<?>> entities, WriteOptions options) Add a collection of updates with givenWriteOptionsto the batch.- Parameters:
entities- the entities to update; must not be null.options- the WriteOptions to apply; must not be null.- Returns:
thisReactiveCassandraBatchOperations.- Throws:
IllegalStateException- if the batch was already executed.- See Also:
-
delete
Add delete to the batch.- Parameters:
entity- the entity to delete; must not be null.options- the WriteOptions to apply; must not be null.- Returns:
thisReactiveCassandraBatchOperations.- Throws:
IllegalStateException- if the batch was already executed.- Since:
- 3.2.2
-
delete
Add an array of deletes to the batch.- Parameters:
entities- the entities to delete; must not be null.- Returns:
thisReactiveCassandraBatchOperations.- Throws:
IllegalStateException- if the batch was already executed.
-
delete
Add a collection of deletes to the batch.- Parameters:
entities- the entities to delete; must not be null.- Returns:
thisReactiveCassandraBatchOperations.- Throws:
IllegalStateException- if the batch was already executed.
-
delete
ReactiveCassandraBatchOperations delete(reactor.core.publisher.Mono<? extends Iterable<?>> entities) Add a collection of deletes to the batch.- Parameters:
entities- the entities to delete; must not be null.- Returns:
thisReactiveCassandraBatchOperations.- Throws:
IllegalStateException- if the batch was already executed.
-
delete
Add a collection of deletes with givenWriteOptionsto the batch.- Parameters:
entities- the entities to delete; must not be null.options- the WriteOptions to apply; must not be null.- Returns:
thisReactiveCassandraBatchOperations.- Throws:
IllegalStateException- if the batch was already executed.- Since:
- 2.2
- See Also:
-
delete
ReactiveCassandraBatchOperations delete(reactor.core.publisher.Mono<? extends Iterable<?>> entities, WriteOptions options) Add a collection of deletes with givenWriteOptionsto the batch.- Parameters:
entities- the entities to delete; must not be null.options- the WriteOptions to apply; must not be null.- Returns:
thisReactiveCassandraBatchOperations.- Throws:
IllegalStateException- if the batch was already executed.- Since:
- 2.2
- See Also:
-