You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by bt...@apache.org on 2020/03/02 03:16:00 UTC
[james-project] 03/29: MAILBOX-396
CassandraMailboxMapper::findMailboxWithPathLike reactive
This is an automated email from the ASF dual-hosted git repository.
btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 8cc581e69d8ae2158d4ae94d31559abb10b0c505
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Wed Feb 26 09:14:06 2020 +0700
MAILBOX-396 CassandraMailboxMapper::findMailboxWithPathLike reactive
We can:
- Avoid calling two time block in a sequential manner
- We can avoid fetching mailbox details and ACLs for entries already
migrated to V2
---
.../cassandra/mail/CassandraMailboxMapper.java | 33 +++++++---------------
1 file changed, 10 insertions(+), 23 deletions(-)
diff --git a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapper.java b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapper.java
index 1c549db..bfeb59f 100644
--- a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapper.java
+++ b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapper.java
@@ -42,9 +42,7 @@ import org.apache.james.util.ReactorUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.github.steveash.guavate.Guavate;
import com.google.common.base.Preconditions;
-import com.google.common.collect.ImmutableList;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
@@ -137,27 +135,16 @@ public class CassandraMailboxMapper implements MailboxMapper {
@Override
public List<Mailbox> findMailboxWithPathLike(MailboxQuery.UserBound query) {
- List<Mailbox> mailboxesV2 = toMailboxes(query, mailboxPathV2DAO.listUserMailboxes(query.getFixedNamespace(), query.getFixedUser()));
- List<Mailbox> mailboxesV1 = toMailboxes(query, mailboxPathDAO.listUserMailboxes(query.getFixedNamespace(), query.getFixedUser()));
-
- List<Mailbox> mailboxesV1NotInV2 = mailboxesV1.stream()
- .filter(mailboxV1 -> mailboxesV2.stream()
- .map(Mailbox::generateAssociatedPath)
- .noneMatch(mailboxV2path -> mailboxV2path.equals(mailboxV1.generateAssociatedPath())))
- .collect(Guavate.toImmutableList());
-
- return ImmutableList.<Mailbox>builder()
- .addAll(mailboxesV2)
- .addAll(mailboxesV1NotInV2)
- .build();
- }
-
- private List<Mailbox> toMailboxes(MailboxQuery.UserBound query, Flux<CassandraIdAndPath> listUserMailboxes) {
- return listUserMailboxes
- .filter(idAndPath -> query.isPathMatch(idAndPath.getMailboxPath()))
- .concatMap(this::retrieveMailbox)
- .collectList()
- .block();
+ String fixedNamespace = query.getFixedNamespace();
+ Username fixedUser = query.getFixedUser();
+
+ return Flux.concat(mailboxPathV2DAO.listUserMailboxes(fixedNamespace, fixedUser),
+ mailboxPathDAO.listUserMailboxes(fixedNamespace, fixedUser))
+ .filter(idAndPath -> query.isPathMatch(idAndPath.getMailboxPath()))
+ .distinct(CassandraIdAndPath::getMailboxPath)
+ .concatMap(this::retrieveMailbox)
+ .collectList()
+ .block();
}
private Mono<Mailbox> retrieveMailbox(CassandraIdAndPath idAndPath) {
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org