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 6f4e5beaaaf6f10ac5979c1da536ce103e6985eb
Author: Benoit Tellier <[email protected]>
AuthorDate: Mon Mar 30 14:45:52 2020 +0700

    [Performance] Avoid empty getMessages(FULL) when all messages have preview
    
    ```
    Flux.merge(
        fetch(withProjectionEntry, FetchGroup.HEADERS, mailboxSession)
            .map(messageResults -> Helpers.toMessageViews(messageResults, new 
FromMessageResultAndPreview(blobManager, fastProjections))),
        fetch(withoutProjectionEntry, FetchGroup.FULL_CONTENT, mailboxSession)
            .map(messageResults -> Helpers.toMessageViews(messageResults, 
messageFullViewFactory::fromMessageResults)))
    ```
    
    Calling code results in fetch called with empty message list. We should
    avoid propagating the query which results in a needless empty call on
    messageManager layer (gain of reactor pipeline evaluation)
---
 .../james/jmap/draft/model/message/view/MessageFastViewFactory.java    | 3 +++
 1 file changed, 3 insertions(+)

diff --git 
a/server/protocols/jmap-draft/src/main/java/org/apache/james/jmap/draft/model/message/view/MessageFastViewFactory.java
 
b/server/protocols/jmap-draft/src/main/java/org/apache/james/jmap/draft/model/message/view/MessageFastViewFactory.java
index 7d7334b..cbf3c3c 100644
--- 
a/server/protocols/jmap-draft/src/main/java/org/apache/james/jmap/draft/model/message/view/MessageFastViewFactory.java
+++ 
b/server/protocols/jmap-draft/src/main/java/org/apache/james/jmap/draft/model/message/view/MessageFastViewFactory.java
@@ -140,6 +140,9 @@ public class MessageFastViewFactory implements 
MessageViewFactory<MessageFastVie
     }
 
     private Mono<List<MessageResult>> fetch(Collection<MessageId> messageIds, 
FetchGroup fetchGroup, MailboxSession mailboxSession) {
+        if (messageIds.isEmpty()) {
+            return Mono.empty();
+        }
         return Mono.fromCallable(() -> 
messageIdManager.getMessages(messageIds, fetchGroup, mailboxSession))
             .onErrorResume(MailboxException.class, ex -> {
                 LOGGER.error("cannot read messages {}", messageIds, ex);


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to