Skip to content

Commit b8347ee

Browse files
committed
update packaging to org.apach and remove converter
1 parent 614766a commit b8347ee

File tree

2 files changed

+33
-67
lines changed

2 files changed

+33
-67
lines changed

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

Lines changed: 16 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,20 @@
1515
* limitations under the License.
1616
*/
1717

18-
package com.alibaba.fluss.client.utils;
19-
20-
import com.alibaba.fluss.row.BinaryString;
21-
import com.alibaba.fluss.row.Decimal;
22-
import com.alibaba.fluss.row.GenericRow;
23-
import com.alibaba.fluss.row.InternalRow;
24-
import com.alibaba.fluss.row.TimestampLtz;
25-
import com.alibaba.fluss.row.TimestampNtz;
26-
import com.alibaba.fluss.types.DataType;
27-
import com.alibaba.fluss.types.DataTypeRoot;
28-
import com.alibaba.fluss.types.DecimalType;
29-
import com.alibaba.fluss.types.LocalZonedTimestampType;
30-
import com.alibaba.fluss.types.RowType;
31-
import com.alibaba.fluss.types.TimestampType;
32-
import com.alibaba.fluss.utils.MapUtils;
18+
package org.apache.fluss.client.utils;
19+
20+
import org.apache.fluss.row.BinaryString;
21+
import org.apache.fluss.row.Decimal;
22+
import org.apache.fluss.row.GenericRow;
23+
import org.apache.fluss.row.InternalRow;
24+
import org.apache.fluss.row.TimestampLtz;
25+
import org.apache.fluss.row.TimestampNtz;
26+
import org.apache.fluss.types.DataType;
27+
import org.apache.fluss.types.DataTypeRoot;
28+
import org.apache.fluss.types.DecimalType;
29+
import org.apache.fluss.types.LocalZonedTimestampType;
30+
import org.apache.fluss.types.RowType;
31+
import org.apache.fluss.types.TimestampType;
3332

3433
import org.slf4j.Logger;
3534
import org.slf4j.LoggerFactory;
@@ -51,13 +50,12 @@
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.
5856
*
5957
* <p>This utility uses reflection to map fields from POJOs to InternalRow and back based on a given
60-
* schema. It includes caching mechanisms to avoid repeated reflection operations for the same POJO
58+
* schema. This implementation does not cache converters; getConverter creates a new instance each time.
6159
* types.
6260
*
6361
* <p>Example usage:
@@ -81,9 +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();
8782

8883
/** Map of supported Java types for each DataTypeRoot. */
8984
private static final Map<DataTypeRoot, Set<Class<?>>> SUPPORTED_TYPES = new HashMap<>();
@@ -168,9 +163,7 @@ private ConverterUtils(Class<T> pojoClass, RowType rowType) {
168163
*/
169164
@SuppressWarnings("unchecked")
170165
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));
166+
return new ConverterUtils<>(pojoClass, rowType);
174167
}
175168

176169
/** Creates field converters for converting from POJO to Row for each field in the schema. */
@@ -580,31 +573,4 @@ private static LinkedHashSet<Class<?>> orderedSet(Class<?>... javaTypes) {
580573
return linkedHashSet;
581574
}
582575

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

fluss-client/src/test/java/com/alibaba/fluss/client/utils/ConverterUtilsTest.java renamed to fluss-client/src/test/java/org/apache/fluss/client/utils/ConverterUtilsTest.java

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,21 @@
1515
* limitations under the License.
1616
*/
1717

18-
package com.alibaba.fluss.client.utils;
19-
20-
import com.alibaba.fluss.client.admin.ClientToServerITCaseBase;
21-
import com.alibaba.fluss.client.table.Table;
22-
import com.alibaba.fluss.client.table.scanner.ScanRecord;
23-
import com.alibaba.fluss.client.table.scanner.log.LogScanner;
24-
import com.alibaba.fluss.client.table.scanner.log.ScanRecords;
25-
import com.alibaba.fluss.client.table.writer.AppendWriter;
26-
import com.alibaba.fluss.metadata.Schema;
27-
import com.alibaba.fluss.metadata.TableDescriptor;
28-
import com.alibaba.fluss.metadata.TablePath;
29-
import com.alibaba.fluss.row.GenericRow;
30-
import com.alibaba.fluss.row.InternalRow;
31-
import com.alibaba.fluss.types.DataTypes;
32-
import com.alibaba.fluss.types.RowType;
33-
18+
package org.apache.fluss.client.utils;
19+
20+
import org.apache.fluss.client.admin.ClientToServerITCaseBase;
21+
import org.apache.fluss.client.table.Table;
22+
import org.apache.fluss.client.table.scanner.ScanRecord;
23+
import org.apache.fluss.client.table.scanner.log.LogScanner;
24+
import org.apache.fluss.client.table.scanner.log.ScanRecords;
25+
import org.apache.fluss.client.table.writer.AppendWriter;
26+
import org.apache.fluss.metadata.Schema;
27+
import org.apache.fluss.metadata.TableDescriptor;
28+
import org.apache.fluss.metadata.TablePath;
29+
import org.apache.fluss.row.GenericRow;
30+
import org.apache.fluss.row.InternalRow;
31+
import org.apache.fluss.types.DataTypes;
32+
import org.apache.fluss.types.RowType;
3433
import org.junit.jupiter.api.Test;
3534

3635
import java.math.BigDecimal;
@@ -177,7 +176,8 @@ public void testCaching() {
177176
ConverterUtils<TestPojo> converter2 =
178177
ConverterUtils.getConverter(TestPojo.class, createTestPojoRowType());
179178

180-
assertThat(converter2).isSameAs(converter1);
179+
// As caching is removed, subsequent calls should produce new instances
180+
assertThat(converter2).isNotSameAs(converter1);
181181
}
182182

183183
@Test

0 commit comments

Comments
 (0)