michaelkoepf commented on code in PR #1404: URL: https://github.com/apache/fluss/pull/1404#discussion_r2231345919
########## fluss-client/src/main/java/com/alibaba/fluss/client/utils/ConverterUtils.java: ########## @@ -0,0 +1,608 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.alibaba.fluss.client.utils; + +import com.alibaba.fluss.row.BinaryString; +import com.alibaba.fluss.row.Decimal; +import com.alibaba.fluss.row.GenericRow; +import com.alibaba.fluss.row.InternalRow; +import com.alibaba.fluss.row.TimestampLtz; +import com.alibaba.fluss.row.TimestampNtz; +import com.alibaba.fluss.types.DataType; +import com.alibaba.fluss.types.DataTypeRoot; +import com.alibaba.fluss.types.DecimalType; +import com.alibaba.fluss.types.LocalZonedTimestampType; +import com.alibaba.fluss.types.RowType; +import com.alibaba.fluss.types.TimestampType; +import com.alibaba.fluss.utils.MapUtils; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.annotation.Nullable; + +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.math.BigDecimal; +import java.time.Instant; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.time.OffsetDateTime; +import java.time.ZoneOffset; +import java.util.Arrays; +import java.util.HashMap; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; + +/** + * Helper class for converting Java POJOs to Fluss's {@link InternalRow} format and vice versa. Review Comment: I think the precondition introduced here ("Java POJO") is not restrictive enough, because a [POJO](https://www.baeldung.com/java-pojo-class#what-is-a-pojo) may not necessarily have a default constructor, but the code does assume one. Maybe it is better to use the more standardized concept of a [Java Bean](https://www.baeldung.com/java-pojo-class#what-is-a-javabean.)? Then, Java users immediately know what there classes must look like in order to use them with the converter. While Java Beans come with boilerplate (field access via getters), Java users won't bother too much because Java beans are everywhere, so they are used to it. An additional benefit is that by saying we expect a Java bean, there _must be_ a public constructor and public setters, so we do not need to tinker around with the `setAccessible` reflection calls. We can just fail with an exception. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
