james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject svn commit: r1689020 - 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:34 GMT
Author: btellier
Date: Fri Jul  3 14:36:33 2015
New Revision: 1689020

URL: http://svn.apache.org/r1689020
Log:
MAILBOX-208 Avoid to fetch all mailbox messages upon UNSEEN 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=1689020&r1=1689019&r2=1689020&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:33 2015
@@ -137,7 +137,11 @@ public class CassandraTableManager {
         RecentMessages(SchemaBuilder.createIndex(INDEX_PREFIX + CassandraMessageTable.Flag.RECENT)
             .ifNotExists()
             .onTable(CassandraMessageTable.TABLE_NAME)
-            .andColumn(CassandraMessageTable.Flag.RECENT))
+            .andColumn(CassandraMessageTable.Flag.RECENT)),
+        SeenMessages(SchemaBuilder.createIndex(INDEX_PREFIX + CassandraMessageTable.Flag.SEEN)
+            .ifNotExists()
+            .onTable(CassandraMessageTable.TABLE_NAME)
+            .andColumn(CassandraMessageTable.Flag.SEEN))
         ;
         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=1689020&r1=1689019&r2=1689020&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:33 2015
@@ -302,13 +302,11 @@ public class CassandraMessageMapper impl
 
     @Override
     public Long findFirstUnseenMessageUid(Mailbox<CassandraId> mailbox) throws MailboxException
{
-        ResultSet rows = session.execute(selectAll(mailbox).orderBy(asc(IMAP_UID)));
-        for (Row row : rows) {
-            if (!row.getBool(SEEN)) {
-                return row.getLong(IMAP_UID);
-            }
-        }
-        return null;
+        return convertToStream(session.execute(selectAll(mailbox).and((eq(SEEN, false)))))
+            .map((row) -> row.getLong(IMAP_UID))
+            .sorted()
+            .findFirst()
+            .orElse(null);
     }
 
     @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