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/04/01 03:32:55 UTC
[james-project] 04/14: [Performance] Avoid empty getMessages(FULL)
when all messages have preview
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 <bt...@linagora.com>
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: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org