pvary commented on code in PR #6299: URL: https://github.com/apache/iceberg/pull/6299#discussion_r1038742272
########## flink/v1.16/flink/src/main/java/org/apache/iceberg/flink/source/enumerator/EnumerationHistory.java: ########## @@ -0,0 +1,58 @@ +/* + * 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.iceberg.flink.source.enumerator; + +import javax.annotation.concurrent.ThreadSafe; +import org.apache.flink.calcite.shaded.com.google.common.collect.EvictingQueue; + +/** + * This enumeration history is used for split discovery throttling. It wraps Guava {@link + * EvictingQueue} to provide thread safety. + */ +@ThreadSafe +class EnumerationHistory { + + // EvictingQueue is not thread safe. + private final EvictingQueue<Integer> enumerationSplitCountHistory; + + EnumerationHistory(int maxHistorySize) { + this.enumerationSplitCountHistory = EvictingQueue.create(maxHistorySize); + } + + /** Add the split count from the last enumeration result. */ + synchronized void add(int splitCount) { + enumerationSplitCountHistory.add(splitCount); + } + + /** @return true if split discovery should pause because assigner has too many splits already. */ + synchronized boolean shouldPauseSplitDiscovery(int pendingSplitCountFromAssigner) { + if (enumerationSplitCountHistory.remainingCapacity() > 0) { + // only check throttling when full history is obtained. Review Comment: What I missed before, but realized now is that the reader stores the row position of the file reader in the checkpoint state. So the reader will not start from the beginning, and this way we will not advance the checkpoint infinitely... Still feel that it will cause issues/misunderstanding later if only some part of the IcebergSource state is checkpointed. The source should be either fully checkpointed or not at all. I would not have exceptions for this rule without a very strong reason. -- 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...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org