@Override public ReactiveCassandraBatchOperations batchOps() { return new ReactiveCassandraBatchTemplate(this); }
@Override public ReactiveCassandraBatchOperations insert(Mono<? extends Iterable<?>> entities, WriteOptions options) { assertNotExecuted(); Assert.notNull(entities, "Entities must not be null"); Assert.notNull(options, "WriteOptions must not be null"); batchMonos.add(entities.map(e -> doInsert(e, options))); return this; }
@Override public ReactiveCassandraBatchOperations delete(Object... entities) { Assert.notNull(entities, "Entities must not be null"); return delete(Arrays.asList(entities)); }
@Override public ReactiveCassandraBatchOperations delete(Iterable<?> entities) { assertNotExecuted(); Assert.notNull(entities, "Entities must not be null"); batchMonos.add(Mono.just(doDelete(entities))); return this; }
@Override public ReactiveCassandraBatchOperations update(Iterable<?> entities, WriteOptions options) { assertNotExecuted(); Assert.notNull(entities, "Entities must not be null"); Assert.notNull(options, "WriteOptions must not be null"); batchMonos.add(Mono.just(doUpdate(entities, options))); return this; }
@Override public ReactiveCassandraBatchOperations insert(Object... entities) { Assert.notNull(entities, "Entities must not be null"); return insert(Arrays.asList(entities)); }
@Override public ReactiveCassandraBatchOperations update(Object... entities) { Assert.notNull(entities, "Entities must not be null"); return update(Arrays.asList(entities)); }
private Collection<? extends BuiltStatement> doUpdate(Iterable<?> entities, WriteOptions options) { List<Update> updateQueries = new ArrayList<>(); CassandraConverter converter = operations.getConverter(); for (Object entity : entities) { Assert.notNull(entity, "Entity must not be null"); updateQueries.add(QueryUtils.createUpdateQuery(getTable(entity), entity, options, converter)); } return updateQueries; }
@Override public ReactiveCassandraBatchOperations delete(Mono<? extends Iterable<?>> entities) { assertNotExecuted(); Assert.notNull(entities, "Entities must not be null"); batchMonos.add(entities.map(this::doDelete)); return this; }
@Override public ReactiveCassandraBatchOperations update(Mono<? extends Iterable<?>> entities, WriteOptions options) { assertNotExecuted(); Assert.notNull(entities, "Entities must not be null"); Assert.notNull(options, "WriteOptions must not be null"); batchMonos.add(entities.map(e -> doUpdate(e, options))); return this; }
@Override public ReactiveCassandraBatchOperations insert(Iterable<?> entities) { return insert(entities, InsertOptions.empty()); }
@Override public ReactiveCassandraBatchOperations update(Iterable<?> entities) { return update(entities, UpdateOptions.empty()); }
private Collection<? extends BuiltStatement> doDelete(Iterable<?> entities) { List<Delete> deleteQueries = new ArrayList<>(); CassandraConverter converter = operations.getConverter(); for (Object entity : entities) { Assert.notNull(entity, "Entity must not be null"); deleteQueries.add(QueryUtils.createDeleteQuery(getTable(entity), entity, QueryOptions.empty(), converter)); } return deleteQueries; }
@Override public ReactiveCassandraBatchOperations withTimestamp(long timestamp) { assertNotExecuted(); batch.using(QueryBuilder.timestamp(timestamp)); return this; }
@Override public ReactiveCassandraBatchOperations insert(Iterable<?> entities, WriteOptions options) { assertNotExecuted(); Assert.notNull(entities, "Entities must not be null"); Assert.notNull(options, "WriteOptions must not be null"); batchMonos.add(Mono.just(doInsert(entities, options))); return this; }
@Override public ReactiveCassandraBatchOperations insert(Mono<? extends Iterable<?>> entities) { return insert(entities, InsertOptions.empty()); }
@Override public ReactiveCassandraBatchOperations update(Mono<? extends Iterable<?>> entities) { return update(entities, UpdateOptions.empty()); }