yuzelin commented on code in PR #1822: URL: https://github.com/apache/incubator-paimon/pull/1822#discussion_r1295348775
########## paimon-flink/paimon-flink-common/src/main/java/org/apache/paimon/flink/sink/cdc/UpdatedDataFieldsBaseProcessFunction.java: ########## @@ -0,0 +1,176 @@ +/* + * 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.paimon.flink.sink.cdc; + +import org.apache.paimon.catalog.Catalog; +import org.apache.paimon.catalog.Identifier; +import org.apache.paimon.schema.SchemaChange; +import org.apache.paimon.schema.SchemaManager; +import org.apache.paimon.schema.TableSchema; +import org.apache.paimon.types.DataType; +import org.apache.paimon.types.DataTypeChecks; +import org.apache.paimon.types.DataTypeRoot; +import org.apache.paimon.utils.Preconditions; + +import org.apache.flink.streaming.api.functions.ProcessFunction; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Arrays; +import java.util.List; + +/** Base class for update data fields process function. */ +public abstract class UpdatedDataFieldsBaseProcessFunction<I, O> extends ProcessFunction<I, O> { Review Comment: 1. `UpdatedDataFieldsBaseProcessFunction` -> `UpdatedDataFieldsProcessFunctionBase` 2. Some methods can be moved to this class: `Open`, `Close`. 3. Some common codes can be refactored and placed to this class: `UpdatedDataFieldsProcessFunction#getSchemaChanges` is static method and used by `MultiTableUpdatedDataFieldsProcessFunction`. ########## paimon-flink/paimon-flink-common/src/main/java/org/apache/paimon/flink/sink/cdc/MultiTableUpdatedDataFieldsProcessFunction.java: ########## @@ -53,16 +47,17 @@ * be 1. */ public class MultiTableUpdatedDataFieldsProcessFunction - extends ProcessFunction<Tuple2<Identifier, List<DataField>>, Void> { + extends UpdatedDataFieldsBaseProcessFunction<Tuple2<Identifier, List<DataField>>, Void> { private static final Logger LOG = LoggerFactory.getLogger(MultiTableUpdatedDataFieldsProcessFunction.class); private final Map<Identifier, SchemaManager> schemaManagers = new HashMap<>(); - private Catalog catalog; + private final Catalog.Loader catalogLoader; public MultiTableUpdatedDataFieldsProcessFunction(Catalog.Loader catalogLoader) { + super(catalogLoader); this.catalogLoader = catalogLoader; Review Comment: delete `this.catalogLoader = catalogLoader` ########## paimon-flink/paimon-flink-common/src/main/java/org/apache/paimon/flink/sink/cdc/UpdatedDataFieldsProcessFunction.java: ########## @@ -50,23 +44,21 @@ * <p>NOTE: To avoid concurrent schema changes, the parallelism of this {@link ProcessFunction} must * be 1. */ -public class UpdatedDataFieldsProcessFunction extends ProcessFunction<List<DataField>, Void> { +public class UpdatedDataFieldsProcessFunction + extends UpdatedDataFieldsBaseProcessFunction<List<DataField>, Void> { private static final Logger LOG = Review Comment: LOG is not used any more, can be deleted. -- 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]
