leaves12138 commented on code in PR #1072: URL: https://github.com/apache/incubator-paimon/pull/1072#discussion_r1185989015
########## paimon-core/src/main/java/org/apache/paimon/operation/AbstractFileStoreScan.java: ########## @@ -316,19 +320,27 @@ private boolean filterManifestFileMeta(ManifestFileMeta manifest) { } /** Note: Keep this thread-safe. */ - private boolean filterByBucket(ManifestEntry entry) { + private boolean filterByBucket(AbstractManifestEntry entry) { return (specifiedBucket == null || entry.bucket() == specifiedBucket); } /** Note: Keep this thread-safe. */ - private boolean filterByBucketSelector(ManifestEntry entry) { + private boolean filterByBucketSelector(AbstractManifestEntry entry) { return (bucketSelector == null || bucketSelector.select(entry.bucket(), entry.totalBuckets())); } /** Note: Keep this thread-safe. */ - private boolean filterByLevel(ManifestEntry entry) { - return (levelFilter == null || levelFilter.test(entry.file().level())); + private boolean filterByLevel(AbstractManifestEntry entry) { + return (levelFilter == null || levelFilter.test(entry.level())); + } + + /** Note: Keep this thread-safe. */ + private boolean filterByStats(AbstractManifestEntry entry) { + if (entry instanceof ManifestEntry) { + return filterByStats((ManifestEntry) entry); + } + return true; Review Comment: done ########## paimon-core/src/main/java/org/apache/paimon/utils/ParallellyExecuteUtils.java: ########## @@ -0,0 +1,106 @@ +/* + * 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.paimon.utils; + +import java.util.ArrayDeque; +import java.util.Iterator; +import java.util.List; +import java.util.NoSuchElementException; +import java.util.Queue; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; +import java.util.function.Function; + +/** + * This class is a parallel execution util class, which mainly aim to process tasks parallelly with + * memory control. + */ +public class ParallellyExecuteUtils { + + public static <T, U> Iterable<T> parallelismBatchIterable( + Function<List<U>, List<T>> processor, List<U> input) { + // default queueSize + int queueSize = FileUtils.COMMON_IO_FORK_JOIN_POOL.getParallelism() * 2; + + return parallelismBatchIterable(processor, input, queueSize); + } + + // reduce memory usage by batch iterable process, the cached result in memory will be queueSize + public static <T, U> Iterable<T> parallelismBatchIterable( + Function<List<U>, List<T>> processor, List<U> input, int queueSize) { + if (queueSize <= 0) { + throw new NegativeArraySizeException("queue size should not be negetive"); + } + + // apart queue + final Queue<List<U>> stack = new ArrayDeque<>(); + int size = input.size(); + int num = size / queueSize; + + for (int i = 0; i < num; i++) { Review Comment: done -- 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...@paimon.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org