rdblue commented on code in PR #8123: URL: https://github.com/apache/iceberg/pull/8123#discussion_r1275570727
########## core/src/main/java/org/apache/iceberg/DistributedDataBatchScan.java: ########## @@ -0,0 +1,309 @@ +/* + * 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; + +import com.github.benmanes.caffeine.cache.Caffeine; +import com.github.benmanes.caffeine.cache.LoadingCache; +import java.util.List; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionException; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.function.Function; +import java.util.stream.Collectors; +import org.apache.iceberg.expressions.Expression; +import org.apache.iceberg.expressions.ManifestEvaluator; +import org.apache.iceberg.expressions.Projections; +import org.apache.iceberg.expressions.ResidualEvaluator; +import org.apache.iceberg.io.CloseableIterable; +import org.apache.iceberg.relocated.com.google.common.collect.ImmutableList; +import org.apache.iceberg.relocated.com.google.common.util.concurrent.MoreExecutors; +import org.apache.iceberg.relocated.com.google.common.util.concurrent.ThreadFactoryBuilder; +import org.apache.iceberg.util.TableScanUtil; + +abstract class DistributedDataBatchScan + extends SnapshotScan<BatchScan, ScanTask, ScanTaskGroup<ScanTask>> implements BatchScan { + + private static final int NUM_LOCAL_CORES = Runtime.getRuntime().availableProcessors(); + private static final long METADATA_LIMIT_PER_LOCAL_CORE = 128 * 1024 * 1024; // 128 MB + private static final int NUM_WORKER_THREADS = 2; + + protected DistributedDataBatchScan(Table table, Schema schema, TableScanContext context) { + super(table, schema, context); + } + + protected abstract int remoteParallelism(); + + protected abstract PlanningMode dataPlanningMode(); + + protected abstract List<DataFile> planDataRemotely(List<ManifestFile> manifests); Review Comment: One thing that makes me uneasy about this interface is that the correctness of these methods' implementations is critical, but we don't really have anything enforcing that correctness. We could add additional checks that re-apply the file filter to the data file's partition and statistics, although that would be slower. I think that might be a good idea still, if we put it behind a flag that you can override: ```java public boolean runDataFileFilters() { return true; // override to turn off filtering if it is done by planDataRemotely } ``` It might also help to have some utilities, like a Serializable ScanHelper that can be sent to executors and called to produce the right data files. -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
