This is an automated email from the ASF dual-hosted git repository.

fanningpj pushed a commit to branch main
in repository 
https://gitbox.apache.org/repos/asf/incubator-pekko-persistence-cassandra.git


The following commit(s) were added to refs/heads/main by this push:
     new 90d80ad  replace deprecated statefulMapConcat (#133)
90d80ad is described below

commit 90d80ad20dd72b9eff09ab1998e3354f78227313
Author: PJ Fanning <[email protected]>
AuthorDate: Sat Feb 24 17:03:47 2024 +0100

    replace deprecated statefulMapConcat (#133)
    
    * replace deprecated statefulMapConcat
    
    * Update AllTags.scala
    
    * Update AllTags.scala
    
    * another impl
    
    * use mutable Set for `seen` to avoid allocating extra Set instances when 
adding
    
    * scala 2.12 compile issue
    
    * refactor
    
    * Update 
core/src/main/scala/org/apache/pekko/persistence/cassandra/reconciler/AllTags.scala
    
    Co-authored-by: AndyChen(Jingzhang) <[email protected]>
    
    ---------
    
    Co-authored-by: AndyChen(Jingzhang) <[email protected]>
---
 .../persistence/cassandra/reconciler/AllTags.scala    | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git 
a/core/src/main/scala/org/apache/pekko/persistence/cassandra/reconciler/AllTags.scala
 
b/core/src/main/scala/org/apache/pekko/persistence/cassandra/reconciler/AllTags.scala
index a7745d5..c60fb62 100644
--- 
a/core/src/main/scala/org/apache/pekko/persistence/cassandra/reconciler/AllTags.scala
+++ 
b/core/src/main/scala/org/apache/pekko/persistence/cassandra/reconciler/AllTags.scala
@@ -18,6 +18,8 @@ import pekko.annotation.InternalApi
 import pekko.stream.scaladsl.Source
 import pekko.NotUsed
 
+import scala.collection.mutable
+
 /**
  * Calculates all the tags by scanning the tag_write_progress table.
  *
@@ -36,16 +38,15 @@ private[pekko] final class AllTags(session: 
ReconciliationSession) {
     session
       .selectAllTagProgress()
       .map(_.getString("tag"))
-      .statefulMapConcat(() => {
-        var seen = Set.empty[String]
-        tag =>
-          if (!seen.contains(tag)) {
-            seen += tag
-            List(tag)
+      .statefulMap(() => mutable.Set.empty[String])(
+        (seen, tag) =>
+          if (seen.contains(tag)) {
+            (seen, None)
           } else {
-            Nil
-          }
-      })
+            (seen += tag, Some(tag))
+          },
+        _ => None)
+      .collect { case Some(tag) => tag }
   }
 
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to