Author: joachim
Date: Sun Dec 3 14:08:27 2006
New Revision: 481944
URL: http://svn.apache.org/viewvc?view=rev&rev=481944
Log:
use a join between message_row and message_flags on getMessages()
performance improvement for JAMES-720
Modified:
james/server/trunk/src/java/org/apache/james/mailboxmanager/torque/TorqueMailbox.java
james/server/trunk/src/java/org/apache/james/mailboxmanager/torque/om/MessageFlagsPeer.java
james/server/trunk/src/java/org/apache/james/mailboxmanager/torque/om/MessageRow.java
james/server/trunk/src/test/org/apache/james/imapserver/util/MessageGenerator.java
Modified:
james/server/trunk/src/java/org/apache/james/mailboxmanager/torque/TorqueMailbox.java
URL:
http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/mailboxmanager/torque/TorqueMailbox.java?view=diff&rev=481944&r1=481943&r2=481944
==============================================================================
---
james/server/trunk/src/java/org/apache/james/mailboxmanager/torque/TorqueMailbox.java
(original)
+++
james/server/trunk/src/java/org/apache/james/mailboxmanager/torque/TorqueMailbox.java
Sun Dec 3 14:08:27 2006
@@ -245,11 +245,11 @@
if (!set.isValid() || set.getType()==GeneralMessageSet.TYPE_NOTHING) {
return new MessageResult[0];
}
- Criteria c = criteriaForMessageSet(set);
UidRange range = uidRangeForMessageSet(set);
try {
- List l = getMailboxRow().getMessageRows(c);
-
+ Criteria c = criteriaForMessageSet(set);
+ c.add(MessageFlagsPeer.MAILBOX_ID,getMailboxRow().getMailboxId());
+ List l = MessageFlagsPeer.doSelectJoinMessageRow(c);
MessageResult[] messageResults = fillMessageResult(l, result
| MessageResult.UID | MessageResult.FLAGS);
checkForScanGap(range.getFromUid());
@@ -280,7 +280,15 @@
MessageResult[] messageResults = new MessageResult[messageRows.size()];
int i = 0;
for (Iterator iter = messageRows.iterator(); iter.hasNext();) {
- MessageRow messageRow = (MessageRow) iter.next();
+ MessageRow messageRow;
+ Object next=iter.next();
+ if (next instanceof MessageRow) {
+ messageRow=(MessageRow)next;
+ } else {
+ MessageFlags messageFlags=(MessageFlags)next;
+ messageRow=messageFlags.getMessageRow();
+ messageRow.setMessageFlags(messageFlags);
+ }
messageResults[i] = fillMessageResult(messageRow, result);
i++;
}
Modified:
james/server/trunk/src/java/org/apache/james/mailboxmanager/torque/om/MessageFlagsPeer.java
URL:
http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/mailboxmanager/torque/om/MessageFlagsPeer.java?view=diff&rev=481944&r1=481943&r2=481944
==============================================================================
---
james/server/trunk/src/java/org/apache/james/mailboxmanager/torque/om/MessageFlagsPeer.java
(original)
+++
james/server/trunk/src/java/org/apache/james/mailboxmanager/torque/om/MessageFlagsPeer.java
Sun Dec 3 14:08:27 2006
@@ -1,7 +1,10 @@
package org.apache.james.mailboxmanager.torque.om;
+import java.util.List;
+
import javax.mail.Flags;
+import org.apache.torque.TorqueException;
import org.apache.torque.util.Criteria;
/**
@@ -41,5 +44,9 @@
if (flags.contains(Flags.Flag.SEEN)) {
c.add(SEEN,value);
}
+ }
+
+ public static List doSelectJoinMessageRow(Criteria criteria) throws
TorqueException {
+ return BaseMessageFlagsPeer.doSelectJoinMessageRow(criteria);
}
}
Modified:
james/server/trunk/src/java/org/apache/james/mailboxmanager/torque/om/MessageRow.java
URL:
http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/mailboxmanager/torque/om/MessageRow.java?view=diff&rev=481944&r1=481943&r2=481944
==============================================================================
---
james/server/trunk/src/java/org/apache/james/mailboxmanager/torque/om/MessageRow.java
(original)
+++
james/server/trunk/src/java/org/apache/james/mailboxmanager/torque/om/MessageRow.java
Sun Dec 3 14:08:27 2006
@@ -2,6 +2,7 @@
package org.apache.james.mailboxmanager.torque.om;
+import java.util.ArrayList;
import java.util.List;
import org.apache.torque.TorqueException;
@@ -32,6 +33,11 @@
mf=(MessageFlags)l.get(0);
}
return mf;
+ }
+
+ public void setMessageFlags(MessageFlags messageFlags) {
+ this.collMessageFlagss=new ArrayList();
+ collMessageFlagss.add(messageFlags);
}
}
Modified:
james/server/trunk/src/test/org/apache/james/imapserver/util/MessageGenerator.java
URL:
http://svn.apache.org/viewvc/james/server/trunk/src/test/org/apache/james/imapserver/util/MessageGenerator.java?view=diff&rev=481944&r1=481943&r2=481944
==============================================================================
---
james/server/trunk/src/test/org/apache/james/imapserver/util/MessageGenerator.java
(original)
+++
james/server/trunk/src/test/org/apache/james/imapserver/util/MessageGenerator.java
Sun Dec 3 14:08:27 2006
@@ -1,3 +1,22 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one *
+ * or more contributor license agreements. See the NOTICE file *
+ * distributed with this work for additional information *
+ * regarding copyright ownership. The ASF licenses this file *
+ * to you under the Apache License, Version 2.0 (the *
+ * "License"); you may not use this file except in compliance *
+ * with the License. You may obtain a copy of the License at *
+ * *
+ * http://www.apache.org/licenses/LICENSE-2.0 *
+ * *
+ * Unless required by applicable law or agreed to in writing, *
+ * software distributed under the License is distributed on an *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
+ * KIND, either express or implied. See the License for the *
+ * specific language governing permissions and limitations *
+ * under the License. *
+ ****************************************************************/
+
package org.apache.james.imapserver.util;
import java.io.ByteArrayOutputStream;
@@ -54,12 +73,34 @@
return os.toString();
}
- public static MimeMessage[] generateSimpleMessages(int c) throws
MessagingException
- {
+ public static MimeMessage[] generateSimpleMessages(int c)
+ throws MessagingException {
MimeMessage[] msgs=new MimeMessage[c];
for (int i=0; i<c; i++) {
msgs[i]=generateSimpleMessage();
}
return msgs;
+ }
+
+ public static MimeMessage generateMessage(int size) throws
MessagingException {
+ MimeMessage mm = new MimeMessage((Session) null);
+ int r = getRandom().nextInt() % 100000;
+ int r2 = getRandom().nextInt() % 100000;
+ mm.setSubject("good news" + r);
+ mm.setFrom(new InternetAddress("user" + r + "@localhost"));
+ mm.setSentDate(new Date());
+ mm.setRecipients(Message.RecipientType.TO,
+ new InternetAddress[] { new InternetAddress("user" + r2
+ + "@localhost") });
+ char[] textChars=new char[size];
+ for (int i = 0; i < textChars.length; i++) {
+ if (i%80 == 0) {
+ textChars[i]='\n';
+ } else {
+ textChars[i]=(char)(65+getRandom().nextInt(26));
+ }
+ }
+ mm.setText(new String(textChars));
+ return mm;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]