chibenwa commented on code in PR #997:
URL: https://github.com/apache/james-project/pull/997#discussion_r874631331
##########
mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraDeletedMessageDAO.java:
##########
@@ -123,12 +124,34 @@ public Mono<Void> addDeleted(CassandraId cassandraId,
MessageUid uid) {
.setLong(UID, uid.asLong()));
}
+ public Mono<Void> addDeleted(CassandraId cassandraId, Flux<MessageUid>
uids) {
Review Comment:
We have a simpler reactive pipeline if we have a collection here. We should
likely consider it.
##########
mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraDeletedMessageDAO.java:
##########
@@ -123,12 +124,34 @@ public Mono<Void> addDeleted(CassandraId cassandraId,
MessageUid uid) {
.setLong(UID, uid.asLong()));
}
+ public Mono<Void> addDeleted(CassandraId cassandraId, Flux<MessageUid>
uids) {
+ return uids
+ .window(65535)
+ .flatMap(partialUidsFlux -> partialUidsFlux.reduce(new
BatchStatement(BatchStatement.Type.UNLOGGED), (batch, uid) ->
+ batch.add(addStatement.bind()
+ .setUUID(MAILBOX_ID, cassandraId.asUuid())
+ .setLong(UID, uid.asLong()))))
+ .flatMap(cassandraAsyncExecutor::executeVoid)
+ .then();
+ }
+
public Mono<Void> removeDeleted(CassandraId cassandraId, MessageUid uid) {
return cassandraAsyncExecutor.executeVoid(deleteStatement.bind()
.setUUID(MAILBOX_ID, cassandraId.asUuid())
.setLong(UID, uid.asLong()));
}
+ public Mono<Void> removeDeleted(CassandraId cassandraId, Flux<MessageUid>
uids) {
+ return uids
+ .window(65535)
+ .flatMap(partialUidsFlux -> partialUidsFlux.reduce(new
BatchStatement(BatchStatement.Type.UNLOGGED), (batch, uid) ->
+ batch.add(deleteStatement.bind()
+ .setUUID(MAILBOX_ID, cassandraId.asUuid())
+ .setLong(UID, uid.asLong()))))
+ .flatMap(cassandraAsyncExecutor::executeVoid)
+ .then();
Review Comment:
If we use a collection we could see if the size is worth it to use a batch
and batch things from (say) 2+items...
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]