cshuo commented on code in PR #4164: URL: https://github.com/apache/flink-cdc/pull/4164#discussion_r2472422414
########## flink-cdc-connect/flink-cdc-pipeline-connectors/flink-cdc-pipeline-connector-hudi/src/main/java/org/apache/flink/cdc/connectors/hudi/sink/event/HudiRecordEventSerializer.java: ########## @@ -0,0 +1,229 @@ +/* + * 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.cdc.connectors.hudi.sink.event; + +import org.apache.flink.cdc.common.data.RecordData; +import org.apache.flink.cdc.common.event.CreateTableEvent; +import org.apache.flink.cdc.common.event.DataChangeEvent; +import org.apache.flink.cdc.common.event.Event; +import org.apache.flink.cdc.common.event.SchemaChangeEvent; +import org.apache.flink.cdc.common.event.TableId; +import org.apache.flink.cdc.common.schema.Schema; +import org.apache.flink.cdc.common.utils.SchemaUtils; +import org.apache.flink.cdc.connectors.hudi.sink.util.RowDataUtils; + +import org.apache.hudi.client.model.HoodieFlinkInternalRow; + +import java.time.ZoneId; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * A {@link HudiRecordSerializer} for converting {@link Event} into {@link HoodieFlinkInternalRow} + * for Hudi writing. + * + * <p>This serializer maintains schema state per table and handles multi-table CDC events by: + * + * <ul> + * <li>Caching schemas from CreateTableEvent and SchemaChangeEvent + * <li>Converting DataChangeEvent to HoodieFlinkInternalRow using cached schemas + * <li>Supporting bucket-wrapped events from upstream operators + * </ul> + * + * <p>Assumes that CreateTableEvent will always arrive before DataChangeEvent for each table, + * following the standard CDC pipeline startup sequence. + */ +public class HudiRecordEventSerializer implements HudiRecordSerializer<Event> { Review Comment: Seems `HudiRecordEventSerializer` is designed to deal with serializing for multiple tables. Like comments in `EventStreamWriteFunction`, `HudiRecordEventSerializer` can be a field of `MultiTableStreamWriteOperatorCoordinator`? serializing data change event to HoodieFlinkInternalRow and dispatch to corresponding table write functions. -- 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]
