You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by "NSAmelchev (via GitHub)" <gi...@apache.org> on 2024/09/19 07:08:06 UTC
Re: [PR] IGNITE-22530 CDC: Add regex filters for cache names [ignite-extensions]
NSAmelchev commented on code in PR #286:
URL: https://github.com/apache/ignite-extensions/pull/286#discussion_r1766278455
##########
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:
`caches` can be immutable.
--
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-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org