tsreaper commented on code in PR #433: URL: https://github.com/apache/flink-table-store/pull/433#discussion_r1046796807
########## flink-table-store-connector/src/main/java/org/apache/flink/table/store/connector/sink/StoreSinkWriteImpl.java: ########## @@ -0,0 +1,101 @@ +/* + * 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.connector.sink; + +import org.apache.flink.runtime.state.StateInitializationContext; +import org.apache.flink.runtime.state.StateSnapshotContext; +import org.apache.flink.table.data.binary.BinaryRowData; +import org.apache.flink.table.store.table.FileStoreTable; +import org.apache.flink.table.store.table.sink.FileCommittable; +import org.apache.flink.table.store.table.sink.TableWrite; + +import javax.annotation.Nullable; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +/** Default implementation of {@link StoreSinkWrite}. This writer does not have states. */ +public class StoreSinkWriteImpl implements StoreSinkWrite { + + protected final FileStoreTable table; + protected final String commitUser; + protected final TableWrite write; + + public StoreSinkWriteImpl( + StateInitializationContext context, FileStoreTable table, String initialCommitUser) + throws Exception { + this.table = table; + + // each job can only have one user name and this name must be consistent across restarts + // we cannot use job id as commit user name here because user may change job id by creating + // a savepoint, stop the job and then resume from savepoint + commitUser = + StateUtils.getSingleValueFromState( + context, "commit_user_state", String.class, initialCommitUser); + + // see comments of StateUtils.getSingleValueFromState for why commitUser may be null + if (commitUser == null) { + write = null; Review Comment: More comments added. -- 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: issues-unsubscr...@flink.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org