From 50208d5da35bdbff1e230e85d04d44aa66ebd585 Mon Sep 17 00:00:00 2001 From: duanzhengqiang Date: Mon, 19 Aug 2024 18:42:02 +0800 Subject: [PATCH 1/3] Use CaseInsensitiveMap to replace toLowerCase method call --- .../schema/model/ShardingSphereTable.java | 33 +++++++++---------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/model/ShardingSphereTable.java b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/model/ShardingSphereTable.java index a7e37fdac8625..bd5eb1db5a569 100644 --- a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/model/ShardingSphereTable.java +++ b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/model/ShardingSphereTable.java @@ -17,6 +17,7 @@ package org.apache.shardingsphere.infra.metadata.database.schema.model; +import com.cedarsoftware.util.CaseInsensitiveMap; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.ToString; @@ -25,7 +26,6 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Collections; -import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -63,7 +63,7 @@ public ShardingSphereTable(final String name, final Collection columns, @@ -76,13 +76,12 @@ public ShardingSphereTable(final String name, final Collection createColumns(final Collection columns) { - Map result = new LinkedHashMap<>(columns.size(), 1F); + Map result = new CaseInsensitiveMap<>(columns.size(), 1F); for (ShardingSphereColumn each : columns) { - String lowerColumnName = each.getName().toLowerCase(); - result.put(lowerColumnName, each); + result.put(each.getName(), each); columnNames.add(each.getName()); if (each.isPrimaryKey()) { - primaryKeyColumns.add(lowerColumnName); + primaryKeyColumns.add(each.getName()); } if (each.isVisible()) { visibleColumns.add(each.getName()); @@ -92,17 +91,17 @@ private Map createColumns(final Collection createIndexes(final Collection indexes) { - Map result = new LinkedHashMap<>(indexes.size(), 1F); + Map result = new CaseInsensitiveMap<>(indexes.size(), 1F); for (ShardingSphereIndex each : indexes) { - result.put(each.getName().toLowerCase(), each); + result.put(each.getName(), each); } return result; } private Map createConstraints(final Collection constraints) { - Map result = new LinkedHashMap<>(constraints.size(), 1F); + Map result = new CaseInsensitiveMap<>(constraints.size(), 1F); for (ShardingSphereConstraint each : constraints) { - result.put(each.getName().toLowerCase(), each); + result.put(each.getName(), each); } return result; } @@ -113,7 +112,7 @@ private Map createConstraints(final Collection * @param column column meta data */ public void putColumn(final ShardingSphereColumn column) { - columns.put(column.getName().toLowerCase(), column); + columns.put(column.getName(), column); } /** @@ -123,7 +122,7 @@ public void putColumn(final ShardingSphereColumn column) { * @return column meta data */ public ShardingSphereColumn getColumn(final String columnName) { - return columns.get(columnName.toLowerCase()); + return columns.get(columnName); } /** @@ -142,7 +141,7 @@ public Collection getColumnValues() { * @return whether contains column or not */ public boolean containsColumn(final String columnName) { - return null != columnName && columns.containsKey(columnName.toLowerCase()); + return null != columnName && columns.containsKey(columnName); } /** @@ -151,7 +150,7 @@ public boolean containsColumn(final String columnName) { * @param index index meta data */ public void putIndex(final ShardingSphereIndex index) { - indexes.put(index.getName().toLowerCase(), index); + indexes.put(index.getName(), index); } /** @@ -160,7 +159,7 @@ public void putIndex(final ShardingSphereIndex index) { * @param indexName index name */ public void removeIndex(final String indexName) { - indexes.remove(indexName.toLowerCase()); + indexes.remove(indexName); } /** @@ -170,7 +169,7 @@ public void removeIndex(final String indexName) { * @return index meta data */ public ShardingSphereIndex getIndex(final String indexName) { - return indexes.get(indexName.toLowerCase()); + return indexes.get(indexName); } /** @@ -189,7 +188,7 @@ public Collection getIndexValues() { * @return whether contains index or not */ public boolean containsIndex(final String indexName) { - return null != indexName && indexes.containsKey(indexName.toLowerCase()); + return null != indexName && indexes.containsKey(indexName); } /** From 21c7bc23bdb1a3bde46b386ec97700ec1c75174a Mon Sep 17 00:00:00 2001 From: duanzhengqiang Date: Thu, 22 Aug 2024 17:53:15 +0800 Subject: [PATCH 2/3] Add more graalvm reachability metadata for caffeine cache --- .../caffeine/2.9.3/reflect-config.json | 98 +++++++++++++++++++ 1 file changed, 98 insertions(+) diff --git a/infra/reachability-metadata/src/main/resources/META-INF/native-image/com.github.ben-manes.caffeine/caffeine/2.9.3/reflect-config.json b/infra/reachability-metadata/src/main/resources/META-INF/native-image/com.github.ben-manes.caffeine/caffeine/2.9.3/reflect-config.json index 02b524be99c55..547f4142890a5 100644 --- a/infra/reachability-metadata/src/main/resources/META-INF/native-image/com.github.ben-manes.caffeine/caffeine/2.9.3/reflect-config.json +++ b/infra/reachability-metadata/src/main/resources/META-INF/native-image/com.github.ben-manes.caffeine/caffeine/2.9.3/reflect-config.json @@ -18,5 +18,103 @@ "condition":{"typeReachable":"com.github.benmanes.caffeine.cache.NodeFactory"}, "name":"com.github.benmanes.caffeine.cache.PDMS", "methods":[{"name":"","parameterTypes":[] }] +}, +{ +"condition":{"typeReachable":"com.github.benmanes.caffeine.cache.BBHeader$ReadAndWriteCounterRef"}, +"name":"com.github.benmanes.caffeine.cache.BBHeader$ReadAndWriteCounterRef", +"fields":[{"name":"writeCounter"}] +}, +{ + "condition":{"typeReachable":"com.github.benmanes.caffeine.cache.BBHeader$ReadCounterRef"}, + "name":"com.github.benmanes.caffeine.cache.BBHeader$ReadCounterRef", + "fields":[{"name":"readCounter"}] +}, +{ + "condition":{"typeReachable":"com.github.benmanes.caffeine.cache.BLCHeader$DrainStatusRef"}, + "name":"com.github.benmanes.caffeine.cache.BLCHeader$DrainStatusRef", + "fields":[{"name":"drainStatus"}] +}, +{ + "condition":{"typeReachable":"com.github.benmanes.caffeine.cache.BaseMpscLinkedArrayQueue"}, + "name":"com.github.benmanes.caffeine.cache.BaseMpscLinkedArrayQueueColdProducerFields", + "fields":[{"name":"producerLimit"}] +}, +{ + "condition":{"typeReachable":"com.github.benmanes.caffeine.cache.BaseMpscLinkedArrayQueue"}, + "name":"com.github.benmanes.caffeine.cache.BaseMpscLinkedArrayQueueConsumerFields", + "fields":[{"name":"consumerIndex"}] +}, +{ + "condition":{"typeReachable":"com.github.benmanes.caffeine.cache.BaseMpscLinkedArrayQueue"}, + "name":"com.github.benmanes.caffeine.cache.BaseMpscLinkedArrayQueueProducerFields", + "fields":[{"name":"producerIndex"}] +}, +{ + "condition":{"typeReachable":"com.github.benmanes.caffeine.cache.LocalLoadingCache"}, + "name":"com.github.benmanes.caffeine.cache.CacheLoader", + "methods":[{"name":"loadAll","parameterTypes":["java.lang.Iterable"] }] +}, +{ + "condition":{"typeReachable":"com.github.benmanes.caffeine.cache.PD"}, + "name":"com.github.benmanes.caffeine.cache.PD", + "fields":[{"name":"value"}] +}, +{ + "condition":{"typeReachable":"com.github.benmanes.caffeine.cache.PS"}, + "name":"com.github.benmanes.caffeine.cache.PS", + "fields":[{"name":"key"}, {"name":"value"}] +}, +{ + "condition":{"typeReachable":"com.github.benmanes.caffeine.cache.PSA"}, + "name":"com.github.benmanes.caffeine.cache.PSA", + "fields":[{"name":"accessTime"}] +}, +{ + "condition":{"typeReachable":"com.github.benmanes.caffeine.cache.SSMSA"}, + "name":"com.github.benmanes.caffeine.cache.PSAMS", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "condition":{"typeReachable":"com.github.benmanes.caffeine.cache.PSW"}, + "name":"com.github.benmanes.caffeine.cache.PSW", + "fields":[{"name":"writeTime"}] +}, +{ + "condition":{"typeReachable":"com.github.benmanes.caffeine.cache.SSMSW"}, + "name":"com.github.benmanes.caffeine.cache.PSWMS", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "condition":{"typeReachable":"com.github.benmanes.caffeine.cache.BoundedLocalCache$BoundedLocalManualCache"}, + "name":"com.github.benmanes.caffeine.cache.SSMSA", + "methods":[{"name":"","parameterTypes":["com.github.benmanes.caffeine.cache.Caffeine","com.github.benmanes.caffeine.cache.CacheLoader","boolean"] }] +}, +{ + "condition":{"typeReachable":"com.github.benmanes.caffeine.cache.BoundedLocalCache$BoundedLocalManualCache"}, + "name":"com.github.benmanes.caffeine.cache.SSMSW", + "methods":[{"name":"","parameterTypes":["com.github.benmanes.caffeine.cache.Caffeine","com.github.benmanes.caffeine.cache.CacheLoader","boolean"] }] +}, +{ + "condition":{"typeReachable":"com.github.benmanes.caffeine.cache.StripedBuffer"}, + "name":"com.github.benmanes.caffeine.cache.StripedBuffer", + "fields":[{"name":"tableBusy"}] +}, +{ + "condition":{"typeReachable":"com.github.benmanes.caffeine.cache.StripedBuffer"}, + "name":"java.lang.Thread", + "fields":[{"name":"threadLocalRandomProbe"}] +}, +{ + "condition":{"typeReachable":"com.github.benmanes.caffeine.cache.LocalLoadingCache"}, + "name":"org.apache.shardingsphere.infra.parser.cache.SQLStatementCacheLoader" +}, +{ + "condition":{"typeReachable":"com.github.benmanes.caffeine.cache.LocalLoadingCache"}, + "name":"org.apache.shardingsphere.sql.parser.core.database.cache.ParseTreeCacheLoader" +}, +{ + "condition":{"typeReachable":"com.github.benmanes.caffeine.cache.UnsafeAccess"}, + "name":"sun.misc.Unsafe", + "fields":[{"name":"theUnsafe"}] } ] From 6de23853ccb9855df09b66c1e1d39d338271a9e6 Mon Sep 17 00:00:00 2001 From: duanzhengqiang Date: Thu, 22 Aug 2024 18:00:52 +0800 Subject: [PATCH 3/3] update reflect-config.json --- .../caffeine/2.9.3/reflect-config.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/infra/reachability-metadata/src/main/resources/META-INF/native-image/com.github.ben-manes.caffeine/caffeine/2.9.3/reflect-config.json b/infra/reachability-metadata/src/main/resources/META-INF/native-image/com.github.ben-manes.caffeine/caffeine/2.9.3/reflect-config.json index 547f4142890a5..a1ddeefde563b 100644 --- a/infra/reachability-metadata/src/main/resources/META-INF/native-image/com.github.ben-manes.caffeine/caffeine/2.9.3/reflect-config.json +++ b/infra/reachability-metadata/src/main/resources/META-INF/native-image/com.github.ben-manes.caffeine/caffeine/2.9.3/reflect-config.json @@ -20,9 +20,9 @@ "methods":[{"name":"","parameterTypes":[] }] }, { -"condition":{"typeReachable":"com.github.benmanes.caffeine.cache.BBHeader$ReadAndWriteCounterRef"}, -"name":"com.github.benmanes.caffeine.cache.BBHeader$ReadAndWriteCounterRef", -"fields":[{"name":"writeCounter"}] + "condition":{"typeReachable":"com.github.benmanes.caffeine.cache.BBHeader$ReadAndWriteCounterRef"}, + "name":"com.github.benmanes.caffeine.cache.BBHeader$ReadAndWriteCounterRef", + "fields":[{"name":"writeCounter"}] }, { "condition":{"typeReachable":"com.github.benmanes.caffeine.cache.BBHeader$ReadCounterRef"},