Github user mgaido91 commented on a diff in the pull request:
https://github.com/apache/nifi/pull/2343#discussion_r157242761
--- Diff:
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/RouteText.java
---
@@ -209,6 +215,30 @@
private volatile Map<Relationship, PropertyValue> propertyMap = new
HashMap<>();
private volatile Pattern groupingRegex = null;
+ @VisibleForTesting
+ final static int PATTERNS_CACHE_MAXIMUM_ENTRIES = 10;
+
+ /**
+ * LRU cache for the compiled patterns. The size of the cache is
determined by the value of
+ * {@link #PATTERNS_CACHE_MAXIMUM_ENTRIES}.
+ */
+ @VisibleForTesting
+ final ConcurrentMap<Pair<Boolean, String>, Pattern> patternsCache =
CacheBuilder.newBuilder()
+ .maximumSize(PATTERNS_CACHE_MAXIMUM_ENTRIES)
+ .<Pair<Boolean, String>, Pattern>build()
+ .asMap();
+
+ private final Function<Pair<Boolean, String>, Pattern> compileRegex =
ignoreCaseAndRegex -> {
--- End diff --
for the `Pair`, I'll get rid of it following your suggestion above.
For the `Function`, my goal in defining the function as a parameter was to
avoid the creation of a new `Function` object at every invocation, using always
the same. What do you think?
---