james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [1/2] james-project git commit: JAMES-1874 Parallel reads on GetMessages (except attachments)
Date Tue, 21 Feb 2017 10:05:13 GMT
Repository: james-project
Updated Branches:
  refs/heads/master 1f6b54942 -> 322d5797a


JAMES-1874 Parallel reads on GetMessages (except attachments)


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/b714e31f
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/b714e31f
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/b714e31f

Branch: refs/heads/master
Commit: b714e31fdd671c99114158eea532c3d727dfe886
Parents: 1f6b549
Author: Benoit Tellier <btellier@linagora.com>
Authored: Mon Feb 20 17:20:08 2017 +0700
Committer: Benoit Tellier <btellier@linagora.com>
Committed: Mon Feb 20 18:03:38 2017 +0700

----------------------------------------------------------------------
 .../cassandra/mail/CassandraMessageIdMapper.java        | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/b714e31f/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageIdMapper.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageIdMapper.java
b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageIdMapper.java
index eec9340..984e2f3 100644
--- a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageIdMapper.java
+++ b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageIdMapper.java
@@ -50,6 +50,7 @@ import org.apache.james.mailbox.store.mail.MessageMapper.FetchType;
 import org.apache.james.mailbox.store.mail.ModSeqProvider;
 import org.apache.james.mailbox.store.mail.model.MailboxMessage;
 import org.apache.james.mailbox.store.mail.model.impl.SimpleMailboxMessage;
+import org.apache.james.util.CompletableFutureUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -92,11 +93,12 @@ public class CassandraMessageIdMapper implements MessageIdMapper {
     }
 
     private Stream<SimpleMailboxMessage> findAsStream(List<MessageId> messageIds,
FetchType fetchType) {
-        List<ComposedMessageIdWithMetaData> composedMessageIds = messageIds.stream()
-            .map(messageId -> imapUidDAO.retrieve((CassandraMessageId) messageId, Optional.empty()))
-            .flatMap(CompletableFuture::join)
-            .collect(Guavate.toImmutableList());
-        return messageDAO.retrieveMessages(composedMessageIds, fetchType, Optional.empty()).join()
+        return CompletableFutureUtil.allOf(
+            messageIds.stream()
+                .map(messageId -> imapUidDAO.retrieve((CassandraMessageId) messageId,
Optional.empty())))
+            .thenApply(stream -> stream.flatMap(Function.identity()))
+            .thenApply(stream -> stream.collect(Guavate.toImmutableList()))
+            .thenCompose(composedMessageIds -> messageDAO.retrieveMessages(composedMessageIds,
fetchType, Optional.empty())).join()
             .filter(pair -> mailboxExists(pair.getLeft()))
             .map(loadAttachments(fetchType))
             .map(toMailboxMessages())


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message