Interface ReactiveCassandraBatchOperations
public interface ReactiveCassandraBatchOperations
Reactive Batch operations for insert/update/delete actions on a table.
ReactiveCassandraBatchOperations
use
logged Cassandra BATCH
es for single entities and collections of entities. 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 TypeMethodDescriptionAdd a collection of deletes to the batch.delete
(Iterable<?> entities, WriteOptions options) Add a collection of deletes with givenWriteOptions
to the batch.Add an array of deletes to the batch.default ReactiveCassandraBatchOperations
delete
(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 givenWriteOptions
to 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 givenWriteOptions
to the batch.Add an array of inserts to the batch.default ReactiveCassandraBatchOperations
insert
(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 givenWriteOptions
to the batch.Add a collection of updates to the batch.update
(Iterable<?> entities, WriteOptions options) Add a collection of updates with givenWriteOptions
to the batch.Add an array of updates to the batch.default ReactiveCassandraBatchOperations
update
(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 givenWriteOptions
to the batch.withTimestamp
(long timestamp) Apply a giventimestamp
to 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 withIllegalStateException
if an already executed batch is being attempted to execute.
-
withTimestamp
Apply a giventimestamp
to the whole batch.- Parameters:
timestamp
- the timestamp to apply.- Returns:
this
ReactiveCassandraBatchOperations
.- Throws:
IllegalStateException
- if the batch was already executed.
-
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:
this
ReactiveCassandraBatchOperations
.- 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:
this
ReactiveCassandraBatchOperations
.- 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:
this
ReactiveCassandraBatchOperations
.- 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:
this
ReactiveCassandraBatchOperations
.- Throws:
IllegalStateException
- if the batch was already executed.
-
insert
Add a collection of inserts with givenWriteOptions
to the batch.- Parameters:
entities
- the entities to insert; must not be null.options
- the WriteOptions to apply; must not be null.- Returns:
this
ReactiveCassandraBatchOperations
.- 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 givenWriteOptions
to the batch.- Parameters:
entities
- the entities to insert; must not be null.options
- the WriteOptions to apply; must not be null.- Returns:
this
ReactiveCassandraBatchOperations
.- 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:
this
ReactiveCassandraBatchOperations
.- 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:
this
ReactiveCassandraBatchOperations
.- 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:
this
ReactiveCassandraBatchOperations
.- 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:
this
ReactiveCassandraBatchOperations
.- Throws:
IllegalStateException
- if the batch was already executed.
-
update
Add a collection of updates with givenWriteOptions
to the batch.- Parameters:
entities
- the entities to update; must not be null.options
- the WriteOptions to apply; must not be null.- Returns:
this
ReactiveCassandraBatchOperations
.- 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 givenWriteOptions
to the batch.- Parameters:
entities
- the entities to update; must not be null.options
- the WriteOptions to apply; must not be null.- Returns:
this
ReactiveCassandraBatchOperations
.- 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:
this
ReactiveCassandraBatchOperations
.- 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:
this
ReactiveCassandraBatchOperations
.- 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:
this
ReactiveCassandraBatchOperations
.- 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:
this
ReactiveCassandraBatchOperations
.- Throws:
IllegalStateException
- if the batch was already executed.
-
delete
Add a collection of deletes with givenWriteOptions
to the batch.- Parameters:
entities
- the entities to delete; must not be null.options
- the WriteOptions to apply; must not be null.- Returns:
this
ReactiveCassandraBatchOperations
.- 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 givenWriteOptions
to the batch.- Parameters:
entities
- the entities to delete; must not be null.options
- the WriteOptions to apply; must not be null.- Returns:
this
ReactiveCassandraBatchOperations
.- Throws:
IllegalStateException
- if the batch was already executed.- Since:
- 2.2
- See Also:
-