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

xuzifu666 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/calcite.git


The following commit(s) were added to refs/heads/main by this push:
     new 3a2c3a10ce [CALCITE-7666] Make regex pattern caches static to avoid 
repeated allocation in RexInterpreter
3a2c3a10ce is described below

commit 3a2c3a10ce2bfb5847a1355b74aa67e014e56ace
Author: Yu Xu <[email protected]>
AuthorDate: Fri Jul 24 16:46:14 2026 +0800

    [CALCITE-7666] Make regex pattern caches static to avoid repeated 
allocation in RexInterpreter
---
 .../java/org/apache/calcite/runtime/SqlFunctions.java  | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java 
b/core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java
index fd4101b5a4..56e6bdb422 100644
--- a/core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java
+++ b/core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java
@@ -2095,7 +2095,7 @@ Pattern toPattern() {
       }
     }
 
-    private final LoadingCache<Key, Pattern> cache =
+    private static final LoadingCache<Key, Pattern> CACHE =
         CacheBuilder.newBuilder()
             .maximumSize(FUNCTION_LEVEL_CACHE_MAX_SIZE.value())
             .build(CacheLoader.from(Key::toPattern));
@@ -2103,32 +2103,32 @@ Pattern toPattern() {
     /** SQL {@code LIKE} function. */
     public boolean like(String s, String pattern) {
       final Key key = new Key(pattern, null, 0);
-      return cache.getUnchecked(key).matcher(s).matches();
+      return CACHE.getUnchecked(key).matcher(s).matches();
     }
 
     /** SQL {@code LIKE} function with escape. */
     public boolean like(String s, String pattern, String escape) {
       final Key key = new Key(pattern, escape, 0);
-      return cache.getUnchecked(key).matcher(s).matches();
+      return CACHE.getUnchecked(key).matcher(s).matches();
     }
 
     /** SQL {@code ILIKE} function. */
     public boolean ilike(String s, String pattern) {
       final Key key = new Key(pattern, null, Pattern.CASE_INSENSITIVE);
-      return cache.getUnchecked(key).matcher(s).matches();
+      return CACHE.getUnchecked(key).matcher(s).matches();
     }
 
     /** SQL {@code ILIKE} function with escape. */
     public boolean ilike(String s, String pattern, String escape) {
       final Key key = new Key(pattern, escape, Pattern.CASE_INSENSITIVE);
-      return cache.getUnchecked(key).matcher(s).matches();
+      return CACHE.getUnchecked(key).matcher(s).matches();
     }
   }
 
   /** State for {@code SIMILAR} function. */
   @Deterministic
   public static class SimilarFunction {
-    private final LoadingCache<String, Pattern> cache =
+    private static final LoadingCache<String, Pattern> CACHE =
         CacheBuilder.newBuilder()
             .maximumSize(FUNCTION_LEVEL_CACHE_MAX_SIZE.value())
             .build(
@@ -2137,7 +2137,7 @@ public static class SimilarFunction {
 
     /** SQL {@code SIMILAR} function. */
     public boolean similar(String s, String pattern) {
-      return cache.getUnchecked(pattern).matcher(s).matches();
+      return CACHE.getUnchecked(pattern).matcher(s).matches();
     }
   }
 
@@ -2154,14 +2154,14 @@ Pattern toPattern() {
       }
     }
 
-    private final LoadingCache<Key, Pattern> cache =
+    private static final LoadingCache<Key, Pattern> CACHE =
         CacheBuilder.newBuilder()
             .maximumSize(FUNCTION_LEVEL_CACHE_MAX_SIZE.value())
             .build(CacheLoader.from(Key::toPattern));
 
     /** SQL {@code SIMILAR} function with escape. */
     public boolean similar(String s, String pattern, String escape) {
-      return cache.getUnchecked(new Key(pattern, escape))
+      return CACHE.getUnchecked(new Key(pattern, escape))
           .matcher(s).matches();
     }
   }

Reply via email to