hungphan227 commented on code in PR #2667:
URL: https://github.com/apache/james-project/pull/2667#discussion_r1984273779


##########
examples/message-fast-view-cleanup-extension/src/main/java/org/apache/james/messagefastview/cleanup/MessageFastViewCleanupService.java:
##########
@@ -0,0 +1,60 @@
+/****************************************************************
+ * 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.messagefastview.cleanup;
+
+import jakarta.inject.Inject;
+
+import org.apache.james.jmap.api.projections.MessageFastViewProjection;
+import org.apache.james.mailbox.model.MessageId;
+import org.apache.james.mailbox.store.mail.MessageService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import reactor.core.publisher.Flux;
+import reactor.core.publisher.Mono;
+
+public class MessageFastViewCleanupService {
+    private static final Logger LOGGER = 
LoggerFactory.getLogger(MessageFastViewCleanupService.class);
+    private static final int DEFAULT_MESSAGE_IDS_PER_SECOND = 1000;
+
+    private final MessageFastViewProjection messageFastViewProjection;
+    private final MessageService messageService;
+
+    @Inject
+    public MessageFastViewCleanupService(MessageFastViewProjection 
messageFastViewProjection, MessageService messageService) {
+        this.messageFastViewProjection = messageFastViewProjection;
+        this.messageService = messageService;
+    }
+
+    public Mono<Void> cleanup() {
+        return Flux.from(messageFastViewProjection.getAllMessageIds())
+            .flatMap(messageId -> exist(messageId)

Review Comment:
   > If I run this in prod I trigger 20.000.000 primary key reads at an 
unsustainable pace that will bring my Cassandra infrastructure to its knees.
   
   Cassandra drive has the default page size of pagination. Added setting page 
size to make sure.
   
   > Can't we think of an approach revolving around the use of bloom filters in 
order to do 2 sequential table scans and mitigate the resource cost of the 
operation?
   
   Previously I thought that using bloom filter could let some redundant 
message ids through. Sorry I forgot that we do not expect all redundant message 
ids removed. Updated



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org
For additional commands, e-mail: notifications-h...@james.apache.org

Reply via email to