stevenzwu commented on code in PR #6299: URL: https://github.com/apache/iceberg/pull/6299#discussion_r1038422914
########## 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: @pvary Just to make sure that I understand you correctly. You agree that the big file and restart is not a problem for causing infinite amount of enumerated splits. You see that constant restarts with completed checkpoints btw can lead to ever-growing enumerated splits. For that reason, you are in favor of adding the checkpointing of the enumeration history for more proper throttling behavior, right? -- 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