Skip to content

Commit 4bda0db

Browse files
committed
remove orderedset
1 parent a3e327d commit 4bda0db

File tree

2 files changed

+26
-32
lines changed

2 files changed

+26
-32
lines changed

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

Lines changed: 21 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
import java.time.ZoneOffset;
4848
import java.util.Arrays;
4949
import java.util.HashMap;
50-
import java.util.LinkedHashSet;
50+
import java.util.HashSet;
5151
import java.util.Map;
5252
import java.util.Set;
5353

@@ -83,27 +83,24 @@ public class PojoConverterUtils<T> {
8383
private static final Map<DataTypeRoot, Set<Class<?>>> SUPPORTED_TYPES = new HashMap<>();
8484

8585
static {
86-
SUPPORTED_TYPES.put(DataTypeRoot.BOOLEAN, orderedSet(Boolean.class, boolean.class));
87-
SUPPORTED_TYPES.put(DataTypeRoot.TINYINT, orderedSet(Byte.class, byte.class));
88-
SUPPORTED_TYPES.put(DataTypeRoot.SMALLINT, orderedSet(Short.class, short.class));
89-
SUPPORTED_TYPES.put(DataTypeRoot.INTEGER, orderedSet(Integer.class, int.class));
90-
SUPPORTED_TYPES.put(DataTypeRoot.BIGINT, orderedSet(Long.class, long.class));
91-
SUPPORTED_TYPES.put(DataTypeRoot.FLOAT, orderedSet(Float.class, float.class));
92-
SUPPORTED_TYPES.put(DataTypeRoot.DOUBLE, orderedSet(Double.class, double.class));
93-
SUPPORTED_TYPES.put(
94-
DataTypeRoot.CHAR, orderedSet(String.class, Character.class, char.class));
95-
SUPPORTED_TYPES.put(
96-
DataTypeRoot.STRING, orderedSet(String.class, Character.class, char.class));
97-
SUPPORTED_TYPES.put(DataTypeRoot.BINARY, orderedSet(byte[].class));
98-
SUPPORTED_TYPES.put(DataTypeRoot.BYTES, orderedSet(byte[].class));
99-
SUPPORTED_TYPES.put(DataTypeRoot.DECIMAL, orderedSet(BigDecimal.class));
100-
SUPPORTED_TYPES.put(DataTypeRoot.DATE, orderedSet(LocalDate.class));
101-
SUPPORTED_TYPES.put(DataTypeRoot.TIME_WITHOUT_TIME_ZONE, orderedSet(LocalTime.class));
102-
SUPPORTED_TYPES.put(
103-
DataTypeRoot.TIMESTAMP_WITHOUT_TIME_ZONE, orderedSet(LocalDateTime.class));
86+
SUPPORTED_TYPES.put(DataTypeRoot.BOOLEAN, setOf(Boolean.class, boolean.class));
87+
SUPPORTED_TYPES.put(DataTypeRoot.TINYINT, setOf(Byte.class, byte.class));
88+
SUPPORTED_TYPES.put(DataTypeRoot.SMALLINT, setOf(Short.class, short.class));
89+
SUPPORTED_TYPES.put(DataTypeRoot.INTEGER, setOf(Integer.class, int.class));
90+
SUPPORTED_TYPES.put(DataTypeRoot.BIGINT, setOf(Long.class, long.class));
91+
SUPPORTED_TYPES.put(DataTypeRoot.FLOAT, setOf(Float.class, float.class));
92+
SUPPORTED_TYPES.put(DataTypeRoot.DOUBLE, setOf(Double.class, double.class));
93+
SUPPORTED_TYPES.put(DataTypeRoot.CHAR, setOf(String.class, Character.class, char.class));
94+
SUPPORTED_TYPES.put(DataTypeRoot.STRING, setOf(String.class, Character.class, char.class));
95+
SUPPORTED_TYPES.put(DataTypeRoot.BINARY, setOf(byte[].class));
96+
SUPPORTED_TYPES.put(DataTypeRoot.BYTES, setOf(byte[].class));
97+
SUPPORTED_TYPES.put(DataTypeRoot.DECIMAL, setOf(BigDecimal.class));
98+
SUPPORTED_TYPES.put(DataTypeRoot.DATE, setOf(LocalDate.class));
99+
SUPPORTED_TYPES.put(DataTypeRoot.TIME_WITHOUT_TIME_ZONE, setOf(LocalTime.class));
100+
SUPPORTED_TYPES.put(DataTypeRoot.TIMESTAMP_WITHOUT_TIME_ZONE, setOf(LocalDateTime.class));
104101
SUPPORTED_TYPES.put(
105102
DataTypeRoot.TIMESTAMP_WITH_LOCAL_TIME_ZONE,
106-
orderedSet(Instant.class, OffsetDateTime.class));
103+
setOf(Instant.class, OffsetDateTime.class));
107104

108105
// TODO: Add more types when https://github.com/apache/fluss/issues/816 is merged
109106
}
@@ -558,17 +555,12 @@ private static int getPrecision(DataType dataType) {
558555
}
559556

560557
/**
561-
* Utility method to create an ordered {@link LinkedHashSet} containing the specified Java type
562-
* classes.
563-
*
564-
* <p>The returned set maintains the insertion order of the provided classes.
558+
* Utility method to create a Set containing the specified Java type classes.
565559
*
566560
* @param javaTypes The Java type classes to include in the set. May be one or more classes.
567-
* @return A new {@link LinkedHashSet} containing the given classes, preserving their order.
561+
* @return A new Set containing the given classes.
568562
*/
569-
private static LinkedHashSet<Class<?>> orderedSet(Class<?>... javaTypes) {
570-
LinkedHashSet<Class<?>> linkedHashSet = new LinkedHashSet<>();
571-
linkedHashSet.addAll(Arrays.asList(javaTypes));
572-
return linkedHashSet;
563+
private static Set<Class<?>> setOf(Class<?>... javaTypes) {
564+
return new HashSet<>(Arrays.asList(javaTypes));
573565
}
574566
}

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,8 @@ public void testRowWithMissingFields() {
177177
.field("stringField", DataTypes.STRING())
178178
.build();
179179

180-
PojoConverterUtils<TestPojo> converter = PojoConverterUtils.getConverter(TestPojo.class, rowType);
180+
PojoConverterUtils<TestPojo> converter =
181+
PojoConverterUtils.getConverter(TestPojo.class, rowType);
181182

182183
TestPojo pojo = createTestPojo();
183184

@@ -230,7 +231,9 @@ public void testFieldAccessFailureThrows() {
230231
public void testNoDefaultConstructorPojoThrows() {
231232
RowType rowType = RowType.builder().field("intField", DataTypes.INT()).build();
232233
assertThatThrownBy(
233-
() -> PojoConverterUtils.getConverter(NoDefaultConstructorPojo.class, rowType))
234+
() ->
235+
PojoConverterUtils.getConverter(
236+
NoDefaultConstructorPojo.class, rowType))
234237
.isInstanceOf(IllegalArgumentException.class)
235238
.hasMessageContaining("must have a default constructor");
236239
}
@@ -409,5 +412,4 @@ public NoDefaultConstructorPojo(int intField) {
409412
this.intField = intField;
410413
}
411414
}
412-
413415
}

0 commit comments

Comments
 (0)