james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject svn commit: r1689019 - in /james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra: CassandraTableManager.java mail/CassandraMessageMapper.java
Date Fri, 03 Jul 2015 14:36:08 GMT
Author: btellier
Date: Fri Jul  3 14:36:07 2015
New Revision: 1689019

URL: http://svn.apache.org/r1689019
Log:
MAILBOX-208 Avoid to fetch all mailbox messages upon RECENT related operations using a Cassandra
index

Modified:
    james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraTableManager.java
    james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageMapper.java

Modified: james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraTableManager.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraTableManager.java?rev=1689019&r1=1689018&r2=1689019&view=diff
==============================================================================
--- james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraTableManager.java
(original)
+++ james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraTableManager.java
Fri Jul  3 14:36:07 2015
@@ -129,12 +129,15 @@ public class CassandraTableManager {
             SchemaBuilder.createIndex(INDEX_PREFIX + CassandraMailboxTable.MAILBOX_BASE)
                 .ifNotExists()
                 .onTable(CassandraMailboxTable.TABLE_NAME)
-                .andColumn(CassandraMailboxTable.MAILBOX_BASE)
-        ),
+                .andColumn(CassandraMailboxTable.MAILBOX_BASE)),
         UserSubscription(SchemaBuilder.createIndex(INDEX_PREFIX + CassandraSubscriptionTable.USER)
             .ifNotExists()
             .onTable(CassandraSubscriptionTable.TABLE_NAME)
-            .andColumn(CassandraSubscriptionTable.USER))
+            .andColumn(CassandraSubscriptionTable.USER)),
+        RecentMessages(SchemaBuilder.createIndex(INDEX_PREFIX + CassandraMessageTable.Flag.RECENT)
+            .ifNotExists()
+            .onTable(CassandraMessageTable.TABLE_NAME)
+            .andColumn(CassandraMessageTable.Flag.RECENT))
         ;
         private SchemaStatement createIndexStatement;
 

Modified: james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageMapper.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageMapper.java?rev=1689019&r1=1689018&r2=1689019&view=diff
==============================================================================
--- james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageMapper.java
(original)
+++ james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageMapper.java
Fri Jul  3 14:36:07 2015
@@ -294,14 +294,10 @@ public class CassandraMessageMapper impl
 
     @Override
     public List<Long> findRecentMessageUidsInMailbox(Mailbox<CassandraId> mailbox)
throws MailboxException {
-        ImmutableList.Builder<Long> result = ImmutableList.<Long> builder();
-        ResultSet rows = session.execute(selectAll(mailbox).orderBy(asc(IMAP_UID)));
-        for (Row row : rows) {
-            if (row.getBool(RECENT)) {
-                result.add(row.getLong(IMAP_UID));
-            }
-        }
-        return result.build();
+        return convertToStream(session.execute(selectAll(mailbox).and((eq(RECENT, true)))))
+            .map((row) -> row.getLong(IMAP_UID))
+            .sorted()
+            .collect(Collectors.toList());
     }
 
     @Override



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