james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nor...@apache.org
Subject svn commit: r984892 - in /james/imap/trunk: mailbox/src/main/java/org/apache/james/imap/mailbox/ memory/src/main/java/org/apache/james/imap/inmemory/mail/ processor/src/main/java/org/apache/james/imap/processor/
Date Thu, 12 Aug 2010 18:15:36 GMT
Author: norman
Date: Thu Aug 12 18:15:36 2010
New Revision: 984892

URL: http://svn.apache.org/viewvc?rev=984892&view=rev
Log:
AbstractSelectionProcessor.createNewSelectedMailbox(..) use MessageMapper.search(...) now
to allow Mailbox implementation to handle it with optimisted performance (only the uids are
needed anyway) (IMAP-191)

Modified:
    james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/Mailbox.java
    james/imap/trunk/memory/src/main/java/org/apache/james/imap/inmemory/mail/InMemoryMessageMapper.java
    james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/AbstractSelectionProcessor.java

Modified: james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/Mailbox.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/Mailbox.java?rev=984892&r1=984891&r2=984892&view=diff
==============================================================================
--- james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/Mailbox.java (original)
+++ james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/Mailbox.java Thu
Aug 12 18:15:36 2010
@@ -57,7 +57,7 @@ public interface Mailbox {
     boolean isWriteable(MailboxSession session);
 
     /**
-     * Searches for messages matching the given query.
+     * Searches for messages matching the given query. The result must be ordered 
      * @param mailboxSession not null
      * @return uid iterator
      * @throws UnsupportedCriteriaException

Modified: james/imap/trunk/memory/src/main/java/org/apache/james/imap/inmemory/mail/InMemoryMessageMapper.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/memory/src/main/java/org/apache/james/imap/inmemory/mail/InMemoryMessageMapper.java?rev=984892&r1=984891&r2=984892&view=diff
==============================================================================
--- james/imap/trunk/memory/src/main/java/org/apache/james/imap/inmemory/mail/InMemoryMessageMapper.java
(original)
+++ james/imap/trunk/memory/src/main/java/org/apache/james/imap/inmemory/mail/InMemoryMessageMapper.java
Thu Aug 12 18:15:36 2010
@@ -174,7 +174,10 @@ public class InMemoryMessageMapper imple
      * @see org.apache.james.imap.store.mail.MessageMapper#searchMailbox(org.apache.james.imap.store.mail.model.Mailbox,
org.apache.james.imap.mailbox.SearchQuery)
      */
     public Iterator<Long> searchMailbox(Mailbox<Long> mailbox, SearchQuery query)
throws StorageException {
-        return new SearchQueryIterator(new ArrayList<MailboxMembership<?>>(getMembershipByUidForMailbox(mailbox).values()).iterator(),
query);
+        List<MailboxMembership<?>> memberships = new ArrayList<MailboxMembership<?>>(getMembershipByUidForMailbox(mailbox).values());
+        Collections.sort(memberships, MailboxMembershipComparator.INSTANCE);
+
+        return new SearchQueryIterator(memberships.iterator(), query);
     }
 
     /**

Modified: james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/AbstractSelectionProcessor.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/AbstractSelectionProcessor.java?rev=984892&r1=984891&r2=984892&view=diff
==============================================================================
--- james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/AbstractSelectionProcessor.java
(original)
+++ james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/AbstractSelectionProcessor.java
Thu Aug 12 18:15:36 2010
@@ -38,10 +38,8 @@ import org.apache.james.imap.mailbox.Mai
 import org.apache.james.imap.mailbox.MailboxManager;
 import org.apache.james.imap.mailbox.MailboxNotFoundException;
 import org.apache.james.imap.mailbox.MailboxSession;
-import org.apache.james.imap.mailbox.MessageRange;
-import org.apache.james.imap.mailbox.MessageResult;
+import org.apache.james.imap.mailbox.SearchQuery;
 import org.apache.james.imap.mailbox.Mailbox.MetaData;
-import org.apache.james.imap.mailbox.util.FetchGroupImpl;
 import org.apache.james.imap.message.request.AbstractMailboxSelectionRequest;
 import org.apache.james.imap.message.response.ExistsResponse;
 import org.apache.james.imap.message.response.FlagsResponse;
@@ -193,23 +191,14 @@ abstract class AbstractSelectionProcesso
     private SelectedMailbox createNewSelectedMailbox(final Mailbox mailbox,
             final MailboxSession mailboxSession, ImapSession session, MailboxPath path)
             throws MailboxException {
-        final Iterator<MessageResult> it = mailbox.getMessages(MessageRange.all(),
-                FetchGroupImpl.MINIMAL, mailboxSession);
-
-        final SelectedMailbox sessionMailbox = new SelectedMailboxImpl(getMailboxManager(),
new Iterator<Long>() {
+        SearchQuery query = new SearchQuery();
+        query.andCriteria(SearchQuery.all());
+        
+        // use search here to allow implementation a better way to improve selects on mailboxes.

+        // See https://issues.apache.org/jira/browse/IMAP-192
+        final Iterator<Long> it = mailbox.search(query, mailboxSession);
 
-			public boolean hasNext() {
-				return it.hasNext();
-			}
-
-			public Long next() {
-				return it.next().getUid();
-			}
-
-			public void remove() {
-				throw new UnsupportedOperationException("Read-only iterator");
-			}
-		}, mailboxSession, path);
+        final SelectedMailbox sessionMailbox = new SelectedMailboxImpl(getMailboxManager(),
it, mailboxSession, path);
         session.selected(sessionMailbox);
         return sessionMailbox;
     }



---------------------------------------------------------------------
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