NSAmelchev commented on code in PR #286:
URL: https://github.com/apache/ignite-extensions/pull/286#discussion_r1796898726


##########
modules/cdc-ext/src/main/java/org/apache/ignite/cdc/kafka/KafkaToIgniteCdcStreamerApplier.java:
##########
@@ -260,7 +278,44 @@ private boolean 
filterAndPossiblyUpdateMetadata(ConsumerRecord<Integer, byte[]>
 
         metrics.incrementReceivedEvents();
 
-        return F.isEmpty(caches) || caches.contains(rec.key());
+        return F.isEmpty(caches) || caches.contains(rec.key()) || 
matchesRegexTemplates(rec.key());
+    }
+
+    /**
+     * Gets caches names from CDC client and finds match
+     * between cache id and user's regex templates.
+     *
+     * @param key Cache id.
+     * @return True if match is found.
+     */
+    private boolean matchesRegexTemplates(Integer key) {
+        Optional<String> cache = streamer.getCaches().stream()
+            .filter(name -> CU.cacheId(name) == key)
+            .findAny();
+
+        Optional<String> matchedCache = cache.filter(this::matchesFilters);
+
+        matchedCache.ifPresent(c -> caches.add(CU.cacheId(c)));

Review Comment:
   The javadoc of the `Collectors.toSet()` says that `There are no guarantees 
on the type, mutability, serializability, or thread-safety of the Set returned`
   
   So, we should not modify it and mutable collection should be used instaed.



-- 
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...@ignite.apache.org

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

Reply via email to