Skip to content

Commit 12a894e

Browse files
committed
remove converter
1 parent def23c8 commit 12a894e

File tree

2 files changed

+2
-37
lines changed

2 files changed

+2
-37
lines changed

fluss-client/src/main/java/org/apache/fluss/client/utils/ConverterUtils.java

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import org.apache.fluss.types.LocalZonedTimestampType;
3030
import org.apache.fluss.types.RowType;
3131
import org.apache.fluss.types.TimestampType;
32-
import org.apache.fluss.utils.MapUtils;
3332

3433
import org.slf4j.Logger;
3534
import org.slf4j.LoggerFactory;
@@ -51,7 +50,6 @@
5150
import java.util.LinkedHashSet;
5251
import java.util.Map;
5352
import java.util.Set;
54-
import java.util.concurrent.ConcurrentHashMap;
5553

5654
/**
5755
* Helper class for converting Java objects to Fluss's {@link InternalRow} format and vice versa.
@@ -81,10 +79,6 @@
8179
public class ConverterUtils<T> {
8280
private static final Logger LOG = LoggerFactory.getLogger(ConverterUtils.class);
8381

84-
/** Cache for converters to avoid repeated reflection operations. */
85-
private static final ConcurrentHashMap<CacheKey, ConverterUtils<?>> CONVERTER_CACHE =
86-
MapUtils.newConcurrentHashMap();
87-
8882
/** Map of supported Java types for each DataTypeRoot. */
8983
private static final Map<DataTypeRoot, Set<Class<?>>> SUPPORTED_TYPES = new HashMap<>();
9084

@@ -168,9 +162,7 @@ private ConverterUtils(Class<T> pojoClass, RowType rowType) {
168162
*/
169163
@SuppressWarnings("unchecked")
170164
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);
174166
}
175167

176168
/** 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) {
580572
return linkedHashSet;
581573
}
582574

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-
}
610575
}

fluss-client/src/test/java/org/apache/fluss/client/utils/ConverterUtilsTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ public void testCaching() {
176176
ConverterUtils<TestPojo> converter2 =
177177
ConverterUtils.getConverter(TestPojo.class, createTestPojoRowType());
178178

179-
assertThat(converter2).isSameAs(converter1);
179+
assertThat(converter2).isNotSameAs(converter1);
180180
}
181181

182182
@Test

0 commit comments

Comments
 (0)