|
29 | 29 | import org.apache.fluss.types.LocalZonedTimestampType; |
30 | 30 | import org.apache.fluss.types.RowType; |
31 | 31 | import org.apache.fluss.types.TimestampType; |
32 | | -import org.apache.fluss.utils.MapUtils; |
33 | 32 |
|
34 | 33 | import org.slf4j.Logger; |
35 | 34 | import org.slf4j.LoggerFactory; |
|
51 | 50 | import java.util.LinkedHashSet; |
52 | 51 | import java.util.Map; |
53 | 52 | import java.util.Set; |
54 | | -import java.util.concurrent.ConcurrentHashMap; |
55 | 53 |
|
56 | 54 | /** |
57 | 55 | * Helper class for converting Java objects to Fluss's {@link InternalRow} format and vice versa. |
|
81 | 79 | public class ConverterUtils<T> { |
82 | 80 | private static final Logger LOG = LoggerFactory.getLogger(ConverterUtils.class); |
83 | 81 |
|
84 | | - /** Cache for converters to avoid repeated reflection operations. */ |
85 | | - private static final ConcurrentHashMap<CacheKey, ConverterUtils<?>> CONVERTER_CACHE = |
86 | | - MapUtils.newConcurrentHashMap(); |
87 | | - |
88 | 82 | /** Map of supported Java types for each DataTypeRoot. */ |
89 | 83 | private static final Map<DataTypeRoot, Set<Class<?>>> SUPPORTED_TYPES = new HashMap<>(); |
90 | 84 |
|
@@ -168,9 +162,7 @@ private ConverterUtils(Class<T> pojoClass, RowType rowType) { |
168 | 162 | */ |
169 | 163 | @SuppressWarnings("unchecked") |
170 | 164 | public static <T> ConverterUtils<T> getConverter(Class<T> pojoClass, RowType rowType) { |
171 | | - CacheKey key = new CacheKey(pojoClass, rowType); |
172 | | - return (ConverterUtils<T>) |
173 | | - CONVERTER_CACHE.computeIfAbsent(key, k -> new ConverterUtils<>(pojoClass, rowType)); |
| 165 | + return new ConverterUtils<>(pojoClass, rowType); |
174 | 166 | } |
175 | 167 |
|
176 | 168 | /** Creates field converters for converting from POJO to Row for each field in the schema. */ |
@@ -580,31 +572,4 @@ private static LinkedHashSet<Class<?>> orderedSet(Class<?>... javaTypes) { |
580 | 572 | return linkedHashSet; |
581 | 573 | } |
582 | 574 |
|
583 | | - /** Key for caching converters. */ |
584 | | - private static class CacheKey { |
585 | | - private final Class<?> pojoClass; |
586 | | - private final RowType rowType; |
587 | | - |
588 | | - public CacheKey(Class<?> pojoClass, RowType rowType) { |
589 | | - this.pojoClass = pojoClass; |
590 | | - this.rowType = rowType; |
591 | | - } |
592 | | - |
593 | | - @Override |
594 | | - public boolean equals(Object o) { |
595 | | - if (this == o) { |
596 | | - return true; |
597 | | - } |
598 | | - if (o == null || getClass() != o.getClass()) { |
599 | | - return false; |
600 | | - } |
601 | | - CacheKey cacheKey = (CacheKey) o; |
602 | | - return pojoClass.equals(cacheKey.pojoClass) && rowType.equals(cacheKey.rowType); |
603 | | - } |
604 | | - |
605 | | - @Override |
606 | | - public int hashCode() { |
607 | | - return 31 * pojoClass.hashCode() + rowType.hashCode(); |
608 | | - } |
609 | | - } |
610 | 575 | } |
0 commit comments