JingsongLi commented on code in PR #480: URL: https://github.com/apache/flink-table-store/pull/480#discussion_r1071039367
########## flink-table-store-core/src/main/java/org/apache/flink/table/store/file/casting/CastedRowData.java: ########## @@ -0,0 +1,170 @@ +/* + * 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 org.apache.flink.table.store.file.casting; + +import org.apache.flink.table.data.ArrayData; +import org.apache.flink.table.data.DecimalData; +import org.apache.flink.table.data.MapData; +import org.apache.flink.table.data.RawValueData; +import org.apache.flink.table.data.RowData; +import org.apache.flink.table.data.StringData; +import org.apache.flink.table.data.TimestampData; +import org.apache.flink.types.RowKind; + +/** + * An implementation of {@link RowData} which provides a casted view of the underlying {@link + * RowData}. + * + * <p>It reads data from underlying {@link RowData} according to source logical type and casts it + * with specific {@link CastExecutor}. + * + * <p>Note: This class supports only top-level castings, not nested castings. + */ +public class CastedRowData implements RowData { + + private final FieldGetterCastExecutor[] castMapping; Review Comment: Maybe we can just use `CastExecutor`? ########## flink-table-store-core/src/main/java/org/apache/flink/table/store/file/schema/IndexCastMapping.java: ########## @@ -0,0 +1,45 @@ +/* + * 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 org.apache.flink.table.store.file.schema; + +import org.apache.flink.table.store.file.casting.FieldGetterCastExecutor; + +import javax.annotation.Nullable; + +/** Class includes index mapping and cast mapping. */ +public class IndexCastMapping { Review Comment: `IndexCastMapping` can be a inner class in `SchemaEvolutionUtil`. ########## flink-table-store-core/src/main/java/org/apache/flink/table/store/file/io/AbstractFileRecordIterator.java: ########## @@ -31,14 +33,21 @@ */ public abstract class AbstractFileRecordIterator<V> implements RecordReader.RecordIterator<V> { @Nullable private final ProjectedRowData projectedRowData; + @Nullable private final CastedRowData castedRowData; - protected AbstractFileRecordIterator(@Nullable int[] indexMapping) { + protected AbstractFileRecordIterator( + @Nullable int[] indexMapping, @Nullable FieldGetterCastExecutor[] castMapping) { this.projectedRowData = indexMapping == null ? null : ProjectedRowData.from(indexMapping); + this.castedRowData = castMapping == null ? null : CastedRowData.from(castMapping); } protected RowData mappingRowData(RowData rowData) { - return projectedRowData == null - ? rowData - : (rowData == null ? null : projectedRowData.replaceRow(rowData)); + final RowData projection = Review Comment: Can we use some if here? like: ``` If (row == null) { return null; } if (projectedRow != null) { row = ....; } if (castedRow != null) { row = ....; } return row; ``` -- 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]
