gaoyunhaii commented on a change in pull request #18428: URL: https://github.com/apache/flink/pull/18428#discussion_r796455508
########## File path: flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/operators/sink/committables/CommittableCollector.java ########## @@ -0,0 +1,243 @@ +/* + * 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.streaming.runtime.operators.sink.committables; + +import org.apache.flink.annotation.Internal; +import org.apache.flink.api.common.functions.RuntimeContext; +import org.apache.flink.api.connector.sink2.Sink.InitContext; +import org.apache.flink.api.java.tuple.Tuple2; +import org.apache.flink.streaming.api.connector.sink2.CommittableMessage; +import org.apache.flink.streaming.api.connector.sink2.CommittableSummary; +import org.apache.flink.streaming.api.connector.sink2.CommittableWithLineage; + +import javax.annotation.Nullable; + +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.NavigableMap; +import java.util.TreeMap; +import java.util.stream.Collectors; + +import static org.apache.flink.util.Preconditions.checkNotNull; + +/** + * This class is responsible to book-keep the committing progress across checkpoints and subtasks. + * It handles the emission of committables and the {@link CommittableSummary}. + * + * @param <CommT> type of committable + */ +@Internal +public class CommittableCollector<CommT> { + private static final long EOI = Long.MAX_VALUE; + /** Mapping of checkpoint id to {@link CheckpointCommittableManagerImpl}. */ + private final NavigableMap<Long, CheckpointCommittableManagerImpl<CommT>> + checkpointCommittables; + /** Denotes the subtask id the collector is running. */ + private final int subtaskId; Review comment: Hi Fabian~ Thanks for the explanation! My main concern comes from that I think current the `CheckpointCommittableManagerImpl` takes two roles: the first is the manager of committables of one checkpoint in memory and another is the data to be stored in the state. For the first role, having `subtaskId` and `numberOfSubtassks` is natural. But for the second role, the two fields are not needed, currently we set it with arbitrary values (0 and 1 respectively), I think this might cause a bit confusion. Thus it seems to me it might be better if we either extract out the two optional fields, or we do not reuse the same object for these two roles~ -- 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]
